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

Computer Combat

Now that you have programmed the player’s attacks, it is time to program the computer attack code. This is slightly more complicated than the player’s attack code because it means the computer needs to find out which unit is selected, which unit it should attack. It will also need to find out the results of the attack and play them out on screen.

Note

Because many aspects of the code is reused, we will only be covering the combat aspect in detail; for any changes to other aspects of the code, we will provide a quick overview of what has changed.

First you need to open the file that we have already created with all the previous changes implemented and our other changes. The file is called Combat3.mfa and can be found in the Examples ...

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