The final(?) edition of el14jbed's ELEC2645 project
Dependencies: N5110 SDFileSystem mbed
Jacob Markl 200852678
Revision 0:cba7494d5dff, committed 2016-05-05
- Comitter:
- horizontalwolf
- Date:
- Thu May 05 13:33:38 2016 +0000
- Commit message:
- Final(?) version of ELEC2645 project
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Arrays.h Thu May 05 13:33:38 2016 +0000 @@ -0,0 +1,483 @@ +/** +@file Arrays.h +@brief The header file containing the global arrays and sprites. +@brief Revision 9.9. +@author Jacob Markl +@date May 2016 +*/ +#ifndef Arrays_H +#define Arrays_H + +struct State { + int mapno; /*!< map number for current state */ + int next_state[4]; /*!< next state (depending on direction up,right,down,left) */ + int mobcode; /*!< identifyer for what arangement of mobs appear on the map */ + int cleared; /*!< 0 if not clear, 1 if cleared */ +}; +typedef struct State STyp; + +STyp fsm[8] = { + {1,{0,1,0,0},0,1}, + {2,{1,1,2,0},1,0}, + {3,{1,3,2,2},2,0}, + {4,{3,4,3,2},3,0}, + {5,{5,4,6,3},0,1}, + {6,{5,5,4,5},4,0}, + {7,{4,7,6,6},5,0}, + {8,{7,7,7,6},6,0} +};/*!< the FSM for the first level */ +/* level 2 map + [9][10][11] +[1][4][5] [13][8] + [7][10][12] + + +*/ + + +STyp lvl2fsm[11] = { + {1,{0,1,0,0},0,1}, //0 + {4,{1,2,1,0},3,0}, //1 + {5,{4,2,3,1},0,1}, //2 + {7,{2,6,3,3},5,0}, //3 + {9,{4,5,2,4},7,0}, //4 + {10,{5,7,5,4},8,0}, //5 + {10,{6,8,6,3},8,0}, //6 + {11,{7,7,9,5},9,0}, //7 + {12,{9,8,8,6},10,0},//8 + {13,{7,10,8,9},11,0},//9 + {8,{10,10,10,9},6,0}//10 +};/*!< The FSM for the second level */ + +STyp cfsm[11]; + +int const g_menuscreen[15][84] = { +// 0 1 2 3 4 5 6 7 8 +// 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5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,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,1,0,0,1,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,1,0,1,1,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,1,0,0,0,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,0,1,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,1,1,1,1,0,0,0,0,1,0,0,0,1,0,1,0,0,0,0,0,1,0,0,0,1,0,1,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,1,1,1,0,0,1,0,0,0,0,0,0,1,1,1,0,0,0,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,0,0,0}, + {0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0},//48 + +};/*!< intro screen array */ + + +//##################### MAPS #################### + +/* level 1 map + +12 6 + 345 + 78 + +*/ + +/* level 2 map + [9][10][11] +[1][4][5] [13][8] + [7][10][12] + + +*/ + +// for maps rock = 1,exit = 2, , doorup = 4, doorright = 5, doordown = 6, doorleft = 7 + +int const g_map_1[8][8]= { + {1,1,1,1,1,1,1,1}, + {1,0,0,0,0,0,0,1}, + {1,0,0,0,0,0,0,1}, + {1,0,0,0,0,0,0,1}, + {1,0,0,0,0,0,0,5}, + {1,0,0,0,0,0,0,1}, + {1,0,0,0,0,0,0,1}, + {1,1,1,1,1,1,1,1}, +};/*!< 1st map array*/ + +int const g_map_2[8][8]= { + {1,1,1,1,1,1,1,1}, + {1,0,0,0,0,0,0,1}, + {1,0,1,1,0,1,0,1}, + {1,0,1,1,0,0,0,1}, + {7,0,1,1,1,0,0,1}, + {1,1,1,1,1,0,0,1}, + {1,1,1,0,0,0,0,1}, + {1,1,1,6,1,1,1,1}, +};/*!< 2nd map array */ + +int const g_map_3[8][8]= { + {1,1,1,4,1,1,1,1}, + {1,0,0,0,1,1,0,1}, + {1,0,0,1,1,0,1,1}, + {1,0,1,1,0,1,1,1}, + {1,0,1,1,1,1,0,5}, + {1,0,0,0,0,0,0,1}, + {1,0,0,0,0,0,0,1}, + {1,1,1,1,1,1,1,1}, +};/*!< 3rd map array */ + +int const g_map_4[8][8]= { + {1,1,1,1,1,1,1,1}, + {1,0,0,0,0,0,0,1}, + {1,0,1,0,1,0,0,1}, + {1,0,1,0,1,1,1,1}, + {7,0,1,0,1,1,0,5}, + {1,1,1,0,1,0,0,1}, + {1,0,0,0,0,0,0,1}, + {1,1,1,1,1,1,1,1}, +};/*!< 4th map array */ + +int const g_map_5[8][8]= { + {1,1,1,4,1,1,1,1}, + {1,1,1,0,1,1,1,1}, + {1,1,1,0,1,1,1,1}, + {1,1,1,0,1,1,1,1}, + {7,0,0,0,1,1,1,1}, + {1,1,1,0,1,1,1,1}, + {1,1,1,0,1,1,1,1}, + {1,1,1,6,1,1,1,1}, +};/*!< 5th map array */ + +int const g_map_6[8][8]= { + {1,1,1,1,1,1,1,1}, + {1,0,0,0,0,0,0,1}, + {1,0,0,0,0,0,0,1}, + {1,0,0,0,0,0,0,1}, + {1,0,0,0,0,0,0,1}, + {1,0,1,1,1,1,0,1}, + {1,0,0,0,0,0,0,1}, + {1,1,1,6,1,1,1,1}, +};/*!< 6th map array */ + +int const g_map_7[8][8]= { + {1,1,1,4,1,1,1,1}, + {1,0,0,0,1,0,0,1}, + {1,0,1,1,1,0,0,1}, + {1,0,1,0,0,0,0,1}, + {1,0,0,0,1,1,0,5}, + {1,0,0,0,1,1,1,1}, + {1,0,0,0,1,1,1,1}, + {1,1,1,1,1,1,1,1}, +};/*!< 7th map array */ +int const g_map_8[8][8]= { + {1,1,1,1,1,1,1,1}, + {1,0,0,0,0,0,0,1}, + {1,0,0,0,0,0,0,1}, + {1,0,0,0,0,0,0,1}, + {7,0,0,0,0,0,0,2}, + {1,0,0,0,0,0,0,1}, + {1,0,0,0,0,0,0,1}, + {1,1,1,1,1,1,1,1}, +};/*!< 8th map array */ + + + +int const g_map_9[8][8]= { + {1,1,1,1,1,1,1,1}, + {1,0,0,0,0,0,0,1}, + {1,0,0,1,0,1,0,1}, + {1,1,0,1,0,1,1,1}, + {1,0,0,1,0,0,0,5}, + {1,0,1,1,1,1,1,1}, + {1,0,0,0,1,0,0,1}, + {1,1,1,6,1,1,1,1}, +};/*!< 9th map array */ + +int const g_map_10[8][8]= { + {1,1,1,1,1,1,1,1}, + {1,0,0,0,1,1,1,1}, + {1,0,1,0,1,1,1,1}, + {1,0,1,0,1,1,1,1}, + {7,0,1,0,1,0,0,5}, + {1,0,1,0,1,0,1,1}, + {1,0,0,0,0,0,1,1}, + {1,1,1,1,1,1,1,1}, +};/*!< 10th map array */ + +int const g_map_11[8][8]= { + {1,1,1,1,1,1,1,1}, + {1,0,0,0,0,0,0,1}, + {1,0,1,0,0,1,0,1}, + {1,0,0,0,0,0,0,1}, + {7,0,0,0,0,0,0,1}, + {1,0,1,0,0,1,0,1}, + {1,0,0,0,0,0,0,1}, + {1,1,1,6,1,1,1,1}, +};/*!< 11th map array */ + +int const g_map_12[8][8]= { + {1,1,1,4,1,1,1,1}, + {1,1,1,0,0,0,0,1}, + {1,1,1,1,1,1,0,1}, + {1,0,1,0,0,1,0,1}, + {7,0,1,0,0,1,0,1}, + {1,0,1,0,0,1,0,1}, + {1,0,0,0,0,0,0,1}, + {1,1,1,1,1,1,1,1}, +};/*!< 12th map array */ + +int const g_map_13[8][8]= { + {1,1,1,4,1,1,1,1}, + {1,1,1,0,0,0,0,1}, + {1,1,1,0,0,1,0,1}, + {1,1,1,1,1,1,0,1}, + {1,1,1,1,1,1,0,5}, + {1,0,1,0,0,1,0,1}, + {1,0,0,0,0,0,0,1}, + {1,1,1,6,1,1,1,1}, +};/*!< 13th map array */ + + + +//########### SPRITES ############ + +int const g_player[6][6] = { + {0,0,0,0,0,0}, + {0,0,1,1,1,1}, + {0,1,1,0,0,0}, + {0,1,1,0,1,0}, + {0,0,1,1,1,0}, + {0,0,0,0,1,0} +};/*!< player sprite array */ + +int const g_playerA[6][6] = { + {0,0,0,0,1,1}, + {0,0,1,1,0,0}, + {0,1,1,0,0,0}, + {0,1,1,0,1,0}, + {0,0,1,1,1,0}, + {0,0,0,0,1,0} +};/*!< player attack sprite array */ + +//########## ITEMS/THING ########### +int const g_rock[6][6] = { + {0,0,1,1,0,0}, + {0,1,0,0,1,0}, + {0,1,1,0,1,0}, + {1,0,0,1,0,1}, + {1,0,0,1,1,1}, + {1,1,1,1,1,1} +};/*!< rock sprite array */ + +int const g_heart[6][6] = { + {0,1,0,0,1,0}, + {1,0,1,1,0,1}, + {1,0,0,0,0,1}, + {1,0,0,0,0,1}, + {0,1,0,0,1,0}, + {0,0,1,1,0,0} +};/*!< heart sprite array */ + +int const g_door[6][6] = { + {0,1,1,1,1,0}, + {1,0,1,1,0,1}, + {1,0,1,1,0,1}, + {1,0,0,0,1,1}, + {1,0,0,0,0,1}, + {1,1,1,1,1,1} +};/*!< door sprite array */ + +int const g_exit[6][6] = { + {1,1,1,1,1,1}, + {1,1,0,0,1,1}, + {0,1,1,1,1,0}, + {0,1,0,0,1,0}, + {0,1,1,1,1,0}, + {0,1,0,0,1,0} +};/*!< exit sprite array */ + +int const g_sword[6][6] = { + {1,0,0,0,0,0}, + {0,1,1,1,0,0}, + {0,1,1,0,0,0}, + {0,1,0,1,0,0}, + {0,0,0,0,1,0}, + {0,0,0,0,0,1} +};/*!< sword sprite array */ +//############## HOSTILES ################## +struct move { + int nextstate; + int nextx; + int nexty; + int facing; + +}; + +int const g_rat[6][6] = { + {0,0,0,0,0,0}, + {0,0,1,1,0,1}, + {0,1,1,1,1,0}, + {1,0,1,1,0,1}, + {1,0,0,0,0,0}, + {0,1,1,0,0,0} +};/*!< rat sprite array */ +typedef const struct move RSTyp; + +RSTyp const ratfsm[8] = { + {1,1,0,1}, + {2,1,0,1}, + {3,0,1,2}, + {4,0,1,2}, + {5,-1,0,3}, + {6,-1,0,3}, + {7,0,-1,4}, + {0,0,-1,4} +};/*!< The FSM for the rat */ + +int const g_frog[6][6] = { + {0,0,0,0,0,1}, + {1,1,0,0,1,0}, + {0,1,1,1,1,1}, + {0,1,1,1,1,1}, + {1,1,0,0,1,0}, + {0,0,0,0,0,1} +};/*!< frog sprite array */ + +typedef const struct move FSTyp; + +FSTyp frogfsm[10] = { + {1,1,0,1}, + {2,1,0,1}, + {3,1,0,1}, + {4,1,0,1}, + {5,1,0,1}, + {6,-1,0,1}, + {7,-1,0,3}, + {8,-1,0,3}, + {9,-1,0,3}, + {0,-1,0,3} + +};/*!< The FSM for the frog */ + +int const g_crab[6][6] = { + {1,0,0,1,1,0}, + {1,0,1,1,0,1}, + {0,1,1,0,0,0}, + {0,1,1,0,0,0}, + {1,0,1,1,0,1}, + {1,0,0,1,1,0} +};/*!< crab sprite array */ + +typedef const struct move CSTyp; + +CSTyp crabfsm[2] = { + {1,1,0,1}, + {0,-1,0,3} +};/*!< The FSM for the Crab */ + +int const g_shroom[6][6] = { + {0,0,1,1,0,0}, + {0,1,0,0,1,0}, + {1,0,0,1,0,1}, + {1,1,0,0,1,1}, + {0,1,1,1,1,0}, + {1,1,0,0,1,1} +};/*!< shroom sprite array*/ + +typedef const struct move SSTyp; + +SSTyp shroomfsm[4] = { + {1,0,1,1}, + {2,0,1,1}, + {3,0,-1,1}, + {0,0,-1,1} +};/*!< The FSM for the shroom */ + +int const g_boss[6][6] = { + {0,1,1,1,1,0}, + {1,0,0,1,0,1}, + {1,1,1,0,0,1}, + {1,0,0,0,0,1}, + {1,1,1,1,1,0}, + {0,1,0,1,0,1} +}; /*!< boss sprite array*/ + +typedef const struct move BSTyp; + +BSTyp bossfsm[23] = { + {1,1,1,1}, + {2,1,1,1}, + {3,1,-1,1}, + {4,1,-1,1}, + {5,-1,-1,2}, + {6,-1,-1,2}, + {7,-1,1,2}, + {8,-1,1,2}, + {9,2,0,1}, + {10,0,-2,1}, + {11,-2,0,2}, + {12,0,2,2}, + {13,2,0,1}, + {14,0,2,2}, + {15,-2,0,2}, + {16,0,-2,1}, + {17,0,-1,2}, + {18,1,0,1}, + {19,0,1,2}, + {0,-1,0,1}, +};/*!< The FSM for the Boss */ +#endif +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Main.cpp Thu May 05 13:33:38 2016 +0000 @@ -0,0 +1,1371 @@ +/* +ELEC2645 Project Jacob Markl 200852678 + +Week 19 - Tested display, started writing arrays + +Week 20 - More arrays, started writing map builders + +Week 21 - nothing, did PCB + +Sometime During Easter - reworked some bits, More Sprites, Map builder, Map writer, started on player builder and player movement + +Week 22 - Reworked player builder and movement. added map interaction + +Week 23 - added mobs, music, saving highscores, reading music from the sd card, added a tutorial, added settings, fixed up some bits and bobs. + +Week 24 - rounded off all parts of the code, expanded game slightly. +*/ +#include "mbed.h" +#include "N5110.h" +#include "Arrays.h" +#include "Variables.h" +#include "Mobs.h" +#include "Tickersandmore.h" +#include "SDcard.h" +#include <vector> + + + +void init_K64F(); +void BUI_isr(); +void BRI_isr(); +void BDI_isr(); +void BLI_isr(); +void BAI_isr(); +void BBI_isr(); +void map_builder(int mapnumber); +void player_builder(); +void screen_builder(); +void player_movement(); +void Attack(); +void stats(); +void timer1_isr(); +void timer2_isr(); +void buttons(); +void init_game(); +void outidle(); +void win(); +void lose(); +void main_menu(); +void game(); +void settings(); +void addtopscore(); +void highscores(); +void tutorial(); +void timeoutsound(); +void startscreen(); +void drawlines(); +void level2screen(); + +//###################### CODE ##################### + +int main() +{ + while(1) { + init_K64F(); + lcd.init(); + startscreen(); + main_menu(); + } +} + + +void init_K64F() +{ + BUI.fall(&BUI_isr); + BUI.mode(PullDown); + BRI.fall(&BRI_isr); + BRI.mode(PullDown); + BDI.fall(&BDI_isr); + BDI.mode(PullDown); + BLI.fall(&BLI_isr); + BLI.mode(PullDown); + BAI.fall(&BAI_isr); + BAI.mode(PullDown); + BBI.fall(&BBI_isr); + BBI.mode(PullDown); + + g_BUI_flag = 0; + g_BRI_flag = 0; + g_BDI_flag = 0; + g_BLI_flag = 0; + g_BAI_flag = 0; + g_BBI_flag = 0; + g_timer1_flag = 0; + g_timer2_flag = 0; + +} + + +void BUI_isr() +{ + g_BUI_flag = 1; // set flag in ISR +} + +void BRI_isr() +{ + g_BRI_flag = 1; // set flag in ISR +} + +void BDI_isr() +{ + g_BDI_flag = 1; // set flag in ISR +} + +void BLI_isr() +{ + g_BLI_flag = 1; // set flag in ISR +} + +void BAI_isr() +{ + g_BAI_flag = 1; // set flag in ISR +} + +void BBI_isr() +{ + g_BBI_flag = 1; // set flag in ISR +} + +void map_builder(int mapnumber) +{ + int mapx = 0; + int mapy = 0; + int spritex = 0; + int spritey = 0; + + switch(mapnumber) { + case 1: + for(int x = 0; x < 8; x++) { + for (int y = 0; y < 8 ; y++) { + g_layout[x][y] = g_map_1[x][y]; + } + } + break; + case 2: + for(int x = 0; x < 8; x++) { + for (int y = 0; y < 8 ; y++) { + g_layout[x][y] = g_map_2[x][y]; + } + } + break; + case 3: + for(int x = 0; x < 8; x++) { + for (int y = 0; y < 8 ; y++) { + g_layout[x][y] = g_map_3[x][y]; + } + } + break; + case 4: + for(int x = 0; x < 8; x++) { + for (int y = 0; y < 8 ; y++) { + g_layout[x][y] = g_map_4[x][y]; + } + } + break; + case 5: + for(int x = 0; x < 8; x++) { + for (int y = 0; y < 8 ; y++) { + g_layout[x][y] = g_map_5[x][y]; + } + } + break; + case 6: + for(int x = 0; x < 8; x++) { + for (int y = 0; y < 8 ; y++) { + g_layout[x][y] = g_map_6[x][y]; + } + } + break; + case 7: + for(int x = 0; x < 8; x++) { + for (int y = 0; y < 8 ; y++) { + g_layout[x][y] = g_map_7[x][y]; + } + } + break; + case 8: + for(int x = 0; x < 8; x++) { + for (int y = 0; y < 8 ; y++) { + g_layout[x][y] = g_map_8[x][y]; + } + } + break; + case 9: + for(int x = 0; x < 8; x++) { + for (int y = 0; y < 8 ; y++) { + g_layout[x][y] = g_map_9[x][y]; + } + } + break; + case 10: + for(int x = 0; x < 8; x++) { + for (int y = 0; y < 8 ; y++) { + g_layout[x][y] = g_map_10[x][y]; + } + } + break; + case 11: + for(int x = 0; x < 8; x++) { + for (int y = 0; y < 8 ; y++) { + g_layout[x][y] = g_map_11[x][y]; + } + } + break; + case 12: + for(int x = 0; x < 8; x++) { + for (int y = 0; y < 8 ; y++) { + g_layout[x][y] = g_map_12[x][y]; + } + } + break; + case 13: + for(int x = 0; x < 8; x++) { + for (int y = 0; y < 8 ; y++) { + g_layout[x][y] = g_map_13[x][y]; + } + } + break; + default: + for(int x = 0; x < 8; x++) { + for (int y = 0; y < 8 ; y++) { + g_layout[x][y] = g_map_1[x][y]; + } + } + break; + } + + for(int x = 0 ; x < 8; x++) { + mapy = 0; + for ( int y = 0; y < 8 ; y++) { + switch(g_layout[x][y]) { + case 0: + for(spritex = 0; spritex < 6; spritex++) { + for (spritey = 0; spritey < 6 ; spritey++) { + g_screen[mapy+spritey][mapx+spritex] = 0; + } + } + + break; + case 1: + for(spritex = 0; spritex < 6; spritex++) { + for (spritey = 0; spritey < 6 ; spritey++) { + g_screen[mapy+spritey][mapx+spritex] = g_rock[spritex][spritey]; + } + } + break; + case 2: + for(spritex = 0; spritex < 6; spritex++) { + for (spritey = 0; spritey < 6 ; spritey++) { + g_screen[mapy+spritey][mapx+spritex] = 2+g_exit[spritex][spritey]; + } + } + + break; + case 4: + for(spritex = 0; spritex < 6; spritex++) { + for (spritey = 0; spritey < 6 ; spritey++) { + g_screen[mapy+spritey][mapx+spritex] = 4+g_door[spritex][spritey]; + } + } + + break; + case 5: + for(spritex = 0; spritex < 6; spritex++) { + for (spritey = 0; spritey < 6 ; spritey++) { + g_screen[mapy+spritey][mapx+spritex] = 6+g_door[spritex][spritey]; + } + } + break; + case 6: + for(spritex = 0; spritex < 6; spritex++) { + for (spritey = 0; spritey < 6 ; spritey++) { + g_screen[mapy+spritey][mapx+spritex] = 8+g_door[spritex][spritey]; + } + } + break; + case 7: + for(spritex = 0; spritex < 6; spritex++) { + for (spritey = 0; spritey < 6 ; spritey++) { + g_screen[mapy+spritey][mapx+spritex] = 10+g_door[spritex][spritey]; + } + } + break; + } + mapy = mapy + 6; + } + mapx = mapx + 6; + } + +} + +void screen_builder() +{ + for( int x = 0; x < 48; x++) { + for (int y = 0; y < 48 ; y++) { + if (((g_screen[x][y])%2)==0) { + lcd.clearPixel(x,y); + } else { + lcd.setPixel(x,y); + } + } + } +} + +void player_builder() +{ + int mapx = g_playerlocationy*6; + int mapy = g_playerlocationx*6; + int csprite[6][6]; + int player[6][6]; + if (g_playersprite == true) { + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + csprite[x][y] = g_playerA[x][y]; + } + } + } else { + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + csprite[x][y] = g_player[x][y]; + } + } + } + switch (g_playerfacing) { + case 0: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + player[x][y] = csprite[y][5-x]; + } + } + + break; + + case 1: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + player[x][y] = csprite[x][y]; + } + } + break; + + case 2: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + player[x][y] = csprite[5-y][x]; + } + } + + break; + case 3: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + player[x][y] = csprite[5-x][5-y]; + } + } + break; + + } + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + g_screen[mapy+y][mapx+x] = 12+player[x][y]; + + } + } +} + +void player_movement() +{ + bool stop = false; + switch(g_playerdirection) { + case 0: + g_playerfacing = 0; + for(int y = 0; y < 6; y++) { + if ((g_playerlocationy-1 == g_mobs[y][2])and(g_playerlocationx== g_mobs[y][1])) { + stop=true; + } + } + if (g_layout[g_playerlocationy-1][g_playerlocationx]==4) { + if (cfsm[g_state].cleared==1) { + g_playerlocationx=3; + g_playerlocationy=6; + g_state = cfsm[g_state].next_state[0]; + mobs(); + } + } else if (stop==true ) { + } else if (g_layout[g_playerlocationy-1][g_playerlocationx]==2) { + if (cfsm[g_state].cleared==1) { + g_playerlocationx=3; + g_playerlocationy=6; + g_gamewon = true; + } + } else if (g_layout[g_playerlocationy-1][g_playerlocationx]!=1) { + g_playerlocationy--; + } + break; + + case 1: + g_playerfacing = 1; + for(int y = 0; + y < 6; + y++) { + if ((g_playerlocationy == g_mobs[y][2])and(g_playerlocationx+1== g_mobs[y][1])) { + stop=true; + } + } + if (g_layout[g_playerlocationy][g_playerlocationx+1]==5) { + if (cfsm[g_state].cleared==1) { + g_playerlocationx=1; + g_playerlocationy=4; + g_state = cfsm[g_state].next_state[1]; + mobs(); + } + } else if (stop==true ) { + } else if (g_layout[g_playerlocationy][g_playerlocationx+1]==2) { + if (cfsm[g_state].cleared==1) { + g_playerlocationx=1; + g_playerlocationy=4; + g_gamewon = true; + } + } else if (g_layout[g_playerlocationy][g_playerlocationx+1]!=1) { + g_playerlocationx++; + } + + break; + + case 2: + g_playerfacing = 2; + for(int y = 0; y < 6; y++) { + if ((g_playerlocationy+1 == g_mobs[y][2])and(g_playerlocationx== g_mobs[y][1])) { + stop=true; + } + } + if (g_layout[g_playerlocationy+1][g_playerlocationx]==6) { + if (cfsm[g_state].cleared==1) { + g_playerlocationx=3; + g_playerlocationy=1; + g_state = cfsm[g_state].next_state[2]; + mobs(); + } + } else if (stop==true ) { + } else if (g_layout[g_playerlocationy+1][g_playerlocationx]==2) { + if (cfsm[g_state].cleared==1) { + g_gamewon = true; + g_playerlocationx=3; + g_playerlocationy=1; + } + } else if (g_layout[g_playerlocationy+1][g_playerlocationx]!=1) { + g_playerlocationy++; + } + + break; + + case 3: + g_playerfacing = 3; + for(int y = 0; y < 6; y++) { + if ((g_playerlocationy == g_mobs[y][2])and(g_playerlocationx-1== g_mobs[y][1])) { + stop=true; + } + } + if (g_layout[g_playerlocationy][g_playerlocationx-1]==7) { + if (cfsm[g_state].cleared==1) { + g_playerlocationx=6; + g_playerlocationy=4; + g_state = cfsm[g_state].next_state[3]; + mobs(); + } + } else if (stop==true ) { + } else if (g_layout[g_playerlocationy][g_playerlocationx-1]==2) { + if (cfsm[g_state].cleared==1) { + g_gamewon = true; + g_playerlocationx=6; + g_playerlocationy=4; + } + } else if (g_layout[g_playerlocationy][g_playerlocationx-1]!=1) { + g_playerlocationx--; + } + + + break; + + case 4: + break; + } +} + +void Attack() +{ + g_playersprite= true; + switch(g_playerfacing) { + + case 0: + for(int y = 0; y < 5; y++) { + if ((g_playerlocationy-1 == g_mobs[y][2])and(g_playerlocationx== g_mobs[y][1])) { + if (g_mobs[y][0] == 6 ) { + g_playerhp++; + } + g_mobs[y][0]=0; + g_mobs[y][1]=0; + g_mobs[y][2]=0; + g_mobs[y][3]=0; + g_score= g_score+10; + } + } + break; + case 1: + for(int y = 0; y < 5; y++) { + if ((g_playerlocationy == g_mobs[y][2])and(g_playerlocationx+1== g_mobs[y][1])) { + if (g_mobs[y][0] == 6 ) { + g_playerhp++; + } + g_mobs[y][0]=0; + g_mobs[y][1]=0; + g_mobs[y][2]=0; + g_mobs[y][3]=0; + g_score= g_score+10; + } + } + break; + case 2: + for(int y = 0; y < 5; y++) { + if ((g_playerlocationy+1 == g_mobs[y][2])and(g_playerlocationx== g_mobs[y][1])) { + if (g_mobs[y][0] == 6 ) { + g_playerhp++; + } + g_mobs[y][0]=0; + g_mobs[y][1]=0; + g_mobs[y][2]=0; + g_mobs[y][3]=0; + g_score= g_score+10; + } + } + break; + case 3: + for(int y = 0; y < 5; y++) { + if ((g_playerlocationy == g_mobs[y][2])and(g_playerlocationx-1== g_mobs[y][1])) { + if (g_mobs[y][0] == 6 ) { + g_playerhp++; + } + g_mobs[y][0]=0; + g_mobs[y][1]=0; + g_mobs[y][2]=0; + g_mobs[y][3]=0; + g_score= g_score+10; + } + } + break; + + } + int clear = 0; + for(int y = 0; y < 5; y++) { + if (g_mobs[y][0]!=0) { + clear++; + } + } + if (clear == 0) { + cfsm[g_state].cleared=1; + } + + +} + +void stats() +{ + int startx = 51; + int starty = 8; + int nx = 0; + int ny = 0; + for(int H = 0; H < g_playerhp; H++) { + for( int x = startx; x < startx+6; x++) { + for (int y = starty; y < starty+6 ; y++) { + if (((g_heart[ny][nx])%2)==0) { + lcd.clearPixel(x,y); + } else { + lcd.setPixel(x,y); + } + ny++; + } + ny=0; + nx++; + } + nx=0; + startx=startx+6; + } + lcd.printString("Health",48,0); + lcd.printString("Time",54,2); + char buffer[14]; + sprintf(buffer,"%d",g_playtime); + + int newx=63; + if (g_playtime>9) { + newx= 60; + } + if (g_playtime>99) { + newx= 57; + } + lcd.printString(buffer,newx,3); + +} + +void timer1_isr() +{ + g_timer1_flag++; +} + +void timer2_isr() +{ + g_timer2_flag++; +} + +void buttons() +{ + if (g_BUI_flag == 1) { + g_BUI_flag = 0; + g_playerdirection=0; + idle.detach(); + g_isidle = 0; + } else if (g_BRI_flag == 1) { + g_BRI_flag = 0; + g_playerdirection=1; + idle.detach(); + g_isidle = 0; + } else if (g_BDI_flag == 1) { + g_BDI_flag = 0; + g_playerdirection=2; + idle.detach(); + g_isidle = 0; + } else if (g_BLI_flag == 1) { + g_BLI_flag = 0; + g_playerdirection=3; + idle.detach(); + g_isidle = 0; + } else if (g_BAI_flag == 1) { + g_BAI_flag = 0; + g_playerdirection=4; + idle.detach(); + g_isidle = 0; + Attack(); + } else { + g_playerdirection=4; + } +} + +void init_game() +{ + g_playersprite = false; + g_gamewon = false; + + g_level = 1; + g_score = 0; + g_playerfacing = 0; + g_playerhp=3; + g_playtime=0; + g_direction = 0; + g_playerinvun = 0; + g_playerdirection = 4; + g_playerlocationy = 4; + g_playerlocationx = 2; + g_state = 0; + g_isidle=0; + g_BBI_flag=0; + g_BAI_flag=0; + for(int x = 0; x < 4; x++) { + for (int y = 0; y < 5 ; y++) { + g_mobs[y][x] = 0; + } + } + memcpy(cfsm,fsm,sizeof(cfsm)); + readsong(); + +} + +void win() +{ + int newx=36; + lcd.clear(); + for (int y = 0; y < g_playerhp ; y++) { + g_score=g_score+20; + } + if (g_playtime>250) { + } else { + g_score=g_score+(250-g_playtime); + } + + char buffer[14]; + sprintf(buffer,"%d",g_score); + addtopscore(); + writesd(); + lcd.printString("You Won!",18,1); + lcd.printString("Score",27,2); + if (g_score>99) { + newx= 30; + } + lcd.printString(buffer,newx,3); + lcd.refresh(); + + +} + +void lose() +{ + int newx=36; + lcd.clear(); + char buffer[14]; + sprintf(buffer,"%d",g_score); + lcd.printString("You Died!",15,1); + lcd.printString("Score",27,2); + if (g_score>99) { + newx= 30; + } + lcd.printString(buffer,newx,3); + lcd.printString("Try Again",15,5); + lcd.refresh(); + addtopscore(); + writesd(); +} + +void main_menu() +{ + ticker1.detach(); + lcd.clear(); + g_options = 4; + g_select = 0; + g_BAI_flag = 0; + + while(1) { + lcd.clear(); + for(int x = 0; x < 84; x++) { + for (int y = 0; y < 15 ; y++) { + if (((g_menuscreen[y][x])%2)==0) { + lcd.clearPixel(x,y); + } else { + lcd.setPixel(x,y); + } + } + } + lcd.printString("LoZ",33,0); + lcd.printString("Play",30,2); + lcd.printString("Settings",18,3); + lcd.printString("Tutorial",18,4); + lcd.printString("Highscores",12,5); + if (g_BUI_flag == 1) { + g_BUI_flag = 0; + if (g_select>0) { + g_select--; + } + } else if (g_BDI_flag == 1) { + g_BDI_flag = 0; + if (g_select<g_options-1) { + g_select++; + } + } else { + } + + int nx = 0; + int ny = 0; + + for(int x = 3; x < 9; x++) { + for (int y = (g_select*8)+17; y < ((g_select*8)+23); + y++) { + if (((g_sword[ny][nx])%2)==0) { + lcd.clearPixel(x,y); + } else { + lcd.setPixel(x,y); + } + + ny++; + } + ny=0; + nx++; + + } + nx=0; + lcd.refresh(); + sleep(); + if (g_BAI_flag == 1) { + g_BAI_flag = 0; + wait(0.1); + + switch(g_select) { + case 0: + init_game(); + game(); + break; + + case 1: + settings(); + break; + + case 2: + tutorial(); + break; + + case 3: + highscores(); + break; + + default: + + break; + } + return; + } + } +} + +void game() +{ + int n=1; + ticker1.attach(&timer1_isr,0.5); + ticker2.attach(&timer2_isr,g_musicarray[0]); + while (1) { + + + lcd.clear(); + if (g_playerhp !=0) { + if (g_playerinvun > 0) { + g_playerinvun--; + } + g_playersprite= false; + buttons(); + player_movement(); + map_builder(cfsm[g_state].mapno); + player_builder(); + mobturn(); + screen_builder(); + stats(); + lcd.refresh(); + +//############################ ATTACK ONLY ########### +// if the player has attacked, this section will run and the players attack will be animated. + + if (g_playersprite==true) { + lcd.clear(); + player_builder(); + screen_builder(); + stats(); + lcd.refresh(); + g_playersprite = false; + } +//##################################################### + + + if (g_timer1_flag) { + g_timer1_flag = 0; + g_playtime++; + } + if (g_timer2_flag) { + g_timer2_flag = 0; + if (g_music) { + + tout.attach(&timeoutsound, (g_musicarray[0]/2)); + Buzz.period(1.0/1000); + Buzz.write(0.0); + if (g_musicarray[n]!=0) { + Buzz.period(1/(g_musicarray[n])); + Buzz.write(0.5); + } + + if (n==(g_musicarray.size()-1)) { + n=1; + } else { + n++; + } + + + } + } + if (g_gamewon) { + if (g_level == 1) { + level2screen(); + g_gamewon = 0; + g_level++; + memcpy(cfsm,lvl2fsm,sizeof(cfsm)); + g_state = 0; + } else { + win(); + ticker1.detach(); + ticker2.detach(); + tout.detach(); + idle.detach(); + while(1) { + if (g_BAI_flag==1) { + g_BAI_flag==0; + break; + } + sleep(); + } + return; + } + } + if (g_BBI_flag) { + g_BBI_flag = 0; + lcd.clear(); + lcd.printString("Are you sure",6,0); + lcd.printString("you want to",9,1); + lcd.printString("quit?",27,2); + lcd.printString(" No Yes ",0,5); + lcd.refresh(); + while(1) { + if (g_BAI_flag==1) { + g_BAI_flag=0; + g_playerhp=0; + break; + } else if (g_BBI_flag==1) { + g_BBI_flag=0; + break; + + } + sleep(); + } + } + } else { + lose(); + ticker1.detach(); + ticker2.detach(); + tout.detach(); + idle.detach(); + + while(1) { + if (g_BAI_flag==1) { + g_BAI_flag==0; + break; + } + sleep(); + } + return; + } + if (g_idle_flag) { + g_idle_flag=0; + lose(); + ticker1.detach(); + ticker2.detach(); + tout.detach(); + idle.detach(); + while(1) { + if (g_BAI_flag==1) { + g_BAI_flag==0; + break; + } + sleep(); + } + return; + } + if (g_isidle==0) { + g_isidle=1; + idle.attach(&outidle,100); + } + sleep(); + } +} + +void settings() +{ + lcd.clear(); + g_options = 2; + g_select = 0; + while(1) { + g_BAI_flag = 0; + g_BBI_flag = 0; + lcd.clear(); + lcd.printString("Settings",18,0); + lcd.printString("Music",27,2); + lcd.printString("Reset",27,3); + if (g_BUI_flag == 1) { + g_BUI_flag = 0; + if (g_select>0) { + g_select--; + } + } else if (g_BDI_flag == 1) { + g_BDI_flag = 0; + if (g_select<g_options-1) { + g_select++; + } + } else { + } + + int nx = 0; + int ny = 0; + + for(int x = 3; x < 9; x++) { + for (int y = (g_select*8)+17; y < ((g_select*8)+23); + y++) { + if (((g_sword[ny][nx])%2)==0) { + lcd.clearPixel(x,y); + } else { + lcd.setPixel(x,y); + } + + ny++; + } + ny=0; + nx++; + + } + nx=0; + lcd.refresh(); + sleep(); + if (g_BAI_flag == 1) { + g_BAI_flag = 0; + switch(g_select) { + case 0: + g_music=!g_music; + if (g_music == 1) { + lcd.clear(); + lcd.printString("Music On",18,3); + lcd.refresh(); + wait(1); + } else { + lcd.clear(); + lcd.printString("Music Off",15,3); + lcd.refresh(); + wait(1); + } + + break; + + case 1: + while(1) { + lcd.clear(); + lcd.printString("Are",33,1); + lcd.printString("You",33,2); + lcd.printString("Sure?",27,3); + lcd.printString(" No Yes ",0,5); + lcd.refresh(); + sleep(); + if (g_BAI_flag==1) { + g_BAI_flag=0; + clearsd(); + break; + } else if (g_BBI_flag==1) { + g_BBI_flag=0; + break; + + } + } + + } + break; + + } + if (g_BBI_flag == 1) { + g_BBI_flag =0; + return; + } + } +} + + + +void addtopscore() +{ + for(int i = 0; i <= 2; i++) { + if (g_score>=g_topscores[i]) { + if (i<2) { + if (i==0) { + g_topscores[i+2]=g_topscores[i+1]; + } + g_topscores[i+1]=g_topscores[i]; + } + g_topscores[i]=g_score; + + return; + } + } +} + + +void highscores() +{ + readsd(); + while(1) { + char score1[14]; + char score2[14]; + char score3[14]; + sprintf(score1,"1st %d",g_topscores[0]); + sprintf(score2,"2nd %d",g_topscores[1]); + sprintf(score3,"3rd %d",g_topscores[2]); + lcd.clear(); + lcd.printString("Highscores",12,0); + lcd.printString(score1,21,2); + lcd.printString(score2,21,3); + lcd.printString(score3,21,4); + lcd.printString("back",60,5); + lcd.refresh(); + sleep(); + if (g_BBI_flag==1) { + g_BBI_flag=0; + break; + } + } +} + +void tutorial() +{ + g_BAI_flag = 0; + lcd.clear(); + drawlines(); + lcd.printString("Use the D-pad",3,0); + lcd.printString("to control",12,1); + lcd.printString("Zordo",27,2); + + ticker1.attach(&timer1_isr,0.5); + int startx=39; + int starty=30; + int ny=0; + int nx=0; + int loop=0; + while(1) { + + if (g_timer1_flag == 1) { + g_timer1_flag = 0; + switch(loop) { + + case 0: + for( int x = startx; x < startx+6; x++) { + for (int y = starty; y < starty+6 ; y++) { + if (((g_player[ny][nx])%2)==0) { + lcd.clearPixel(x,y); + } else { + lcd.setPixel(x,y); + } + ny++; + } + ny=0; + nx++; + } + nx=0; + lcd.refresh(); + lcd.drawRect(startx,starty,6,6,2); + loop++; + break; + + case 1: + for( int x = startx; x < startx+6; x++) { + for (int y = starty; y < starty+6 ; y++) { + if (((g_player[5-nx][ny])%2)==0) { + lcd.clearPixel(x,y); + } else { + lcd.setPixel(x,y); + } + ny++; + } + ny=0; + nx++; + } + nx=0; + lcd.refresh(); + lcd.drawRect(startx,starty,6,6,2); + loop++; + break; + + case 2: + for( int x = startx; x < startx+6; x++) { + for (int y = starty; y < starty+6 ; y++) { + if (((g_player[5-ny][5-nx])%2)==0) { + lcd.clearPixel(x,y); + } else { + lcd.setPixel(x,y); + } + ny++; + } + ny=0; + nx++; + } + nx=0; + lcd.refresh(); + lcd.drawRect(startx,starty,6,6,2); + loop++; + break; + + case 3: + for( int x = startx; x < startx+6; x++) { + for (int y = starty; y < starty+6 ; y++) { + if (((g_player[nx][5-ny])%2)==0) { + lcd.clearPixel(x,y); + } else { + lcd.setPixel(x,y); + } + ny++; + } + ny=0; + nx++; + } + nx=0; + lcd.refresh(); + lcd.drawRect(startx,starty,6,6,2); + loop=0; + break; + } + } + sleep(); + if (g_BAI_flag == 1) { + g_BAI_flag = 0; + wait(0.1); + break; + } + } + g_BAI_flag = 0; + lcd.clear(); + drawlines(); + lcd.printString("The A button",6,0); + lcd.printString("will attack",9,1); + lcd.printString("with Zordo's",6,2); + lcd.printString("Sword",27,3); + + startx=39; + starty=36; + loop = 0; + while(1) { + if (g_timer1_flag == 1) { + g_timer1_flag = 0; + switch(loop) { + case 0: + for( int x = startx; x < startx+6; x++) { + for (int y = starty; y < starty+6 ; y++) { + if (((g_player[ny][nx])%2)==0) { + lcd.clearPixel(x,y); + } else { + lcd.setPixel(x,y); + } + ny++; + } + ny=0; + nx++; + } + nx=0; + lcd.refresh(); + lcd.drawRect(startx,starty,6,6,2); + loop++; + break; + + case 1: + for( int x = startx; x < startx+6; x++) { + for (int y = starty; y < starty+6 ; y++) { + if (((g_playerA[ny][nx])%2)==0) { + lcd.clearPixel(x,y); + } else { + lcd.setPixel(x,y); + } + ny++; + } + ny=0; + nx++; + } + nx=0; + lcd.refresh(); + lcd.drawRect(startx,starty,6,6,2); + loop=0; + break; + + } + } + sleep(); + if (g_BAI_flag == 1) { + g_BAI_flag = 0; + wait(0.1); + break; + } + } + lcd.clear(); + drawlines(); + lcd.printString("You must kill",3,0); + lcd.printString("all hostiles",6,1); + lcd.printString("on a map to",9,2); + lcd.printString("go through",12,3); + lcd.printString("the door",18,4); + + startx=39; + starty=41; + while(1) { + for( int x = startx; x < startx+6; x++) { + for (int y = starty; y < starty+6 ; y++) { + if (((g_door[ny][nx])%2)==0) { + lcd.clearPixel(x,y); + } else { + lcd.setPixel(x,y); + } + ny++; + } + ny=0; + nx++; + } + nx=0; + lcd.refresh(); + sleep(); + if (g_BAI_flag == 1) { + g_BAI_flag = 0; + wait(0.1); + break; + } + + } + g_BAI_flag = 0; + lcd.clear(); + lcd.printString("Be Swift,",15,0); + lcd.printString("Be Brave,",15,1); + lcd.printString("Dont Die.",15,2); + lcd.printString("Praise the sun",0,3); + lcd.printString("love from",15,4); + lcd.printString("-Prince Lonk",6,5); + while(1) { + if (g_BAI_flag == 1) { + g_BAI_flag = 0; + wait(0.1); + break; + } + } + ticker1.detach(); +} +void timeoutsound() +{ + Buzz.write(0.0); +} + + +void outidle() +{ + g_idle_flag = 1; +} + +void startscreen() +{ + for( int x = 0; x < 84; x++) { + for (int y = 0; y < 48 ; y++) { + if (((g_LoZ[y][x])%2)==0) { + lcd.clearPixel(x,y); + } else { + lcd.setPixel(x,y); + } + } + } + lcd.refresh(); + wait(2); + +} +void drawlines() +{ + lcd.drawLine(0,0,0,47,1); + lcd.drawLine(1,4,1,43,1); + lcd.drawLine(2,10,2,37,1); + lcd.drawLine(3,17,3,30,1); + lcd.drawLine(83,0,83,47,1); + lcd.drawLine(82,4,82,43,1); + lcd.drawLine(81,10,81,37,1); + lcd.drawLine(80,17,80,30,1); +} + +void level2screen() +{ + while(1) { + lcd.clear(); + lcd.printString("Level 2",21,1); + lcd.printString("Press A",21,4); + lcd.refresh(); + if (g_BAI_flag) { + g_BAI_flag = 0; + break; + } + sleep(); + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Main.h Thu May 05 13:33:38 2016 +0000 @@ -0,0 +1,144 @@ +/** +@file Main.h +@brief The header file containing the main functions for the game. +@brief Revision 9.9. +@author Jacob Markl +@date May 2016 +*/ +#ifndef MAIN_H +#define MAIN_H + +#include "mbed.h" +#include "N5110.h" +#include <vector> + + + + +/** +Initialises the mbed and peripherals +*/ +void init_K64F(); + +/** +Toggles the Up button flag +*/ +void BUI_isr(); +/** +Toggles the Right button flag +*/ +void BRI_isr(); +/** +Toggles the Down button flag +*/ +void BDI_isr(); +/** +Toggles the Left button flag +*/ +void BLI_isr(); +/** +Toggles the A button flag +*/ +void BAI_isr(); +/** +Toggles the B button flag +*/ +void BBI_isr(); +/** +Selects the current layout and bulids the map for the game, with the sprites for each point +@param mapnumber - the current mapnumber, passed from the game function +@returns a filled g_screen array +*/ +void map_builder(int mapnumber); +/** +Bulids the current player sprite for the game and draws it on g_screen +*/ +void player_builder(); +/** +Draws the screen onto the lcd. Loops through g_screen and sets each pixel +*/ +void screen_builder(); +/** +changes the next location and direction of the player sprite based on the inputs from the player +*/ +void player_movement(); +/** +calls the attack animation and checks for the mobs in the attacked space +*/ +void Attack(); +/** +calculates and displays the stats on the side of the screen +*/ +void stats(); +/** +toggles the timer1 flag +*/ +void timer1_isr(); +/** +toggles the timer 2 flag +*/ +void timer2_isr(); +/** +checks each button flag for the next movement or action +*/ +void buttons(); +/** +initializes the game variables +*/ +void init_game(); +/** +raises the isidle flag when triggered +*/ +void outidle(); +/** +shows the win screen and calls the score saving function +*/ +void win(); +/** +show the lose screen and calls the score saving function +*/ +void lose(); +/** +displays the main menu and controls the inputs for it +*/ +void main_menu(); +/** +displays the game screen and stats, runs untill the win or lose screen is called +*/ +void game(); +/** +displays the settings menu and controls the inputs for it +*/ +void settings(); + +/** +sorts the current score into the high score array +*/ +void addtopscore(); +/** +displayes the highscore screen +*/ +void highscores(); +/** +displays the tutorial for the game +*/ +void tutorial(); +/** +turns the current note off when called from tout +*/ +void timeoutsound(); +/** +shows the intro screen for the game +*/ +void startscreen(); +/** +draws lines for the tutorial +*/ +void drawlines(); +/** +pauses on the Level 2 intro screen between levels +*/ +void level2screen(); + + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Mobs.h Thu May 05 13:33:38 2016 +0000 @@ -0,0 +1,634 @@ +/** +@file Mobs.h +@brief The header file containing the mob code. +@brief Revision 9.9. +@author Jacob Markl +@date May 2016 +*/ +#ifndef Mobs_H +#define Mobs_H + +#include "Main.h" +#include "Arrays.h" +#include "Variables.h" +/** +preforms all the movement for the rat mob and draws it to g_screen +@param mobnum - the mob number passed from mobturn(); +@returns a rat mob on the g_screen array +*/ +void rat(int mobnum); +/** +preforms all the movement for the frog mob and draws it to g_screen in the location given by g_mobs array +@param mobnum - the mob number passed from mobturn(); +@returns a frog mob on the g_screen array +*/ +void frog(int mobnum); +/** +preforms all the movement for the crab mob and draws it to g_screen in the location given by g_mobs array +@param mobnum - the mob number passed from mobturn(); +@returns a crab mob on the g_screen array +*/ +void crab(int mobnum); +/** +preforms all the movement for the shroom mob and draws it to g_screen in the location given by g_mobs array +@param mobnum - the mob number passed from mobturn(); +@returns a shroom mob on the g_screen array +*/ +void shroom(int mobnum); +/** +preforms all the movement for the boss mob and draws it to g_screen in the location given by g_mobs array +@param mobnum - the mob number passed from mobturn(); +@returns a boss mob on the g_screen array +*/ +void boss(int mobnum); +/** +draws the heart sprite to g_screen in the location given by g_mobs array +@param mobnum - the mob number passed from mobturn(); +@returns a heart on the g_screen array +*/ +void heart(int mobnum); +/** +initializes the g_mobs for a map, based off the mobcode for each map. Is checked when a new map is loaded +*/ +void mobs() +{ + if (cfsm[g_state].cleared==1) { + for(int x = 0; x < 4; x++) { + for (int y = 0; y < 5 ; y++) { + g_mobs[y][x] = 0; + } + } + } else { + for(int x = 0; x < 4; x++) { + for (int y = 0; y < 5 ; y++) { + g_mobs[y][x] = 0; + } + } + switch (cfsm[g_state].mobcode) { + + case 0: + break; + + case 1: + g_mobs[0][0]= 1; + g_mobs[0][1]= 4; + g_mobs[0][2]= 1; + g_mobs[0][3]= 0; + + g_mobs[1][0]= 3; + g_mobs[1][1]= 5; + g_mobs[1][2]= 5; + g_mobs[1][3]= 0; + break; + + case 2: + g_mobs[0][0]= 2; + g_mobs[0][1]= 1; + g_mobs[0][2]= 5; + g_mobs[0][3]= 0; + + g_mobs[1][0]= 2; + g_mobs[1][1]= 1; + g_mobs[1][2]= 6; + g_mobs[1][3]= 0; + + g_mobs[2][0]= 3; + g_mobs[2][1]= 1; + g_mobs[2][2]= 2; + g_mobs[2][3]= 0; + break; + + case 3: + g_mobs[0][0]= 2; + g_mobs[0][1]= 1; + g_mobs[0][2]= 1; + g_mobs[0][3]= 0; + + g_mobs[1][0]= 2; + g_mobs[1][1]= 1; + g_mobs[1][2]= 6; + g_mobs[1][3]= 0; + + g_mobs[2][0]= 3; + g_mobs[2][1]= 5; + g_mobs[2][2]= 2; + g_mobs[2][3]= 0; + + g_mobs[3][0]= 3; + g_mobs[3][1]= 5; + g_mobs[3][2]= 5; + g_mobs[3][3]= 0; + break; + + case 4: + g_mobs[0][0]= 2; + g_mobs[0][1]= 1; + g_mobs[0][2]= 4; + g_mobs[0][3]= 0; + + g_mobs[1][0]= 6; + g_mobs[1][1]= 3; + g_mobs[1][2]= 2; + g_mobs[1][3]= 0; + + break; + case 5: + g_mobs[0][0]= 1; + g_mobs[0][1]= 1; + g_mobs[0][2]= 4; + g_mobs[0][3]= 0; + + g_mobs[1][0]= 3; + g_mobs[1][1]= 1; + g_mobs[1][2]= 1; + g_mobs[1][3]= 0; + + g_mobs[2][0]= 4; + g_mobs[2][1]= 5; + g_mobs[2][2]= 1; + g_mobs[2][3]= 0; + + break; + case 6: + g_mobs[0][0]= 5; + g_mobs[0][1]= 2; + g_mobs[0][2]= 5; + g_mobs[0][3]= 1; + break; + + case 7: + g_mobs[0][0]= 3; + g_mobs[0][1]= 1; + g_mobs[0][2]= 4; + g_mobs[0][3]= 0; + + g_mobs[1][0]= 4; + g_mobs[1][1]= 2; + g_mobs[1][2]= 1; + g_mobs[1][3]= 0; + + g_mobs[2][0]= 3; + g_mobs[2][1]= 4; + g_mobs[2][2]= 4; + g_mobs[2][3]= 0; + + break; + + case 8: + g_mobs[0][0]= 4; + g_mobs[0][1]= 1; + g_mobs[0][2]= 2; + g_mobs[0][3]= 0; + + g_mobs[1][0]= 4; + g_mobs[1][1]= 3; + g_mobs[1][2]= 4; + g_mobs[1][3]= 0; + + break; + + case 9: + g_mobs[0][0]= 1; + g_mobs[0][1]= 2; + g_mobs[0][2]= 1; + g_mobs[0][3]= 1; + + g_mobs[1][0]= 1; + g_mobs[1][1]= 5; + g_mobs[1][2]= 1; + g_mobs[1][3]= 1; + + g_mobs[2][0]= 1; + g_mobs[2][1]= 5; + g_mobs[2][2]= 4; + g_mobs[2][3]= 1; + + g_mobs[3][0]= 1; + g_mobs[3][1]= 2; + g_mobs[3][2]= 4; + g_mobs[3][3]= 1; + break; + + case 10: + g_mobs[0][0]= 4; + g_mobs[0][1]= 3; + g_mobs[0][2]= 4; + g_mobs[0][3]= 0; + + g_mobs[1][0]= 4; + g_mobs[1][1]= 4; + g_mobs[1][2]= 4; + g_mobs[1][3]= 0; + + g_mobs[2][0]= 3; + g_mobs[2][1]= 3; + g_mobs[2][2]= 3; + g_mobs[2][3]= 0; + break; + + case 11: + g_mobs[0][0]= 2; + g_mobs[0][1]= 1; + g_mobs[0][2]= 6; + g_mobs[0][3]= 0; + + g_mobs[1][0]= 3; + g_mobs[1][1]= 3; + g_mobs[1][2]= 2; + g_mobs[1][3]= 0; + + g_mobs[2][0]= 4; + g_mobs[2][1]= 6; + g_mobs[2][2]= 1; + g_mobs[2][3]= 0; + + g_mobs[4][0]= 6; + g_mobs[4][1]= 1; + g_mobs[4][2]= 5; + g_mobs[4][3]= 0; + break; + + + default: + break; + } + } +} +/** +calls the functions for every mob that is currently on the map +*/ +void mobturn() +{ + for(int y = 0; y < 5; y++) { + switch(g_mobs[y][0]) { + + case 1: + rat(y); + break; + case 2: + frog(y); + break; + case 3: + crab(y); + break; + case 4: + shroom(y); + break; + case 5: + boss(y); + break; + case 6: + heart(y); + break; + default: + break; + } + } +} + + +void frog(int mobnum) +{ + int frog[6][6]; + + switch (frogfsm[g_mobs[mobnum][3]].facing) { + case 1: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + frog[x][y] = g_frog[x][y]; + } + } + break; + + case 2: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + frog[x][y] = g_frog[5-y][x]; + } + } + + break; + case 3: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + frog[x][y] = g_frog[5-x][5-y]; + } + } + break; + case 4: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + frog[x][y] = g_frog[y][5-x]; + } + } + + break; + + default: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + frog[x][y] = g_frog[x][y]; + } + } + break; + } + if (g_timer1_flag == 1) { + if (((g_mobs[mobnum][1]+frogfsm[g_mobs[mobnum][3]].nextx)==g_playerlocationx)and((g_mobs[mobnum][2]+frogfsm[g_mobs[mobnum][3]].nexty)==g_playerlocationy)) { + if (g_playerinvun==0) { + g_playerhp--; + g_playerinvun=4; + } + } else { + g_mobs[mobnum][1] = g_mobs[mobnum][1]+frogfsm[g_mobs[mobnum][3]].nextx; + g_mobs[mobnum][2] = g_mobs[mobnum][2]+frogfsm[g_mobs[mobnum][3]].nexty; + g_mobs[mobnum][3] = frogfsm[g_mobs[mobnum][3]].nextstate; + } + } + int mapx = g_mobs[mobnum][2]*6; + int mapy = g_mobs[mobnum][1]*6; + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + g_screen[mapy+y][mapx+x] = 16+frog[x][y]; + + } + } +} + +void rat(int mobnum) +{ + int rat[6][6]; + + switch (ratfsm[g_mobs[mobnum][3]].facing) { + case 1: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + rat[x][y] = g_rat[x][y]; + } + } + break; + + case 2: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + rat[x][y] = g_rat[5-y][x]; + } + } + + break; + case 3: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + rat[x][y] = g_rat[5-x][5-y]; + } + } + break; + case 4: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + rat[x][y] = g_rat[y][5-x]; + } + } + + break; + + default: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + rat[x][y] = g_rat[x][y]; + } + } + break; + } + if (g_timer1_flag == 1) { + if (((g_mobs[mobnum][1]+ratfsm[g_mobs[mobnum][3]].nextx)==g_playerlocationx)and((g_mobs[mobnum][2]+ratfsm[g_mobs[mobnum][3]].nexty)==g_playerlocationy)) { + if (g_playerinvun==0) { + g_playerhp--; + g_playerinvun=4; + } + } else { + g_mobs[mobnum][1] = g_mobs[mobnum][1]+ratfsm[g_mobs[mobnum][3]].nextx; + g_mobs[mobnum][2] = g_mobs[mobnum][2]+ratfsm[g_mobs[mobnum][3]].nexty; + g_mobs[mobnum][3] = ratfsm[g_mobs[mobnum][3]].nextstate; + } + } + int mapx = g_mobs[mobnum][2]*6; + int mapy = g_mobs[mobnum][1]*6; + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + g_screen[mapy+y][mapx+x] = 14+rat[x][y]; + + } + } +} + +void crab(int mobnum) +{ + int crab[6][6]; + + switch (crabfsm[g_mobs[mobnum][3]].facing) { + case 1: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + crab[x][y] = g_crab[x][y]; + } + } + break; + + case 2: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + crab[x][y] = g_crab[5-y][x]; + } + } + + break; + case 3: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + crab[x][y] = g_crab[5-x][5-y]; + } + } + break; + case 4: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + crab[x][y] = g_crab[y][5-x]; + } + } + + break; + + default: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + crab[x][y] = g_crab[x][y]; + } + } + break; + } + if (g_timer1_flag == 1) { + if (((g_mobs[mobnum][1]+crabfsm[g_mobs[mobnum][3]].nextx)==g_playerlocationx)and((g_mobs[mobnum][2]+crabfsm[g_mobs[mobnum][3]].nexty)==g_playerlocationy)) { + if (g_playerinvun==0) { + g_playerhp--; + g_playerinvun=4; + } + } else { + g_mobs[mobnum][1] = g_mobs[mobnum][1]+crabfsm[g_mobs[mobnum][3]].nextx; + g_mobs[mobnum][2] = g_mobs[mobnum][2]+crabfsm[g_mobs[mobnum][3]].nexty; + g_mobs[mobnum][3] = crabfsm[g_mobs[mobnum][3]].nextstate; + } + } + int mapx = g_mobs[mobnum][2]*6; + int mapy = g_mobs[mobnum][1]*6; + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + g_screen[mapy+y][mapx+x] = 14+crab[x][y]; + + } + } +} + +void shroom(int mobnum) +{ + int shroom[6][6]; + + switch (shroomfsm[g_mobs[mobnum][3]].facing) { + case 1: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + shroom[x][y] = g_shroom[x][y]; + } + } + break; + + case 2: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + shroom[x][y] = g_shroom[5-y][x]; + } + } + + break; + case 3: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + shroom[x][y] = g_shroom[5-x][5-y]; + } + } + break; + case 4: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + shroom[x][y] = g_shroom[y][5-x]; + } + } + + break; + + default: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + shroom[x][y] = g_shroom[x][y]; + } + } + break; + } + if (g_timer1_flag == 1) { + if (((g_mobs[mobnum][1]+shroomfsm[g_mobs[mobnum][3]].nextx)==g_playerlocationx)and((g_mobs[mobnum][2]+shroomfsm[g_mobs[mobnum][3]].nexty)==g_playerlocationy)) { + if (g_playerinvun==0) { + g_playerhp--; + g_playerinvun=4; + } + } else { + g_mobs[mobnum][1] = g_mobs[mobnum][1]+shroomfsm[g_mobs[mobnum][3]].nextx; + g_mobs[mobnum][2] = g_mobs[mobnum][2]+shroomfsm[g_mobs[mobnum][3]].nexty; + g_mobs[mobnum][3] = shroomfsm[g_mobs[mobnum][3]].nextstate; + } + } + int mapx = g_mobs[mobnum][2]*6; + int mapy = g_mobs[mobnum][1]*6; + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + g_screen[mapy+y][mapx+x] = 14+shroom[x][y]; + + } + } +} + + +void heart(int mobnum) +{ + int heart[6][6]; + + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + heart[x][y] = g_heart[x][y]; + } + } + + int mapx = g_mobs[mobnum][2]*6; + int mapy = g_mobs[mobnum][1]*6; + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + g_screen[mapy+y][mapx+x] = 16+heart[x][y]; + + } + } +} + + +void boss(int mobnum) +{ + int boss[6][6]; + + switch (bossfsm[g_mobs[mobnum][3]].facing) { + case 1: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + boss[x][y] = g_boss[x][5-y]; + } + } + + break; + case 2: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + boss[x][y] = g_boss[x][y]; + } + } + break; + + + default: + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + boss[x][y] = g_boss[x][y]; + } + } + break; + } + if (g_timer1_flag == 1) { + if (((g_mobs[mobnum][1]+bossfsm[g_mobs[mobnum][3]].nextx)==g_playerlocationx)and((g_mobs[mobnum][2]+bossfsm[g_mobs[mobnum][3]].nexty)==g_playerlocationy)) { + if (g_playerinvun==0) { + g_playerhp--; + g_playerinvun=4; + } + } else { + g_mobs[mobnum][1] = g_mobs[mobnum][1]+bossfsm[g_mobs[mobnum][3]].nextx; + g_mobs[mobnum][2] = g_mobs[mobnum][2]+bossfsm[g_mobs[mobnum][3]].nexty; + g_mobs[mobnum][3] = bossfsm[g_mobs[mobnum][3]].nextstate; + } + } + int mapx = g_mobs[mobnum][2]*6; + int mapy = g_mobs[mobnum][1]*6; + for(int x = 0; x < 6; x++) { + for (int y = 0; y < 6 ; y++) { + g_screen[mapy+y][mapx+x] = 14+boss[x][y]; + + } + } +} + + + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/N5110.lib Thu May 05 13:33:38 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/eencae/code/N5110/#ba8addc061ea
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDFileSystem.lib Thu May 05 13:33:38 2016 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/mbed_official/code/SDFileSystem/#7b35d1709458
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/SDcard.h Thu May 05 13:33:38 2016 +0000 @@ -0,0 +1,110 @@ +/** +@file SDcard.h +@brief The header file containing functions for the SDcard. +@brief Revision 9.9. +@author Jacob Markl +@date May 2016 +*/ + +#ifndef SDcard_H +#define SDcard_H + +#include "SDFileSystem.h" +#include "Main.h" +#include "Variables.h" +#include "Main.h" + +FILE *topscore; +FILE *song; +std::vector<float> g_musicarray; +using namespace std; + + +/** +checks if the top score file exists, if it does then it closes the file and removes it +if the file does not exist it creates a new file, writes it blank and closes it. +*/ +void clearsd() +{ + topscore = fopen("/sd/topscore.txt", "r"); + if (topscore != NULL) { + fclose(topscore); + remove("/sd/topscore.txt"); + } + topscore = fopen("/sd/topscore.txt", "w"); + fprintf(topscore, "0,0,0"); + fclose(topscore); +} + +/** +writes a topscore file, fills it with the g_topscore array and closes it. +*/ +void writesd() +{ + + topscore = fopen("/sd/topscore.txt", "w"); + if (topscore!=NULL) { + fprintf(topscore, "%d,%d,%d",g_topscores[0],g_topscores[1],g_topscores[2]); + fclose(topscore); + } + +} +/** +clears the g_musicarray +reads the song stored on the sd card and stores it in the g_musicarray if the song file exists +if the song does not exist then it stores the g_songdefault in the g_musicarray +*/ +void readsong() +{ + + song = fopen("/sd/song.txt", "r"); + if (song==NULL) { + song = fopen("/sd/song.txt", "r"); + } + g_musicarray.clear(); + if (song==NULL) { + for (int y = 0; y < (((sizeof(g_songdefault))/(sizeof(g_songdefault[0])))-1) ; y++) { + g_musicarray.push_back(g_songdefault[y]); + } + } else { + int i = 0; + float note=0; + while (fscanf(song, "%f,",¬e) != EOF) { + g_musicarray.push_back(note); + i++; + } + fclose(song); + } + +} +/** +reads from the sd card and store the high scores in the g_topscores array +if the file does not exist, then write a new blank file +*/ +void readsd() +{ + int value1; + int value2; + int value3; + topscore = fopen("/sd/topscore.txt", "r"); + if (topscore==NULL) { + topscore = fopen("/sd/topscore.txt", "r"); + if (topscore==NULL) { + writesd(); + } + } + if (topscore!=NULL) { + fscanf(topscore, "%d,%d,%d",&value1,&value2,&value3); + g_topscores[0]=value1; + g_topscores[1]=value2; + g_topscores[2]=value3; + fclose(topscore); + } + else{ + g_topscores[0]=0; + g_topscores[1]=0; + g_topscores[2]=0; + } + +} +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Tickersandmore.h Thu May 05 13:33:38 2016 +0000 @@ -0,0 +1,82 @@ +/** +@file Tickersandmore.h +@brief The header file containing Tickers, Timeouts, and the pins for the I/Os. +@brief Revision 9.9. +@author Jacob Markl +@date May 2016 +*/ + +#ifndef Tick_H +#define Tick_H + +#include "SDcard.h" +/** +@namespace ticker1 +@brief A Ticker that provides the game timing +*/ +Ticker ticker1; +/** +@namespace ticker2 +@brief A Ticker that provides the music timing +*/ +Ticker ticker2; +/** +@namespace tout +@brief A Timeout that triggers the pwm note stop +*/ +Timeout tout; +/** +@namespace idle +@brief A Timeout that triggers the timing out from the player not acting for so long. +*/ +Timeout idle; +/** +@namespace idle +@brief A Timeout that triggers the timing out from the player not acting for so long. +*/ +PwmOut Buzz(PTA2); +/** +@namespace BUI +@brief An InterruptIn for the up button. +*/ +InterruptIn BUI(PTB18); +/** +@namespace BRI +@brief An InterruptIn for the right button. +*/ +InterruptIn BRI(PTB19); +/** +@namespace BDI +@brief An InterruptIn for the down button. +*/ +InterruptIn BDI(PTC1); +/** +@namespace BLI +@brief An InterruptIn for the left button. +*/ +InterruptIn BLI(PTC8); +/** +@namespace BAI +@brief An InterruptIn for the A button. +*/ +InterruptIn BAI(PTB3); +/** +@namespace BBI +@brief An InterruptIn for the B button. +*/ +InterruptIn BBI(PTB2); +/** +@namespace lcd +@brief the pin deffinitions for the N5110 lcd. +*/ +// VCC, SCE, RST, D/C, MOSI, SCLK, LED +N5110 lcd (PTE26 , PTA0 , PTC4 , PTD0 , PTD2 , PTD1 , PTC3); + +/** +@namespace sd +@brief the pin deffinitions for the SDcard. +*/ +SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); + + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Variables.h Thu May 05 13:33:38 2016 +0000 @@ -0,0 +1,53 @@ +/** +@file Variables.h +@brief The header file containing the global variables. +@brief Revision 9.9. +@author Jacob Markl +@date May 2016 +*/ + +#ifndef Variables_H +#define Variables_H + + +bool g_music = true;/*!< if music is on, value is true */ +bool g_playersprite = false;/*!<if the player is attacking, value is true */ +bool g_gamewon = false;/*!< if the player wins the game, value is true */ + +int g_level = 1;/*!< the currently selected level */ +int g_isidle = 0;/*!< a flag for if the player goes idle */ +int g_select = 0;/*!<the current selected menu option */ +int g_options = 0;/*!< the ammount of menu options availalbe */ +int g_direction = 0;/*!<the current movement direction of the map */ +int g_playerfacing = 0;/*!< the direction the player is facing */ +int g_playerinvun = 0;/*!< how long the player is invurable for */ +int g_playerdirection = 4;/*!< the current direction the player is moveing */ +int g_playerlocationy = 4;/*!< the players y coord */ +int g_playerlocationx = 2;/*!< the players x coord */ +int g_playerhp = 3;/*!< the players current hp */ +int g_state = 0;/*!< the current map state */ +int g_playtime = 0;/*!<the total playtime for the current run */ +int g_score = 0;/*!< the players score */ +int g_layout[8][8];/*!< the layout array for the current map */ +int g_screen[48][48];/*!< the screen array for the urrent map */ +int g_topscores[3]= {0,0,0};/*!< the topscore array */ +int g_mobs[5][4]= { + {0,0,0,0}, + {0,0,0,0}, + {0,0,0,0}, + {0,0,0,0}, + {0,0,0,0} +};/*!<the current mobs on the map array */ +float g_songdefault[9]= {0.5,1175,1245,1175,1480,1397,1175,1245,1109};/*!<the song that is played when the sd cant be loaded */ + +volatile int g_BUI_flag = 0;/*!<the volatile up button flag */ +volatile int g_BRI_flag = 0;/*!<the volatile right button flag */ +volatile int g_BDI_flag = 0;/*!<the volatile down button flag */ +volatile int g_BLI_flag = 0;/*!<the volatile left button flag */ +volatile int g_BAI_flag = 0;/*!<the volatile A button flag */ +volatile int g_BBI_flag = 0;/*!<the volatile B button flag */ +volatile int g_timer1_flag = 0;/*!<the volatile timer1 flag */ +volatile int g_timer2_flag = 0;/*!<the volatile timer2 flag */ +volatile int g_idle_flag = 0;/*!<the volatile idle timeout flag */ + +#endif \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu May 05 13:33:38 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/f141b2784e32 \ No newline at end of file