Software Engineering: Extending Classes

For this in-class exercise, we will be extending the project we worked on yesterday. First, downlowd the solution to the exercise from last class:

We are going to make a few changes to this project: Multiple players, homining missles. If there is sufficient time, we will make the changes as data-driven as possible

Adding Multiple Players

FIrst up, we need to add multiple players. If you look at the Player.css class, there are a few things that get in the way of multiple players. The first is in the Update method -- we have hardcoded the keys for movement and firing of the player. That won't work for mutliple players. So, we need to:

Homing Bullets

With proper program decomposition, adding new features is not hard. Create a new Particle class, which is a subclass of the existing partilce class. The constructor should take as input parameter the object (for now, just a Player object) that is being targeted. (Really, we should make a superclass (or an interface) of all objects, of which the Player is a subclass. This superclass (or interface) should contain a position -- then the homing projectiles can home on anything that is a sublcass (or implementation) of this class (or interface)

For the easiest homing bullet, have the bullet's velocity point directly at the target every frame. For added challenge (and a better visual effect), give the bullets a maximum rotational velocity, and rotate the bullet's velocity in the direction of the target each frame using the rotational velocity to determine how far to rotate each frame

Collision

If you still have time, add simple collision with particles and ships (or ships and ships). Given that we are rotating rectangles, this will be difficult to do with any accuracy until we go over collision detection, later this semester. However, you should be able to get something (even with a really inaccurate bounding box)

Some things to think about: