Game Development Reference
In-Depth Information
GameObject.Move.Left;
}
We should mention at this point that there are only two lines of code in these if state-
ments, but there can be many more. Imagine how gigantic the code base is for some of the
games you play. Those games are much more complex. Sometimes, the logic for the right
arrow being pressed can be more than a page of logic. Let's add some code that will make
the GameObject move in four directions. The code is as follows:
if (RightArrow.Pressed) {
GameObject.Speed = 10;
GameObject.Move.Right;}
if (LeftArrow.Pressed) {
GameObject.Speed = 10;
GameObject.Move.Left;}
if (UpArrow.Pressed) {
GameObject.Speed = 10;
GameObject.Move.Up;}
if (DownArrow.Pressed) {
GameObject.Speed = 10;
GameObject.Move.Down;
}
This is a lot of code and we are not even making a complex game. So far, our game just
has a GameObject moving up, down, left, and right. We have no projectiles, no antag-
onists, and no artificial intelligence. So, why a code like this? Well, it's only recently that
non-coding languages have been around. If you have ever played a game, it was painstak-
ingly coded. We should also point out that the preceding code is an abbreviated version to
make it simpler. Depending on the language, moving something across the screen might
take many more lines of code.
Search WWH ::




Custom Search