3. Chapter 1
Game Design
1.1
Level
The level consists basically of 3 models: the level itself and 2 additional models to add more
details to the world.
There is a special class which can be called upon that can determine from a Vector3 input
if that point is above the level model and can determine the height of the level model at a given
point. This is used to keep all moving units on top of the level.
1.2
HUD
There are a few 2D elements that make up the interface of the game.
1.2.1
Action Keys
The Action Keys show the player what the squad is doing. If the buttons light up it means
that that part of the squad is busy attacking some enemies. The circle displays the amount of
squad units of that type that are still alive.
1.2.2
Pointer
The pointer is a texture of which the position can be controlled with the right analogue stick
of the Xbox controller or with the mouse. When it comes across something in the world, the
object reacts to it. A ray is shot into the world from the pointer’s position and the unit in the
world that detects it reacts to it.
1.2.3
Squad
We have four models that are loaded to a certain type of squad unit. Each type has it’s own
gun after which the type is called. The types are: Machinegunner, Rocketlauncher, Grenadier
and Shotgunner.
The Machinegunner fires a lot of bullets. The Rocketlauncher shoots rockets at enemies
which explode at the point where the enemy was when the rocket was fired. The Grenadier
throws grenades at the enemy. Like a rocket the grenade will explode at the point where the
enemy unit was when the grenade was thrown. Grenadiers and Rocketlaunchers are thereby
not that effective against fast enemies. The Shotgunner will shoot bullets at a lower rate than
the Machinegunner, but these bullets have a greater impact than the bullets from the machine
gun.
2
4. 1.2.4
Enemies
There are four different types of enemies that move across the surface of the level. They attack
the squad when in they are within a certain range and follow them around the level. The four
different types of enemies have a certain weakness for the different types in the squad. They
are placed in groups that can be attacked by the squad unit types and are spawned from spawn
points.
1.3
Movement
The movement of the squad is defined by a single point that travels on the height map. The
squad units stay in their own group and those groups try to stay near the squad point.
The movement of the squad is handled by the left stick of the Xbox controller or by the
WASD-keys.
1.4
Camera
When the squad moves forward, the camera stays a little behind and seems to look forward.
When moving backwards, the camera is pushed backwards and looks at the ground where the
squad is moving to. The movement of the camera is smoothed by a spring so it glides from
position to position.
The camera will turn with you, so if you move to the left the camera will follow behind you.
But moving the squad is not the only way to turn the camera. When you move the pointer
(with the right poke on the controller or with the mouse) to the sides of the screen, the camera
will turn in proportions to that distance. When the pointer is in the upper part of the screen,
the camera will move a little bit backwards and looks a little bit more up so that it gives a
better overview of the level.
3
5. Chapter 2
Game Requirements
In this chapter we will elaborate on the implementation of the general and choosen extra requirements.
2.1
General Requirements
These are the requirements that have to be met by the final product.
2.1.1
3D environment
Our game takes place in a 3D environment where the camera focus lies on a spot in the middle
of the squad (or where the squad needs to go).
2.1.2
Reward and Punishment system
The player progresses by surviving and destroying the enemy. By doing this, the player completes the stages.
As of the arcade part of the game, the player earns points by destroying enemies. The
number of squad units alive will act as a kind of multiplier. So if you survive everything while
maintaining a high number of squad members your score will be higher than if you survive with
less.1 .
2.1.3
Level of difficulty
The level of difficulty increases when you progress in the level. You start with a small squad
with only one type (Shotgunner) with one type of enemies that has a weakness for Shotgunner
and only one spawnpoint from which they spawn. When you have destroyed that spawnpoint
you’ll advance to the next stage. Two spawnpoints will be added where two different types of
enemies will spawn. The player now learns that the Shotgunner is not that capable against
the other kind of enemy and needs help. He’ll find that in a tube that can be destroyed which
frees some trapped squad members. Now he will have the firepower to destroy the other type
of enemies more easily.
Every time you manage to destroy all the current spawning points you’ll advance to a next
stage where more spawnpoints will be added with more enemies and there will be some more
tubes that you can shoot to get more squad members. By adding more and better/faster/harder/stronger
enemies the stage will become more difficult to survive and complete.
1
Section 2.4.1, Game Design Document [1]
4
6. 2.1.4
Audio
Audio is played for actions like exploding bombs and gunfire. There are some ambient sounds
like falling water drops.
The soundtrack is dynamically build from drum, bass and guitar tracks. Together they
make up the soundtrack by choosing the more mellow parts when the game is not that intense
and choosing the more heavy parts when there is action. The volume will also adjust to reflect
the game play.
When you’ll lose squad members the drums lose volume and are send through a reverb so
that it sounds more hollow.
2.1.5
Game state framework
The game can be paused so that an interface is shown where you can quit or resume the game,
view the controls and a section where you can configure some options like the volume of the
soundtrack.
2.2
Graphics
These requirements are about the graphical features that have to be implemented. We decided
to put in particles and special custom shaders, because they can add a lot to the game experience
and sound cool.
2.2.1
Particles
We want to make use of particles to make explosions look awesome and to give the user feedback
about what happens. There are explosions with smoke and there are particles that represent
the damage done to enemies. Those particles fly off the enemies on the other side of where they
have been hit.
2.2.2
Special Custom Shaders
Since we have animations in the game, we had to use the matrix palette shader that came with
the animation library. But the models looked flat and rough since this shader doesn’t use any
form of lighting or advanced texture sampling. So we had to rewrite it to create out own custom
shader.
The texture sampling was added by describing that the sampler should use linear smoothing.
We added support for one ambient light and three point lights to the shader, as well as a
parameter to set specular power. The ambient light is defined by only one color, while a point
light is defined by a combination of color, position, falloff and range. The lighting factor for
each point light is then created by taking the dot product of the pixel normal with the negative
light direction, raise that to the specular power, and then taking falloff and range into account.
To give an illusion of shadows in the level we added a masking technique, that used the 4
separate channels of a texture (that should be as large as the level) as a mask for the different
lights. We used the RGB channels as mask for the point lights and the alpha channel as mask
for the ambient light. This way we can darken our animated models in caves, or in the shadow
of a static object. Note that the different channels are not the colors: each channel is just a
value from zero to one that is then multiplied by the already calculated light effect.
5
7. We added fog support in our custom animation shader as well. This way all animated models
start out blended with the surroundings in the distance, and will be more visible as they are
finding their way to your squad!
The shader also handles highlight support. This highlights the model of an enemy as the
player moves the pointer over that enemy, or any other enemy in the same group. This way the
player can easily see which target he is telling his squad units to attack.
2.3
Artificial Intelligence
These requirements are about the Artificial Intelligence that will control certain objects in the
game. We chose Character, Group and Automatic Object Control, because those are all needed
to implement the game play the way it was designed.
2.3.1
Character Control
Squad Movements We chose character control because we want to move our squad in a
’fuzzy’ way. The player doesn’t control the units directly. The specifc movement of the units
need to be controlled by the system.
While squad moves, it is the responsibility of every unit not to fall behind. When squad stops,
main positions are calculated using group control, yet individual units would keep readjusting
their positions themselves.
Enemy Movements Normally the movement of an enemy is indirectly controlled by the
group that it belongs to (see below). Yet when an enemy spots a squad member in its active
range, it takes control of its own movements and starts following the squad instead of its own
group. In case it looses the squad, it returns to its group again. Just a little disappointed.
Enemy Targeting After an enemy group is selected the character decides itself which particular enemy will he attack to. Each unit will be more likely to shoot the enemies standing
closest to itself. Yet the enemy needs to be in the selected enemy group.
2.3.2
Group Control
Spawning The game has a spawn manager which manages the spawning of new enemies
from dynamic spawn points. This manager works using fuzzy logic to spawn a enemy group.
By looking at the active enemies and number of enemies in the world the spawn manager
decides, which spawning point to use, how many enemies to put in a group, what sort enemies
to spawn.
Spawn managers duties are extended to keep track of different game stages, making the
game more and more difficult.
Yet the spawn manager is not all that evil. It also spawns squad members when necessary.
When a pod is destroyed by the squad spawn manager checks the squad status to decide which
sort of unit the squad needs most, and than spawns it on the squad position.
Squad Movements Characters will be controlled by moving an invisible point across the
surface of the heightmap. Taking that invisible point as a center, for every type unit a main
position will be calculated with that types ranking as radius and a randomly generated angle.
All individual units will choose a place close to their types main position. Once a main
position is set for a unit type it is up to that type units to be organized around that point.
6
8. 2.3.3
Path Finding
Although the general movement of the squad is considered to be the users responsibility, the
movement of the enemy groups are handled by each enemy group. Each enemy (If they do not
have the squad in their active range) patrols around the an invisible group center.
The group center uses a bread first search algorithm to find the squad in increasing number
of steps. When a valid path is found, the group center starts moving towards the squad. Not
to leave any fellow members behind, the group center moves in a relatively slow rate.
Enemies During the game play different sorts of enemies will be spawned to keep the user
challenged. By each stage of the game, with new spawning points, there comes new types of
enemies.
The attributes of enemies are selected considering their appearance, their role in game, the
attributes of the squad unit that is coupled with it. (For example if an enemy has a long range
it is not coupled with a squad unit which has short range).
A manta ray as an example; is quite a big creature. Being big, it is slow with a low range
yet it inflicts high amount of damage since in the beginning of the game, it is the only enemy
sort to be spawned.
The attributes of the other enemies can be seen in table 2.1.
Enemies:
Manta Ray
Bug
Bee
Boomer
Table 2.1: Attributes of enemies
Attributes:
Range
Speed Damage
Short
Low
High
Average Average Average
Short
High
Low
Long
Average
Low
New Squad Types
New Enemy Types
Nr of Spawn points
Nr of Possible Enemies
Table 2.2: Stages of the game
Stage 1
Stage 2
Stage 3
Machinegunner Shotgunner Grenadier
Manta ray
Bug
Bee
1
2
3
50
75
100
Stage 4
Rocketlauncher
Boomer
3
200
Game Stages Table 2.2 shows how the game progresses between stages. As the game shifts
from one level to another, the spawn manager spawns new sort of enemies and pods. Those
pods can be used to get new squad members.
7
9. Chapter 3
Class Diagram
World and Viewer
The virtual world is a Component3DContainer and contains Component3D’s. Because Component3DContainer inherits from a Component3D he can reside in a Component3DContainer.
A simple application would be a tree as container, filled with leaves as components. The position, rotation and scale of the leaves are relative to the parent container, so if the tree would
move (!) the leaves would stay with the tree.
To display the virtual world we have a Viewer that has a Camera. The Camera has a
reference to the world so that is knows its position in the virtual world.
The Game calls the update method of the world and the world calls the update method to
all his childs recursively. The Game calls the draw method of the Viewer so that he can draw
the world.
Figure 3.1: Class Diagram of the units
Squad and Enemies All actors in the world belong to groups. The squad moves as one
group and acts in different groups. Enemies should move and attack as groups. The group is
8
10. defined by UnitGroup. All actors (Units) have one group to which they belong. The position of
the squad and the position of the units relative to the squad position are handled by the squad
manager.
Just as the squad units are generally controlled by the squad manager, so are the movements
of the enemies controlled by the enemy group managers.
9