Friday, December 9, 2011

Humans vs. Aliens in Design Patterns

This semester, the sophomores in our Design Patterns class created a game where humans battle it out with aliens. You can watch it on our YouTube channel.

Here is a legend to explain the graphics (clearly, this course was NOT focused on game graphics!):
Green Triangles = Alien
Purple Circle = Human
Black Square = Pistol
Orange Square = Pulse Rifle
Blue Square = Plasma Cannon
Red Square = Chain Gun
Bar along one side = remaining health points

The health bar represents the back of the Human or Alien and helps determine what direction the Human or Alien is facing. Each life form (e.g. Human or Alien) is using a state pattern to determine it's actions (Finding a weapon, Finding a target, Attacking a target, or Reloading). Lifeforms that die are replaced with it's corresponding type (e.g. Human for a Human). Each Alien is given a Linear Recovery Rate that recovers a random amount of health points at a random time rate. For example 5 health points every 4 time ticks. Each Human is given a random amount of armor. The Alien's state pattern has a special case that if the Alien gets hurt enough it will "run" away until enough health is recovered. The Human's state pattern has a special case that if the Human comes across a better weapon (it does more damage) it will swap weapons. The other patterns used in the program: Strategy for the Alien's recovery system, Observer for the time system, and Decorator for the weapon system.