Mbed project for a FRDM-K64F microcontroller. Game made out of five sub-games including flappy birds, snake, stack, trivia and space invaders.

Dependencies:   mbed

Fork of The_Children_of_Cronos_el15mggr by ELEC2645 (2016/17)

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers game.h Source File

game.h

Go to the documentation of this file.
00001 #include "mbed.h"
00002 #include "N5110.h"
00003 #include "Bitmap.h"
00004 #include "Gamepad.h"
00005 #include "hydralib.h"
00006 #include "Stymphalianlib.h"
00007 #include "aurigaslib.h"
00008 #include "cerinealib.h"
00009 #include "taurolib.h"
00010 #include "array.h"
00011 
00012 
00013 /** Selector */
00014 struct State {
00015     int position;     /**< position */
00016     int nextstate[2];/**< next state */
00017 };
00018 
00019 /**
00020 @file game.h
00021 @brief Header file for the function prototyps and variables of the main game file
00022 @author Mateo Randulfe
00023 @date May 2017
00024 */
00025 
00026 /**
00027 * x button connection
00028 * @param x
00029 */
00030 DigitalOut  x (PTC17);
00031 /**
00032 * y button connection
00033 * @param y
00034 */
00035 DigitalOut  y (PTC12);
00036 /**
00037 * a button connection
00038 * @param a
00039 */
00040 DigitalOut  a (PTB9);
00041 /**
00042 * b button connection
00043 * @param b
00044 */
00045 DigitalOut  b (PTD0);
00046 /**
00047 * l button connection
00048 * @param l
00049 */
00050 DigitalOut  l (PTB18);
00051 /**
00052 * r button connection
00053 * @param r
00054 */
00055 DigitalOut  r (PTB3);
00056 /**
00057 * start button connection
00058 * @param start
00059 */
00060 DigitalOut  start (PTC5);
00061 /**
00062 * back button connection
00063 * @param back
00064 */
00065 DigitalOut back(PTB19);
00066 /**
00067 * lcd objct for interacting with the screen library
00068 * @param lcd
00069 */
00070 
00071 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
00072 /**
00073 * gamepad objct for interacting with the gamepad library
00074 * @param pad
00075 */
00076 Gamepad pad;
00077 /**
00078 * hydralib objct for interacting with the first game library(the snake)
00079 * @param hyd
00080 */
00081 hydralib hyd;
00082 /**
00083 * Stymphalianlib objct for interacting with the second game library(space invaders)
00084 * @param stym
00085 */
00086 Stymphalianlib stym;
00087 /**
00088 * aurigaslib objct for interacting with the third game library(flappy birds)
00089 * @param aurig
00090 */
00091 aurigaslib aurig;
00092 /**
00093 * cerinealib objct for interacting with the fourth game library(stack)
00094 * @param cer
00095 */
00096 cerinealib cer;
00097 /**
00098 * taurolib objct for interacting with the fith game library(quesions and answers)
00099 * @param tau
00100 */
00101 taurolib tau;
00102 
00103 /**
00104 * ticker object for switching on progressively the lights in the intro
00105 */
00106 Ticker introlights;
00107 /**
00108 * ticker object for moving the aliens each second in th space invaders game
00109 */
00110 Ticker alienmove;
00111 
00112 /**
00113 * initialises all the objects like gamepad and lcd
00114 * it also performs h init function of all the games
00115 */
00116 void init();
00117 /**
00118 * brief intro with the game name in a fancy way using bitmaps
00119 */
00120 void intro();
00121 /**
00122 * switchs on progressivly the lights in the intro screen
00123 */
00124 void lights();
00125 /**
00126 * displays the different games selector screen and allows to switch between them
00127 */
00128 void game();
00129 /**
00130 * function that allows to select the five different games in an up down selector using a sructure
00131 */
00132 void select();
00133 /**
00134 * executes the screen where the player can select the option he wants like tutoria,story of the game,the games screen or the scores
00135 */
00136 void menuscreen();
00137 /**
00138 * function that allows to select the different menu options the player have
00139 */
00140 void menuselect();
00141 /**
00142 * draws the screen that selects beween the five different games(which is inside itself of the menuselct screen
00143 */
00144 void drawselectmenu();
00145 /**
00146 * draws the screen that selects beween opions in the menu
00147 */
00148 void drawselectscreen();
00149 
00150 /** selects between different games */
00151 void selected();
00152 /**
00153 * displays the tutorial screen and the selecor of it.The player can choose to read the instructions of the different levels
00154 */
00155 void tutorial();
00156 /**
00157 * displays the game sory screen and the selecor of it.The player can scrolls to keep reading the story.
00158 */
00159 void story();
00160 /**
00161 * displays the highest scores
00162 */
00163 void highscores();
00164 /**
00165 * saves the score if pressed and if its bigger than the thid position
00166 */
00167 void savescore();
00168 
00169 /** performs the aliens movement */
00170 void aliens();
00171 /**
00172 * executes the screen where the player can select the game he wants
00173 */
00174 void newgame();
00175 /**
00176 * function that assemblies the first game
00177 */
00178 void gameone();
00179 
00180 //if false the game is not running i true it will be running
00181 bool game1=false;
00182 /**
00183 * function that assemblies the second game
00184 */
00185 void gametwo();
00186 // if false the game is not running i true it will be running
00187 bool game2=false;
00188 /**
00189 * function that assemblies the third game
00190 */
00191 void gamethree();
00192 //if false the game is not running i true it will be running
00193 bool game3=false;
00194 /**
00195 * function that assemblies the fourth game
00196 */
00197 void gamefour();
00198 // if false the game is not running i true it will be running
00199 bool game4=false;
00200 /**
00201 * function that assemblies the fith game
00202 */
00203 void gamefive();
00204 // if false the game is not running i true it will be running
00205 bool game5=false;
00206 // if false the menu screen will not be displayed if true it will
00207 bool menuselection=true;
00208 // if false the games selector screen will not be displayed if true it will
00209 bool selection=true;
00210 // if false the tutorial screen will not be displayed if true it will
00211 bool tut=false;
00212 // if false the story screen will not be displayed if true it will
00213 bool stor=false;
00214 // if false the highscore screen will not be displayed if true it will
00215 bool highscr=false;
00216 // if false the save screen will not be displayed if true it will
00217 bool savescr=false;
00218 
00219 
00220 /** structure array for the different games*/
00221 State games[5]= {
00222     {0,{4,1}},
00223     {1,{0,2}},
00224     {2,{1,3}},
00225     {3,{2,4}},
00226     {4,{3,0}}
00227 };
00228 /** structure array for the different menu options*/
00229 State menu[4]= {
00230     {0,{3,1}},
00231     {1,{0,2}},
00232     {2,{1,3}},
00233     {3,{2,0}}
00234 };
00235 /** structure array for the tutorial options*/
00236 State tuto[5]= {
00237     {0,{4,1}},
00238     {1,{0,2}},
00239     {2,{1,3}},
00240     {3,{2,4}},
00241     {4,{3,0}}
00242 };
00243 
00244 //arrays for displaying scores
00245 char buffer0[20];
00246 char buffer1[20];
00247 char buffer2[20];
00248 char buffer3[20];
00249 char buffer4[20];
00250 char buffer5[20];
00251 
00252 int statetutorial=0;
00253 int outpututorial=0;
00254 
00255 int statemenu=0;
00256 int outputmenu=0;
00257 
00258 
00259 int statestory=0;
00260 int outputstory=0;
00261 
00262 int state=0;
00263 int output=0;
00264 
00265 //???
00266 int lit=0;
00267 //??
00268 int k=1;
00269 
00270 int totalscore;
00271 //different scores for the games
00272 int scoreg1, scoreg2,scoreg3,scoreg4,scoreg5;
00273 
00274 #define NOTE_B0  31
00275 #define NOTE_C1  33
00276 #define NOTE_CS1 35
00277 #define NOTE_D1  37
00278 #define NOTE_DS1 39
00279 #define NOTE_E1  41
00280 #define NOTE_F1  44
00281 #define NOTE_FS1 46
00282 #define NOTE_G1  49
00283 #define NOTE_GS1 52
00284 #define NOTE_A1  55
00285 #define NOTE_AS1 58
00286 #define NOTE_B1  62
00287 #define NOTE_C2  65
00288 #define NOTE_CS2 69
00289 #define NOTE_D2  73
00290 #define NOTE_DS2 78
00291 #define NOTE_E2  82
00292 #define NOTE_F2  87
00293 #define NOTE_FS2 93
00294 #define NOTE_G2  98
00295 #define NOTE_GS2 104
00296 #define NOTE_A2  110
00297 #define NOTE_AS2 117
00298 #define NOTE_B2  123
00299 #define NOTE_C3  131
00300 #define NOTE_CS3 139
00301 #define NOTE_D3  147
00302 #define NOTE_DS3 156
00303 #define NOTE_E3  165
00304 #define NOTE_F3  175
00305 #define NOTE_FS3 185
00306 #define NOTE_G3  196
00307 #define NOTE_GS3 208
00308 #define NOTE_A3  220
00309 #define NOTE_AS3 233
00310 #define NOTE_B3  247
00311 #define NOTE_C4  262
00312 #define NOTE_CS4 277
00313 #define NOTE_D4  294
00314 #define NOTE_DS4 311
00315 #define NOTE_E4  330
00316 #define NOTE_F4  349
00317 #define NOTE_FS4 370
00318 #define NOTE_G4  392
00319 #define NOTE_GS4 415
00320 #define NOTE_A4  440
00321 #define NOTE_AS4 466
00322 #define NOTE_B4  494
00323 #define NOTE_C5  523
00324 #define NOTE_CS5 554
00325 #define NOTE_D5  587
00326 #define NOTE_DS5 622
00327 #define NOTE_E5  659
00328 #define NOTE_F5  698
00329 #define NOTE_FS5 740
00330 #define NOTE_G5  784
00331 #define NOTE_GS5 831
00332 #define NOTE_A5  880
00333 #define NOTE_AS5 932
00334 #define NOTE_B5  988
00335 #define NOTE_C6  1047
00336 #define NOTE_CS6 1109
00337 #define NOTE_D6  1175
00338 #define NOTE_DS6 1245
00339 #define NOTE_E6  1319
00340 #define NOTE_F6  1397
00341 #define NOTE_FS6 1480
00342 #define NOTE_G6  1568
00343 #define NOTE_GS6 1661
00344 #define NOTE_A6  1760
00345 #define NOTE_AS6 1865
00346 #define NOTE_B6  1976
00347 #define NOTE_C7  2093
00348 #define NOTE_CS7 2217
00349 #define NOTE_D7  2349
00350