Chocolate Bunny Escape

Game Overview:

    It's been a few months since Easter, and the Cadbury Creme Eggs have gone bad... real bad. They've hatched a batch of bunnies intent on getting back at the people who neglected them at the height of their popular season. Only one person stands in their way, a flamethrower-wielding maniac known only as "Guy". As Guy, you must navigate your way through the hordes of chocolate bunnies, obtaining much needed fuel for your "trusty" bunny-melting apparatus. Melt all bunnies that stand in your way, destroy the boxes of bad eggs, and save the world from a very sticky end.

Gameplay:

    The game uses a third-person over the shoulder camera with fixed field of view and standard mouse and keyboard movement. Bunnies have basic "swarm" AI; they attempt to navigate to the player in the most direct fashion possible, overwhelming by sheer numbers. The main goal of the game is for the player to stay alive, collecting fuel for his flamethrower and health for himself. The game is over when the player has destroyed all three Cadbury Creme Egg boxes.

Full Screenshots:


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Controls:

   Keyboard:
	w - Move player forward
	a - Move player left
	s - Move player backward
	d - Move player right
	ESC - Exit game
   Mouse:
	Move to orient view
	Left-click to fire

 

Technologies:

     Artificial Intelligence      Bunny Melting      Flamethrower Particle System      View Frustrum Culling      World Level of Detail      Sounds
 

 

Artificial Intelligence

Requirements:

1. Bunnies have to move in life-like packs/swarms. Bunnies should not converger into a single file line when approaching the player.
2. Bunnies, when approaching the player, have to attempt to encircle once close enough. This is an extension of the first requirement. Once the pack has reached its target, it should not stay clumped, but should break apart in order to reach the player.

Design:

Using Craig Reynolds' method of modeling artificial life through agent-based steering behaviors, a flocking behavior was implemented. To achieve player circling, a combination of obstacle avoidance and separation behavior was used.

 

Flocking behavior is achieved throuhg a mix of three other behaviors:

    Cohesion is the tendency for bunnies to steer towards their neighbors' average position (Figure 1).

    Alignment is the tendency for bunnies to steer towards their neighbors' average heading (Figure 2).

    Separation is the tendency for bunnies to steer away from their neighbors. Each bunny checks the distance to its neighbor and then applies a force that is inversely proportional in magnitude to the neighbor's distance and in the opposite direction of that neighbor (Figure3).

Figure 1: Components for successful AI


 

In addition to this flocking behavior, Obstacle avoidance is used to enable bunnies to maneuver around each other in order to attack the player. This works by creating a rectangle in front of each bunny. If anything intersects the rectangle, a lateral force is applied away from the nearest object, equal to the lateral distance to that object (Figure 4).

If the swarm is within a specified attack range from the player:


     - Each bunny treats its neighbors as obstacles and attempts to avoid them.

     - If the bunny encounters obstacles, try to separate from the swarm in order to get a less obstacle-ridden path.

     - Otherwise, flock while steering towards the player.

 

Bunny Melting

    The bunny melting effect is handled through use of a vertex shader. Vertex shaders operate on all vertices passed down the graphics pipeline and take over the job of transformations and lighting. By returning a modified vertex position, a melting effect can be obtained. For a more realistic effect, the position is modified using the sine function operating on the x and z coordinates of the vertices. Combining this value with the inverse of the bunnies' health creates a smooth melt which reflects overall damage to the bunny. In addition, a sine function modifies the x and z coordinates of the vertices once the y coordinate is below a lower threshold to create a 'pooling' effect.

Figure 2: Various stages of bunny melt


 

Flamethrower Particle System

Figure 3: Description of Flamethrower effect


 

View Frustrum Culling


There's no reason to make the computer perform lighting calculations on objects that the player can't see. View Frustum Culling (VFC) is the process of removing objects outside the camera's field of vision from the rendering path, to speed up performance. In the "Original Scene", there are objects that are out of the player's view.

Each object is checked against the four planes that define the viewing volume. If it's on the opposite side of every plane, we know for sure that it's hidden from the player's view. In the "Frustum Plane Test", green objects are objects that are within the view frustum and should therefore be drawn. Red objects are not drawn, as they are out of the player's view.

Once all of these hidden objects are removed, the scene can be rendered more efficiently without impacting what the player sees. This is shown in the final picture, "Scene after VFC".

Figure 4: Description of View Frustrum Culling


 

World Level of Detail


    Level of detail for the terrain is handled through recursive comparison of quad-tree nodes against a distance metric. If the node of the quad-tree is greater than a certain distance from the player, it is labeled as a leaf. All terrain located within a leaf of the quad-tree is rendered using a level dependent resolution. Thus, if a leaf is located one-level deep in the quad-tree, the associated terrain is far from the player and can be rendered at a lower resolution, whereas leaves at max depth are closest to the player and should be rendered at maximum detail. This implementation increases the frame rate by reducing the amount of quad-tree traversal required as well as the resolution of terrain objects far away.

Figure 5: Wireframe box showing level of detail


 

Sounds


    Sounds are handled through the audio API, OpenAL which provides a simple buffer allocation scheme for storing sound sources as well as functions for playing and stopping those sources. Sound effects currently in the game are the following:

     - Flamethrower

     - Player footsteps

     - Bunny attack sounds

     - Player and Bunny defeat sounds


 

References:

Particle Systems:

	Wikipedia
	Neon Helium Tutorial

World Level of Detail:

	World Wind Wiki
	Patent Storm

Vertex Shaders:

	Examples from Cg Toolkit
	 

Artificial Intelligence:

	Flocking as a Concurrency Problem
	Steering Behaviors For Autonomous Characters
	Siggraph 97
	Potential Fields

MD2 Loader:

	Duke's MD2 Loader