![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Balint Bogdan SnekGame
Dependencies: FoodLibrary Gamepad N5110 SnekGame mbed
Diff: main.cpp
- Revision:
- 1:a222ad7a05b9
- Parent:
- 0:789c74742603
- Child:
- 2:94b01aafb32f
--- a/main.cpp Mon Mar 20 11:18:44 2017 +0000 +++ b/main.cpp Fri May 05 11:56:20 2017 +0000 @@ -1,58 +1,90 @@ #include "mbed.h" #include "N5110.h" +#include "Gamepad.h" + +#include "Snake.h" + +/************************Structs************************/ +struct UserInput { + Direction d; + +}; -void loadMap(); -void getEnemy(); -void bomb(); +/************************Objects************************/ +N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);//set LCD pins +Gamepad pad; +Snake snake; + +//Serial pc(USBTX , USBRX );//tx, rx +//Engine bman; -//set LCD pins -int heroChar[4]=(1,1,0,1); -int bomb[4]=(0,1,0,1); -int boulderLocation[4][8]={}// set the coordinate for boulder, if 00, boulder does not exist +/************************Prototypes************************/ +void start_screen(); +void init(); +void display(); +void update_game(UserInput input); + +/************************Variables************************/ + +//int heroChar[4]=(1,1,0,1); +//int bomb[4]=(0,1,0,1); +//int boulderLocation[4][8]={}// set the coordinate for boulder, if 00, boulder does not exist + +/************************Main code************************/ int main() { lcd.init();//initializing display - + pad.init(); + //pc.printf("initalized"); + snake.init(25,25,6); + start_screen(); while (true) { - //draw the map - - //draw top line (life) - - //draw boulders - - //draw characters at certain position - - //draw bomb - - //refresh - wait(0.2f); + //run game engine + //implement safety features + //start stop buttons here for menu + + pad.leds_on(); + wait(0.05f); + pad.leds_off(); + wait(0.1f); + //engine.getInput(pad); + //snake.update(pad); + //printf("updated"); + snake.draw(lcd); + snake.update(pad); + //wait(0.2f); } } - +/************************Functions************************/ -void loadMap(){ - //get the size of the map and - //use draw line for large lines - //set pixel for small bts - //look for boulders , if coordinate 00 ignore - //draw boulder as bomb +void start_screen(){ + lcd.printString("Snek, the game",0,1); + lcd.printString("Press Start",0,4); + lcd.refresh(); + printf("waiting for input"); + while ( pad.check_event(Gamepad::START_PRESSED) == false) {//this is a placeholder code from pong, change it please + pad.leds_on(); + wait(0.1); + pad.leds_off(); + wait(0.1); + printf("still..."); } - -void drawHero(){ - //get the position first - //draw {1,2} in first line - //flip [3,4] for walking +printf("done"); + } + +void init(){ + lcd.init();//initalizing display + pad.init();//inita;izing pad + + //bman.init();//initalizing game } - -void bomb(){ - //get location - //draw bomb - //flip bomb do show its a bomb - //if a boulder is at the range set0 +void display() { - } - \ No newline at end of file + lcd.clear(); + //bman.display(lcd); + lcd.refresh(); +} \ No newline at end of file