02 Language Notes
Logical Operators
&& = both true
|| = either true
! = false to be true
Types of Data
String = text (ex. Console.WriteLine("Hello World");)
Int = Whole number (ex. Int area = 120;)
double = decimal number (ex. double weight = 1.54;)
Float = less accurate decimal (postfix f)
Decimal = more accurate decimal (postfix m)
Bool = true or false
var = any data type can be used
String Info
" = for having Quotation marks in strings
Data in strings = use $ before the quotation and then {} around the variable
\t = adds a tab
\n = creates a new line
Methods
block of code defined within a class that controls game behavior, logic, and interactions.
Start() = Called once before the first frame update
Update() = Called once per frame
void = the method doesn't return a value
public = shows the class in the component menu and to other classes
. = directs into a method
transform = position of the object
Vector3 = x y z
Vector2 = x y
new = keyword to create something
If & Switch Statements
Switch
int choice = 2;
switch(choice);
{
// "1" is the thing that has to be true for this case to run (can be any form of data)
case 1:
Console.Write("example1");
// "break" stops the code so it doesn't run the rest.
break;
case 2:
Console.Write("ex. 2");
break;
// default = else(no match)
default:
Console.Write("no match");
break;
}
If
int x = -10
if(x<0)
{
Console.WriteLine("less than 0");
}
else
{
Console.WriteLine("greater than zero");
}
Loops
for
/* initializer creates a variable, condition is what is needed to stop the loop
and the iterator is what runs every time the loop runs */
for (initializer; condition; iterator)
{
// code block
}