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.

Share


About

BrockMy name is Brock.

I am a web developer, an atheist, a DC resident, and a bit of a movie enthusiast. I try to write about those topics at least now and again, but this site is mostly just a bunch of crap about my life.

I grew up outside Buffalo, NY, and went to RIT. In November 2005, I moved to the Washington, DC metro area. For the most part, it’s been pretty good to me.  These days, I live a couple blocks from Chinatown in DC with my lovely wife Erin and our Bichon, Lola May, and work for a PR firm downtown.

You can contact me by e-mail at brock@brockboland.com.

Elsewhere

Share

Categories