Dependencies:
el14hzbm_Final_Project
mbed
« Back to documentation index
main.cpp File Reference
Program implementation.
More...
Go to the source code of this file.
Functions
void intro ()
Introduction Page.
void firstView ()
FirstView.
void gameView ()
GameView.
void optionView ()
Option.
void instructionView ()
Intruction Page.
void brightnessView ()
Brightness View.
void finishView (int g_score )
Finish View.
void SleepView ()
Sleep View.
void crash (int carValue [], int opponent_y, int g_score , int g_level , int k, int l, int delay )
Crash.
void game_interface (int g_score , int g_level , int g_liveleft )
Game Interface.
void playermovement (int g_level )
Player Movement.
void checkLastCar (int g_level )
Last Traffic Car.
void finishLevel (int g_level )
Level Finish.
void initialGameInterface ()
Initialise game display.
void initGameVar ()
Initiate Game Variable.
void firstViewPointer ()
FirstViewPointer.
void optionPointer ()
Pointer Controller.
void brightnessController ()
Brightness Controller.
void initArray ()
Initiate Music Array.
void tone (float frequency, float duration )
Tone.
void gameplaysound (float duration )
Gameplay Music.
void crashsound ()
Crash Music.
void pausesound ()
Pause Music.
void finishsound ()
Finish Music.
void live (int liveleft)
LifeLeft.
void roadline (int moving)
Road Display.
void score (int m, int my)
Score Text.
void level (int x1, int y1)
Level Text.
void button_isr ()
Button Interrupt.
Detailed Description
Program implementation.
Definition in file main.cpp .
Function Documentation
void brightnessController
(
)
Brightness Controller.
function to control the lcd brightness.
Definition at line 589 of file main.cpp .
Brightness View.
function to display the brightnees controller screen.
Definition at line 283 of file main.cpp .
Button Interrupt.
Use for interrupt. It will change the flag to one.
Definition at line 811 of file main.cpp .
void checkLastCar
(
int
g_level )
Last Traffic Car.
Function to check where is the last car to stop the loop at different level.
Parameters:
g_level - check where is the last car at certain level to stop the level loop and proceed to next level.
Definition at line 501 of file main.cpp .
void crash
(
int
carValue [],
int
opponent_y ,
int
g_score ,
int
g_level ,
int
k ,
int
l ,
int
delay
)
Crash.
Check if there are crash occur between the player and the traffic car. Store the pixel of player's car and pixel of trafic's car and check if they overlap each other.
Parameters:
carValue[] - consist array of value for position of traffic's car (which column).
opponent_y - the position of array's car (which row).
g_score - display the score value of the game.
g_level - display current level of the gameplay.
k - read the position of player's car (x-direction).
l - read the position of player's car (y-direction).
delay - create delay for the next car to enter the screen at different time.
Definition at line 371 of file main.cpp .
Crash Music.
function to provide sound when crash occur.
Definition at line 654 of file main.cpp .
void finishLevel
(
int
g_level )
Level Finish.
Function to display a message when a level is completed.
Parameters:
g_level - Write a text where a certain level is completed.
Definition at line 512 of file main.cpp .
Finish Music.
function to provide sound when the game finished.
Definition at line 686 of file main.cpp .
void finishView
(
int
g_score )
Finish View.
Function to display the end screen when the game is finally over.
Parameters:
g_score - display the final score at the end of the game.
Definition at line 321 of file main.cpp .
FirstView.
Function to provide main menu screen of the game.
Definition at line 55 of file main.cpp .
void firstViewPointer
(
)
FirstViewPointer.
Function to control the pointer in main menu screen.
Definition at line 565 of file main.cpp .
void game_interface
(
int
g_score ,
int
g_level ,
int
g_liveleft
)
Game Interface.
Display the text use during gameplay. (eg. Score, Level).
Parameters:
g_score - display the score value of the game.
g_level - display current level of the gameplay.
g_liveleft - display how many life left in the gameplay.
Definition at line 455 of file main.cpp .
void gameplaysound
(
float
duration )
Gameplay Music.
function to play sound during gameplay.
Parameters:
duration - play the note at duration equal to speed of the car.
Definition at line 640 of file main.cpp .
GameView.
The main part of the game coding is in here. Contain all the complex part for the game. Use array to store the traffic's car before displaying them into the screen.
Definition at line 103 of file main.cpp .
Initiate Music Array.
function to initialise sample array for music (sound) purpose.
Definition at line 603 of file main.cpp .
Initiate Game Variable.
function to initialize back all game variable used for new game.
Definition at line 555 of file main.cpp .
void initialGameInterface
(
)
Initialise game display.
Initialise display with game interface when the user enter the game. Show the background display of the game screen. Also contain countdown timer before the game start.
Definition at line 527 of file main.cpp .
Intruction Page.
function to provide game manual for the player.
Definition at line 217 of file main.cpp .
Introduction Page.
Function to display introduction page when power is turn on.
Definition at line 34 of file main.cpp .
void level
(
int
x1 ,
int
y1
)
Level Text.
function to display level text in screen.
Parameters:
x1 - locate the x-coordinate of the text
y1 - locate the y-coordinate of the text
Definition at line 790 of file main.cpp .
void live
(
int
liveleft )
LifeLeft.
Function to draw how many life left in game.
Parameters:
g_liveleft - display how many life left in the gameplay.
Definition at line 702 of file main.cpp .
Pointer Controller.
Function to control pointer in option menu.
Definition at line 575 of file main.cpp .
Option.
Function to display the option menu at the beginning.
Definition at line 171 of file main.cpp .
Pause Music.
function to provide sound when the gmae is paused.
Definition at line 670 of file main.cpp .
void playermovement
(
int
g_level )
Player Movement.
Function to control the movement of the player's car.
Parameters:
g_level - provide different speed for the player's car at different level.
Definition at line 470 of file main.cpp .
void roadline
(
int
moving )
Road Display.
Display the text use during gameplay. (eg. Score, Level) Function to display the road line in the game.
Parameters:
moving - use to make the road look as it is moving.
Definition at line 708 of file main.cpp .
void score
(
int
m ,
int
my
)
Score Text.
function to display score text in screen.
Parameters:
m - locate the x-coordinate of the text
my - locate the y-coordinate of the text
Definition at line 732 of file main.cpp .
Sleep View.
Function to generate sleep mode to save energy & power. Also include lcd off to switch of the lcd. Improve power effciency for the game system Expand the battery lifetime.
Definition at line 354 of file main.cpp .
void tone
(
float
frequency ,
float
duration
)
Tone.
function to play a tone of set frequency for given duration
Parameters:
frequency - frequency that the tone is being played.
duration - time duration for a note to be played
Definition at line 612 of file main.cpp .