Dealing with more units

Dealing with one unit or even one unit per team is pretty simple. When you start to have multiple units per team, things start to get hairy. In this lesson, we'll deal with a fixed number of units per team. This code will lay the foundation for lesson where we'll add cities. With cities we'll be able to have an indeterminate number of units per team. Requires a browser that supports applets
This is meant to be a replacement when we do things (javascript menus) that might get hidden behind the applet.


Using arrays to track a static number of units: 5 vs 5
Should be able to change the number of units simply by increasing the size of the arrays

Selecting a unit

Cycling through all the units in a team with the 'n' key
Adding unit info to output
Add a square around the selected unit to indicate which one's selected

Dealing with multiple units

Moving the current unit
All these things that were simple if/else statements before are sudeenly a lot more complicated: functional decomposition

Conflict with multiple units

Have to take odds of multiple units into account: much more complicated
Detecting the end of the game

Rate this lesson: *****