April 2017
Beginner to intermediate
394 pages
9h 16m
English
When we want to move a game object, the simplest way to do it is to update the position at a constant rate. This can work fine for some games. However, for simulating cars, spaceships, or even gravity, it won't look correct. For now, we will use this method as an example then look at physics-based movement a little later. Since we are just updating the object's position, the code to move the player to the right will look like this:
//Move the player to the right //This is just an example //A game should not be hard-coded like this pos.x += 5;
It is worth noting that the value 5 is not measured in inches or meters; it is in game units. Game units are completely arbitrary and are dependent on the size of objects in the ...
Read now
Unlock full access