O'Reilly logo

Going to War: Creating Computer War Games by Jason Darby

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

Basic Movement Point Calculation

Now that you have assigned an object with its starting point value, it is time to do a basic set of calculations so that when the player presses a particular key, the movement points will reduce.

Following are the things you need to do:

  • Set the Current Movement Value to the same value as the starting movement value.

  • Set the Current starting value to the counter object. This allows you to keep a real-time view of the movement points decreasing.

  • Check for when the keyboard is pressed and reduce the current movement value by 1.

  • To ensure that the counter is correct at all times, you must create a condition that sets the counter to the current value when a specific key is pressed.

Setting the Value

At the beginning ...

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