O'Reilly logo

Learning Unity 2D Game Development by Example by Venita Pereira

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Code fundamentals

In order to create our own code, we need to understand the foundations of programming so that we can build upon it.

Code is made up of the following main components:

  • Variables
  • Data types
  • Operators (also known as expressions)
  • Functions (also known as methods)
  • Comments
  • Library import variables

When programming, we make use of variables to store both known and unknown information in the form of values and identifiers in named locations in memory.

For instance, we could store the name of the main character in our game in a variable, as shown in the following line of code:

Name = Hercules

Name is the variable's identifier, and Hercules is the stored value assigned to the variable Name.

Data types

Variables are used in programming to store different ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required