Assesment Task.doc Dean Rather’s
DODGEBALL
G a m e p r o d u c t i o n f i l e
3 | Log Book |
6 | Structure Chart |
7 | Data Dictionary |
12 | Gantt Chart |
14 | Code Fragment One |
17 | Code Fragment Two |
19 | Code Fragment Three |
20 | Instillation Guide |
21 | User Tutorial |
Log Book
Chronicling of the creation of Dodgeball. From Week 1 through 10.
Week 1) Planning
This week I designed a basic layout for my game to follow, as demonstrated in the Structure Chart.
I also decided what style of game it would be, and some important game elements I will implement.
It will be a ‘dodgeball’ style game, the twist is, you control the player with the mouse. This game will require a constant 60 FPS to keep the player under the mouse at all times.
Pretty much; there’s a lot of balls bouncing around and you need to keep your player from getting hit.
Balls start off few, and over time more and more appear.
The ball’s are of random caliber, their size dictates their speed.
Power-ups are available; one to give you an overshield, one to slow down the enemies, one to make you invincible for a short time, and perhaps even one to set off a little EMP that destroys any enemies within a short radius.
At this stage the game is planned to be ‘infinate’ in that you cannot win; the goal is to live the longest and make the highest time. To ‘win’ would be to live longer than whoever’s made the previous record.
I have decided to build this game with the C++’s SDL (simple direct-media library) library, as it is extremely fast, and should allow me the speed nescicary.
I am currently setting up my C++ compiler to work with the SDL library.
Week 2) Setting up.
This week I set up SDL, created the graphics for my game, and began importing images into the SDL framework of C++.
I’ve got a window up and running, with images, and transparency, and images allocated at corresponding X and Y variables. I’ve begun setting up a class for the ball instances, and I’m currently re-organizing my code to make it easier to work with. I will soon begin getting a frame rate happening, so I can animate the game.
Week 3) Classes, Vectors, Arrays, Instances, input, animation and GameStates.
This week I set various game states (game, menu, credits, learn) come to think of it I should add ‘paused’. I set up a timer (60 FPS) by which the entire game code is limited, I then set the cursor’s image to correspond with gamestate (it’s a cursor in the menu and a man when your playing). I then created a class “Buttons” containing X, Y, W, and H variables, and instantiated the quit and play buttons. I set up the getUI fn to read mouse clicks, and adapted the menu() fn to quit if you click the close button, or go to the game if you click the play button. I also made gamestates transition smoothly between menu and the game, (ESC takes you from the game to the menu).
I then created a ball instance, and instantiated three upon setup of the game. They have random start positions (within the game’s arena), and random directions and speeds. This random aspect, at the current time, has some faults, as I just implemented it late last period. Due to setting up the timer, animation now works… decently. I’m not sure wether I’m passing data around with pointers correctly though, as the game does run slower and less consistently than I had hoped. This might also be of fault to the timer, but I’m not sure.
I don’t yet have any means of printing text or outputting textual data, so troubleshooting is currently very difficult.
Week 4) Physics
This week I implemented Physics, making each individual ball bounce off the arena boundaries accurately. I also adjusted the ball’s random positioning and direction so they appear in more random positions and move in a more random movement. (They used to be running along permanent 45 degree angles, now it is constantly between about 46 and 70.) I have begun implementing Pythagoras’s theorem of the length of a hypotenuse to find distance from the ball’s to the main character. I’ve also begun implementing music
Week 5) Alternative Sound Library
I didn’t like the SDL_Mixer library as I didn’t have the option to pause MIDI files (Like the one I’m using as the background music) So I did some research, found that an extremely professional sound library FMOD, was free to use for any game that wasn’t being sold. So I downloaded, installed, and learnt to use it, and got it working pretty well.
FMOD is also the sound library used for some professional games, such as World of Warcraft. But since then I’ve decided against using it, and I am going to revert back to SDL_Mixer.
I have begun writing a data dictionary to record all of my variables.
Week 6) Completion of data dictionary, beginning to clean up files
There were far too many lines in the one main.cpp file (over 1200) so I decided if I were to break it up into separate .cpp files, for each major part of the code (global variable declreations, video functions, maths functions, misc functions etc.)
I also finished the data dictionary, there were about 150 variables at the time. I will keep the dictionary updated as I continue programming of my game.
I have a deadline of Tuesday next week to have a functional demo ready for some people.
Week 7) Demo Preperation
I spent a lot of time this week preparing the game to be displayed as a playable demo. It went along without too many problems, I got some basics like a primitive 3-hit lives system happening.
I didn’t do much else this week as I was preoccupied with other work, although I did learn how to read and write to notepad files, which I may use to make my own Scoreboard, which has, all along, been my plan for completion of this game. (IE to win, you beat the highest score).
Week 8) Score saving system
I spent pretty much the whole week working on a program (which was to be a set of functions to use in my game) which opens a notepad file, reads the high scores from it, and saves new high scores over it. I got a lot of it working, but in it’s current stage, it’s far too buggy to implement into the game.
Week 9) Fixing some things
A lot of work needs to be done since implementing the game over thing. Bugs are popping up everywhere, and I have stopped actually making progress on the project to go back and iron out a couple bugs. Needing to split up the code into lots of other files is looking like a very important thing to do.
Week 10) Still fixing things
I’ve fixed the music, I’m working on the game over thing, and I’m just about to cut this code up once and for all, I was having troubles messing around with it before, but I’ve got a proper tutorial on it right now and will abide by this for instruction.
Structure Chart
The following structure chart, created on day 1, outlines the basis of structure I planned
my game functions and operations about.
Data Dictionary
The following data dictionary outlines all pieces of data in my project at time of writing. It has the data type, for example numbers (integer) words (string) or yes/no (Boolean).
It also contains what they are initiated to (granted their not initiated to some complex calculation; which some of them are.)
Globals | |||
Name | Type | Description | Initialised to |
WINDOW_WIDTH | Constant Integer | Width of the window (pixels) | 800 |
WINDOW_HEIGHT | Constant Integer | Height of the window (pixels) | 600 |
WINDOW_DEPTH | Constant Integer | Bit Depth of the window | 32 |
FPS | Constant Integer | Max Frames Per Second of the game (refresh rate) | 30 |
FRAME_RATE | Constant Integer | miliseconds (second/1000) per frame | 1000/FPS |
BALLD | Constant Integer | Diameter of the ball | 30 |
CURSORD | Constant Integer | Cursor Diameter | 64 |
ARENAX | Constant Integer | game arena top-left X coord | 46 |
ARENAY | Constant Integer | game arena top-left Y coord | 53 |
ARENAW | Constant Integer | game arena width | 583 |
ARENAH | Constant Integer | game arena height | 522 |
RBARX | Constant Integer | Right bar X coord | 665 |
RBARY | Constant Integer | Right bar Y coord | 17 |
RBARW | Constant Integer | right bar width | 787-RBARX |
RBARH | Constant Integer | right bar height | 585-RBARY |
MAXSPEED | Constant Integer | maximum speed a ball may move (pixels/frame) | 9 |
MINSPEED | Constant Integer | minium speed a ball may move (pixels/frame) | 7 |
MANW | Constant Integer | mans width | 36 |
MANH | Constant Integer | mans height | 54 |
FONTSIZE | Constant Integer | font's size | 20 |
GRIMFRAMES | Constant Integer | frames in the grimace 3d clip | 19 |
STARTBALLS | Constant Integer | amount of balls at the start | 5 |
NEWBALLDELAY | Constant Integer | delay between ball creation | 3 |
FULLSCREEN | Constant Boolean | wether the game is to be run in fullscreen | FALSE |
MENU | Constant Integer | a variable name to reference a game state | 1 |
GAME | Constant Integer | a variable name to reference a game state | 2 |
LEARN | Constant Integer | a variable name to reference a game state | 3 |
CREDITS | Constant Integer | a variable name to reference a game state | 4 |
QUIT | Constant Integer | a variable name to reference a game state | 5 |
STATE | Integer | The varable used to refer to the game states. | MENU |
mouseX | Integer | Mouse's X coord | 0 |
mouseY | Integer | Mouse's Y coord | 0 |
origTime | Integer | original system time in ms (second/1000) | 0 |
Timer | Integer | ms since orig time | 0 |
LastUpdate | Integer | time in ms the screen most recently refreshed | 0 |
GrimaceFrame | Integer | frame grimace 3d film is currently at | 0 |
Seconds | Integer | Seconds since the game started (timer*1000) | 0 |
GameSeconds | Integer | Seconds of unpaused gameplay | 0 |
OldFrames | Integer | number of frames rendered in the previous second | 0 |
Frames | Integer | current frame being rendered this second | 0 |
Hit | Integer | number of times the man has been hit | 0 |
lastBallSpawn | Integer | When the last ball was spawned (in seconds) | 0 |
middleness | Integer | how close the player is to the middle | 0 |
score | Integer | players score | 0 |
Balls | Integer | number of balls currently onscreen | 0 |
isRunning | Boolean | if the current state is running | TRUE |
paused | Boolean | if the game is paused | FALSE |
keyUp | Boolean | if the "up" key is being held down | FALSE |
keyDown | Boolean | if the "down" key is being held down | FALSE |
keyLeft | Boolean | if the "left" key is being held down | FALSE |
keyRight | Boolean | if the "right" key is being held down | FALSE |
keyReturn | Boolean | if the "return" key is being held down | FALSE |
keySpace | Boolean | if the "space" key is being held down | FALSE |
keyM | Boolean | if the "m" key is being held down | FALSE |
keyEsc | Boolean | if the "esc" key is being held down | FALSE |
mouseDown | Boolean | if the mouse button is being held down | FALSE |
slowBalls | Boolean | if the slowBalls state is active | FALSE |
toggler | Boolean | a variable to help toggle booleans | FALSE |
musicOn | Boolean | if the music is on | FALSE |
mute | Boolean | if the music is muted | FALSE |
imageNames[] | Constant String Array | Names of game images | |
imageCount | Constant Integer | Number of game images | # of images |
soundNames[] | Constant String Array | Names of game sounds | |
soundCount | Constant Integer | Number of game sounds | # of sounds |
Class Variables - "Man" Class | |||
Name | Type | Description | Initialised to |
Global | |||
visible | Boolean | if the man is to be rendered this frame | TRUE |
invulnerable | Boolean | if the man should detect collisions with enemies | FALSE |
health | Integer | How much health the man has | 3 |
invulStart | Integer | Time at which invulnerablility began (in Game Seconds) | 0 |
invulTimer | Integer | Time the man has been invulnerable for (in seconds) | 0 |
slow | Integer | Time that slow can be called for | 5 |
inverters | Integer | Number of inverters left | 3 |
emp | Integer | number of EMP charges left | 3 |
Class Variables - "Ball" Class | |||
Name | Type | Description | Initialised to |
Global | |||
X | Integer | X Position | Random |
Y | Integer | Y Position | Random |
S | Integer | Speed | Random |
T | Integer | Time at which it was created (In game seconds) | GameSeconds |
dx | Integer | X Direction (Horz) | Random |
dy | Integer | Y Direction (Vert) | Random |
flashing | Boolean | if the ball should be flashing | TRUE |
visible | Boolean | if the ball should be rendered this frame | FALSE |
beenHit | Boolean | if the ball has been hit | FALSE |
Ball() | |||
tolerance | Integer | how inaccurately the about() fn can make the ball's direction | 70 |
moveBall() | |||
tdx | Integer | Temporary horz direction | dx |
tdy | Integer | Temporary vert direction | dy |
tX | Integer | Temporary X coord | X + tdx |
tY | Integer | Temporary Y coord | Y + tdy |
Class Variables - "Button" Class | |||
Name | Type | Description | Initialised to |
Global | |||
x | Integer | X Coord | |
y | Integer | Y Coord | |
w | Integer | Width | |
h | Integer | Height | |
Function - beginSDL() | |||
Name | Type | Description | Initialised to |
r | Integer | Red value used when referencing transparent colour | 255 |
g | Integer | Green value used when referencing transparent colour | 0 |
b | Integer | Blue value used when referencing transparent colour | 255 |
Function - drawImage(SDL_Surface *img, SDL_Surface *dest, int x, int y) | |||
Name | Type | Description | Initialised to |
x | Integer | X coord to draw image to | |
y | Integer | Y coord to draw image to | |
Function - DisplayText(string text, int x, int y) | |||
Name | Type | Description | Initialised to |
text | String | Text to be written to screen | |
x | Integer | X coord to write it to | |
y | Integer | Y coord to write it to | |
Function - Random(int X, int Y) | |||
Name | Type | Description | Initialised to |
X | Integer | minimum random result | |
Y | Integer | maximum random result | |
Function - outOfBounds(int x, int y) | |||
Name | Type | Description | Initialised to |
x | Integer | X coord to check if out of bounds of arena | |
y | Integer | Y coord to check if out of bounds of arena | |
Function - wordNum(int num) | |||
Name | Type | Description | Initialised to |
num | Integer | number to be returned as a string | |
origNum | Constant Integer | original number passed to function | |
sSign | String | Sign of number (Positive or Negative) | |
sNumber | String | Final Number | |
sHundred | String | Hundreds | |
sThousand | String | Thousands | |
sMillion | String | Millions | |
sBillion | String | Billions | |
saNums[10] | String Array | Array of written numbers zero - nine | |
saTens[8] | String Array | Array of written tens, Twenty - Ninety | |
Function - updateScore() | |||
Name | Type | Description | Initialised to |
oldScore | Integer | original score (before increasing it) | score |
newScore | Double | new score | |
tempHit | Integer | temporary number of hits | Hit |
fraction | Double | a fraction used in calculating the score | |
Function - printDetails() | |||
Name | Type | Description | Initialised to |
H | Constant Integer | gap between X coords of each written line | |
N | Integer | Number of lines written | 0 |