Thursday, 17 September 2020

Coding 17/9

 Joe Simmonds - joe.simmonds@sit.ac.nz

1st year recap

3 sections to coding:
Variables, Functions and Methods
  • Variables store data that can be referenced or changed, basically any assets can be stored and referenced as variables. The 4 main types we are using are Strings(Basically ASCII storage of names, passwords, dialogue etc. Cannot be used for calculations), Ints(Integer, whole numbers only), Floats(Any number with a decimal place, used in % type health bars) and Bools(Boolean, true/false, yes/no) .
  • Functions are blocks of code that are triggered at specific times in your game. We are using 3 main ones: Start(), Update() - runs on each frame refresh and FixedUpdate() - runs on a set frame rate. 
  • Methods are similar to functions but only run when they are "called". Methods can have a lot of code/instructions then we can call it with a single line of code in a Function.
C# Syntax
End code lines with ; and {} denotes a paragraph of code. When writing variables remember to set public(can be used by any script) or private(can only be used by the script it is written in) and must have a lower case p. Next is the type of variable, and then the name of the variable(any name we want/will remember but with no spaces. Use lower case to distinguish from functions/methods which use capital letters). Finish it with the initial state of the variable, in this case it is in quotations due to being a string.

public string location = "Invercargill";
private in score = 0;

  • = symbol tells a variable that there is a new value
  • == symbol is asking to check what the current value of the variable is
  • "if" statements checks values before a piece of code is run
  • "if else" statements are the same as If statements with an extra code that runs if the first part is true and will do nothing if the first part is false.
  • && symbol tells the code to check more than one variable before running the code. Both must be true before the code will run
  • || symbol means "or" in which the code will run if one of the two conditions are met.
  • Short form boolean writing is where the variable is shortened to the name only ie: if(jump == true) gets shortened to if(jump). if(jump == false) shortens to if(!jump).
  • // comments out anything written after them
Exporting from Unity to Maya for tweaking

Have at least one basic floor blocked out for next week, and character modelled and rigged from gaming class.

No comments:

Post a Comment

BSA702 14/7

 arrays and lists Quick and Easy Galaxy painting  great tutorial I found when I was looking for a background for my pitch tomorrow. I want t...