Mohamed Moawya / SnakeGame

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers SnakeEngine.h Source File

SnakeEngine.h

00001 #include "snake_defines.h"
00002 #include "N5110.h"
00003 #include "Gamepad.h"
00004 
00005 class SnakeEngine
00006 {
00007 
00008 private:
00009     //Direction of out snake
00010     //0 - LEFT, 1 - RIGHT, 2 - DOWN, 3- UP
00011     int dirSnake;
00012     int gameScore;
00013     int gameLife;
00014     int gameObjectSize;        //width of the snake
00015     unsigned int snakeSize;    // initial length of the sanke
00016     int obstaclesNum ; /********************update*******************/
00017     unsigned int level;        /********************update*******************/
00018 
00019     gameObject snake[100]; // size of the snake. Lets hope no one can grow the snake more than 100 :D
00020 
00021     gameObject obstacles[12]
00022     ; /********************update*******************/
00023 
00024     gameObject food;
00025 
00026     stateGame state;
00027 
00028     Gamepad &gamePad;
00029     N5110 &lcd;
00030 
00031     bool bLeft;
00032     bool bRight;
00033     bool bDown;
00034     bool bUp;
00035 
00036     int AREA_X;
00037     int AREA_Y;
00038     int AREA_X_min;
00039     int AREA_Y_min;
00040     int gameSpeed;
00041 
00042     void drawSnake();
00043     void drawFood();
00044     void drawScore();
00045     void regenFood();
00046     void readUserInput();
00047 
00048 public:
00049     SnakeEngine(Gamepad &, N5110 &);
00050     ~SnakeEngine();
00051     void drawGameFrame();
00052     void isColliding();
00053     void setupGame();
00054     void handleUserInput();
00055     void updateGame();
00056     void playGame();
00057     void gameIsPaused();
00058     void gameIsLost();
00059     void init();
00060     void runGameEngine();
00061     void welcome();
00062     int getGameSpeed();
00063     void drawObstacles();      /********************update*******************/
00064     void obstaclesPosition(); /********************update*******************/
00065 };