test test test

Dependencies:   mbed

Committer:
mohamedmoawya
Date:
Mon May 25 19:06:11 2020 +0000
Revision:
0:e4c5e6ec922e
snake game tteest

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mohamedmoawya 0:e4c5e6ec922e 1 /* mbed Microcontroller Library
mohamedmoawya 0:e4c5e6ec922e 2 * Copyright (c) 2019 ARM Limited
mohamedmoawya 0:e4c5e6ec922e 3 * SPDX-License-Identifier: Apache-2.0
mohamedmoawya 0:e4c5e6ec922e 4 */
mohamedmoawya 0:e4c5e6ec922e 5
mohamedmoawya 0:e4c5e6ec922e 6 #include "mbed.h"
mohamedmoawya 0:e4c5e6ec922e 7
mohamedmoawya 0:e4c5e6ec922e 8 #include "N5110.h"
mohamedmoawya 0:e4c5e6ec922e 9 #include "Gamepad.h"
mohamedmoawya 0:e4c5e6ec922e 10 #include "SnakeEngine.h"
mohamedmoawya 0:e4c5e6ec922e 11
mohamedmoawya 0:e4c5e6ec922e 12
mohamedmoawya 0:e4c5e6ec922e 13 Gamepad gamePad;
mohamedmoawya 0:e4c5e6ec922e 14 N5110 lcd;
mohamedmoawya 0:e4c5e6ec922e 15 SnakeEngine snakeEngine(gamePad,lcd);
mohamedmoawya 0:e4c5e6ec922e 16
mohamedmoawya 0:e4c5e6ec922e 17 int gameSpeed;
mohamedmoawya 0:e4c5e6ec922e 18
mohamedmoawya 0:e4c5e6ec922e 19
mohamedmoawya 0:e4c5e6ec922e 20
mohamedmoawya 0:e4c5e6ec922e 21
mohamedmoawya 0:e4c5e6ec922e 22 int main(){
mohamedmoawya 0:e4c5e6ec922e 23 int fps = 6;
mohamedmoawya 0:e4c5e6ec922e 24 gamePad.init();
mohamedmoawya 0:e4c5e6ec922e 25 gamePad.reset_buttons();
mohamedmoawya 0:e4c5e6ec922e 26
mohamedmoawya 0:e4c5e6ec922e 27 lcd.init();
mohamedmoawya 0:e4c5e6ec922e 28 snakeEngine.init();
mohamedmoawya 0:e4c5e6ec922e 29 snakeEngine.welcome();
mohamedmoawya 0:e4c5e6ec922e 30 gameSpeed = snakeEngine.getGameSpeed(); // initiallize the game speed to lowest
mohamedmoawya 0:e4c5e6ec922e 31
mohamedmoawya 0:e4c5e6ec922e 32 fps = gameSpeed*2;
mohamedmoawya 0:e4c5e6ec922e 33 while(true){
mohamedmoawya 0:e4c5e6ec922e 34 snakeEngine.runGameEngine();
mohamedmoawya 0:e4c5e6ec922e 35 gameSpeed = snakeEngine.getGameSpeed();
mohamedmoawya 0:e4c5e6ec922e 36 fps = gameSpeed*2;
mohamedmoawya 0:e4c5e6ec922e 37 wait(1.0f/fps); // we wait accordingly to game speed
mohamedmoawya 0:e4c5e6ec922e 38 }
mohamedmoawya 0:e4c5e6ec922e 39
mohamedmoawya 0:e4c5e6ec922e 40 }