Zombie Madness

Zombie Madness

By Balraj Aujla

Description:

Zombie madness is a first perosn shooter survival game. The goal of the game is to survive as long as possible and to kill as many zombies as you can! To kill the zombies the player is given an automatic assult rifle and infinite ammunition, however the clip size is only forty bullets. When the player runs out of bullets the gun reloads for seven seconds and then the player can shoot again. Also for more precision aiming the player may look down the gun's sights. This will reduce recoil and give a much nicer indication of what is being shot. The player is also able to sprint throughout the game world at the cost of stamina. The initial stamina is set to about 3000 and when sprinting is halted the stamina begins to regenerate. The regeneration model is that when stamina is very low it increses much faster than when it is almost full. The other attribute the player has is health, which is initialized to 100. Once the player loses health there is no way to get it back and when the health attribute is zero the game over screen is shown and the program exits. The zombies will never stop regenrating and will always be trying to kill the player.


zombie1

Controls:

W: Move foward
A: Move Left
D: Move Right
S: Move Backwards
R: Sprint
SPACE: Aim Down Sights
MOUSE CLICK: Shoot Bullets


zombie1

Techincal:

Zombie Madness was programmed with a combination of C++ and openGL and it draws heavily from the code that was developed throughout CPE 471. The project really began in lab7 when the class had to develop the blinn phong lighting model. As the lighting system developed in lab is essentially the same as the one used in the project. However when textures are added in, the specular component and shineiness is minimilized as no objects in the world are meant to be shiny at all. Then assignment 4 contributed heavily as all the movement using the "W, A, S, D" Keys and camera movement was implemetned then. Everything else that is in the game was made specifically for this project.

The first challenge was to make the gun simply follow the camera. This turned out to be much simpler than i thought it would be as i simply had to multipy the gun's matrix with the camera matrix and provide a small offset and rotation to have it point to the center of the screen. Then i set the mouse cursor to be invisible (Any image showing cursor on this page is due to centos screenshot program capturiing mouse which is invisible while program is running) to make it so the player would be more likely to aim down the sights. To make it so the player could aim down the sights the gun's offset from the camera matrix was modified when the space key was held down. But at this point the gun was practicaly useless as it could not shoot. The bullets were made using my own custom particle system which could generate about forty bullets in about forty frames, a problem which would later be fixed. Once the particle system was created the camera matrix was saved at the instance each bullet was created and applied to each individual bullet. Then i applied a constant translation on the bullet which made it constantly move forward. Once the bullet had been alive for a good amount of time it was set to not exist. However there were two problems at this point as it seemed the bullets were shootng out incredibly fast and they were also always traveling in a straight line. The fix for this was to include a timer which would only allow a bullet to be shot when it equaled zero. This gave me perfect control of the rate of fire and made it so the player did not shoot sixty bullets per second. The other problem was fixed by having each bullet slowly translate downwards as the lifetime went down.

The next thing to do was collision detection. As i did not have the zombies loaded in at this time i used the bunny obj that we had been using throughout the class as a test. I imported the bounding box class that Professor Sueda implemented for us and placed a bounding box around every bunny and every bullet. When the bullet and bunny had collided four times the bunny would no longer be drawn. Then as the bullet moved through the world it is contantlly checking if it had collided with any of the bunnies.This was very simple as the bounding box class had been given, however one problem arose. The bullet was being translated in a way such as "position.z -= 5" which meant that a bullet could easily miss an object whose size was less than five. To fix this the bounding box was simply scaled up by five in the z axis and the problem was seemingly fixed. It was at this point where i went online and downloded all my objects(other than the gun which had aleady been uploaded) into the world. I then applied the given textures and had a world populated with a house in the middle, about forty trees, and very creepy zombies.

Now all that was left was making it so the zombies actually attacked the player. The initial AI for this part was to simply have each zombie caclulate it's distance from the player in each frame and minimize that distance. When any zombie had a distance too close to the player the player would simply lose health. This AI truned out to be very problemeatic as all the zombies would move in a straight line and sometimes merge into one big line together. To fix this the zombies had some randomenss calculated in how they moved at the player. This AI was slightly better however some of the previous problems still existed but were minimized. If more time was given I would have implemented A* star search for the zombies so they could move in a more logical way. I would have also made it so the player and the zombies could not move through objects, which would be easy to do yet time consuming.


zombie1

References:

Shinjiro Sueda, for the bounding box class, and all the source code for Lab7, and Assignment 4.
www.turbosquid.com, for the house, tree, and zombie objects & included textures.
www.tf3dm.com, for the gun object and textures.