Battle!

Battle!

The class was given code for a Turtle object with some basic functionality, like turning right or left, moving to a specified location, moving forward, etc. It was based on the Logo turtle developed at MIT. If I remember correctly, the assignment was to use inheritance to create sub-classes of Turtle and do something interesting with them. I had seen one of the Lord of the Rings movies recently and didn’t have any better ideas, so I decided to build a basic battle simulation.

The humans and orcs both have infantry and archers. Each soldier maintains its own health value; the infantry start off with more than the archers. Each soldier watches for the nearest enemy and targets them. The infantry will charge the enemy and attack at close range, while archers hang back to shoot arrows. I found that they were far too vulnerable standing still, so they keep stepping to the side while facing their targeted enemy. As such, they sort of walk in circles. When one of the armies has been eliminated, the other does a little dance, but more men can be added at any time using the buttons on the right.

It’s not a very complex project, but it was fun to build. By the time it was nearly finished, I spent almost as much time playing with it as I did coding it - it turned out to be more entertaining than I expected.