Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

What constitutes a line?

A topic by Kiki SoDa created Apr 25, 2018 Views: 221 Replies: 2
Viewing posts 1 to 3
Submitted (1 edit)

I am curious what is considered a line for our games? Does it only count if we move to the next line with a newline/enter, or is it something more specific like a semicolon marks the end of a line?

As an example, how many lines would you say the following code contains?


using UnityEngine;

public class Character: MonoBehaviour
{
    public int test_var1 = 100; public float test_var2 = 200;

    void Start()
    {    test_var2+=++test_var1;}


Host (2 edits)

That would be 4. It counts as a line only if it has something on it and if it isn't the start or end of a new function/void/class. The "using" things don't count either (lol, I can't remember what they're called!).

Submitted

So, just to be clear on specifics then, the following should not count as lines:

  • Lines that are simply curly braces: '{' or '}'
  • Import lines: 'using UnityEngine;'
  • Function definitions: 'void Start()'
  • Class definitions: 'public class Character: MonoBehaviour'

However, the other lines would count:

  • Variable declarations: 'public int test_var1 = 100;' and 'public float test_var2 = 200;'
  • Modifying variables: ' test_var2 += ++test_var1;'

I didn't have any in the previous example, but would function calls or conditional statements and loops count?

Example:

for(int i = 0; i < 5; i++){

if(this_counts_as_a_line){

        Debug.Log("This counts as a line?");
}else{

        Debug.Log("Does the else count too?");

}

}

So, while the curly brackets do not count as a line, the for loop definition, if statement, else statement, and Log function calls would all count for a total of 5 lines?