Final Commit

Dependencies:   mbed

Committer:
JRM1986
Date:
Wed Mar 21 13:09:20 2018 +0000
Revision:
7:c38800a428a6
Parent:
6:f3f508cea1c4
Child:
10:62d8cb7742c3
Initialisation of Food class completed, de-bugged but not tested with testing class;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JRM1986 2:ea90cec2489a 1 #ifndef SNAKEENGINE_H
JRM1986 2:ea90cec2489a 2 #define SNAKEENGINE_H
JRM1986 2:ea90cec2489a 3
JRM1986 2:ea90cec2489a 4 #include "mbed.h"
JRM1986 3:50f01159c61d 5 #include "FXOS8700CQ.h"
JRM1986 3:50f01159c61d 6 #include "Gamepad.h"
JRM1986 2:ea90cec2489a 7 #include "N5110.h"
JRM1986 6:f3f508cea1c4 8 #include "Food.h"
JRM1986 6:f3f508cea1c4 9 #include "Snake.h"
JRM1986 2:ea90cec2489a 10
JRM1986 2:ea90cec2489a 11 /** SnakeEngine Class
JRM1986 1:c3fdbc4b1293 12 * @brief Class that initialises and defines the game charectoristics ready for the main file
JRM1986 1:c3fdbc4b1293 13 * @author Joshua R. Marshall
JRM1986 1:c3fdbc4b1293 14 * @date Feb, 2018
JRM1986 2:ea90cec2489a 15 */
JRM1986 2:ea90cec2489a 16 class SnakeEngine
JRM1986 2:ea90cec2489a 17 {
JRM1986 2:ea90cec2489a 18
JRM1986 2:ea90cec2489a 19 public:
JRM1986 6:f3f508cea1c4 20
JRM1986 2:ea90cec2489a 21 SnakeEngine(); // constructor
JRM1986 2:ea90cec2489a 22 ~SnakeEngine(); // destructor
JRM1986 6:f3f508cea1c4 23
JRM1986 7:c38800a428a6 24 void init(int food_pos_x, int food_pos_y); // initiallises the position of the food, and snake
JRM1986 6:f3f508cea1c4 25 void draw(N5110 &lcd); // draws snake/food to the lcd
JRM1986 6:f3f508cea1c4 26 void update(Gamepad &pad); // updates depending on gamepad input
JRM1986 6:f3f508cea1c4 27 void get_input(Gamepad &pad); // gets the input from the gamepad
JRM1986 6:f3f508cea1c4 28
JRM1986 2:ea90cec2489a 29
JRM1986 2:ea90cec2489a 30 private:
JRM1986 2:ea90cec2489a 31
JRM1986 6:f3f508cea1c4 32 void check_wall_reached(); // checks if snake has hit the side
JRM1986 6:f3f508cea1c4 33 void check_food_eaten(); // checks if snake has eaten the food
JRM1986 6:f3f508cea1c4 34 void check_tail_collision(); // checks if snake has collided with its own tail
JRM1986 6:f3f508cea1c4 35
JRM1986 6:f3f508cea1c4 36 // ----- Food Position -----
JRM1986 6:f3f508cea1c4 37
JRM1986 6:f3f508cea1c4 38 int _fx;
JRM1986 6:f3f508cea1c4 39 int _fy;
JRM1986 6:f3f508cea1c4 40
JRM1986 6:f3f508cea1c4 41 Food _food;
JRM1986 6:f3f508cea1c4 42
JRM1986 6:f3f508cea1c4 43 Snake _snake;
JRM1986 2:ea90cec2489a 44
JRM1986 2:ea90cec2489a 45 };
JRM1986 2:ea90cec2489a 46 #endif