Final Commit

Dependencies:   mbed

Committer:
JRM1986
Date:
Mon Apr 30 08:11:40 2018 +0000
Revision:
18:406fc298a7c4
Parent:
17:94dd8a691d4a
Child:
19:b437806e579b
Save Commit

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 13:72bc2579e85e 11 #define SNAKE_X 74
JRM1986 13:72bc2579e85e 12 #define SNAKE_Y 23
JRM1986 13:72bc2579e85e 13 #define SNAKE_DIRECTION W
JRM1986 13:72bc2579e85e 14
JRM1986 2:ea90cec2489a 15 /** SnakeEngine Class
JRM1986 1:c3fdbc4b1293 16 * @brief Class that initialises and defines the game charectoristics ready for the main file
JRM1986 1:c3fdbc4b1293 17 * @author Joshua R. Marshall
JRM1986 1:c3fdbc4b1293 18 * @date Feb, 2018
JRM1986 2:ea90cec2489a 19 */
JRM1986 16:85ca9feccf3f 20
JRM1986 16:85ca9feccf3f 21 int g_tail_length();
JRM1986 17:94dd8a691d4a 22 Vector2D g_tail_position();
JRM1986 17:94dd8a691d4a 23
JRM1986 17:94dd8a691d4a 24 int g_get_even_array();
JRM1986 17:94dd8a691d4a 25 int g_get_odd_array();
JRM1986 17:94dd8a691d4a 26 int g_get_engine_frame_count();
JRM1986 16:85ca9feccf3f 27
JRM1986 16:85ca9feccf3f 28 static Vector2D g_tp;
JRM1986 16:85ca9feccf3f 29 static int g_tl;
JRM1986 17:94dd8a691d4a 30 static int g_tc;
JRM1986 17:94dd8a691d4a 31 static int g_engine_fc;
JRM1986 16:85ca9feccf3f 32
JRM1986 17:94dd8a691d4a 33 static int g_odd_array_x[100];
JRM1986 17:94dd8a691d4a 34 static int g_odd_array_y[100];
JRM1986 17:94dd8a691d4a 35 static int g_even_array_x[100];
JRM1986 17:94dd8a691d4a 36 static int g_even_array_y[100];
JRM1986 17:94dd8a691d4a 37 static int g_array_x[100];
JRM1986 17:94dd8a691d4a 38 static int g_array_y[100];
JRM1986 17:94dd8a691d4a 39
JRM1986 17:94dd8a691d4a 40 Vector2D g_holder_pos();
JRM1986 17:94dd8a691d4a 41
JRM1986 17:94dd8a691d4a 42
JRM1986 16:85ca9feccf3f 43
JRM1986 16:85ca9feccf3f 44
JRM1986 2:ea90cec2489a 45 class SnakeEngine
JRM1986 2:ea90cec2489a 46 {
JRM1986 2:ea90cec2489a 47
JRM1986 2:ea90cec2489a 48 public:
JRM1986 6:f3f508cea1c4 49
JRM1986 2:ea90cec2489a 50 SnakeEngine(); // constructor
JRM1986 2:ea90cec2489a 51 ~SnakeEngine(); // destructor
JRM1986 6:f3f508cea1c4 52
JRM1986 18:406fc298a7c4 53 void init(); // initiallises the position of the food, and snake
JRM1986 6:f3f508cea1c4 54 void draw(N5110 &lcd); // draws snake/food to the lcd
JRM1986 6:f3f508cea1c4 55 void update(Gamepad &pad); // updates depending on gamepad input
JRM1986 13:72bc2579e85e 56 void get_input(Gamepad &pad); // gets the input from the gamepad
JRM1986 6:f3f508cea1c4 57
JRM1986 16:85ca9feccf3f 58 bool detect_food_collision(Gamepad &pad);
JRM1986 16:85ca9feccf3f 59 bool detect_wall_collision();
JRM1986 16:85ca9feccf3f 60 bool detect_tail_collision();
JRM1986 16:85ca9feccf3f 61
JRM1986 16:85ca9feccf3f 62 void set_tail_length(bool collision_detected);
JRM1986 16:85ca9feccf3f 63 int get_tail_length();
JRM1986 16:85ca9feccf3f 64
JRM1986 17:94dd8a691d4a 65 void set_odd_array(Gamepad &pad);
JRM1986 17:94dd8a691d4a 66 void set_even_array(Gamepad &pad);
JRM1986 17:94dd8a691d4a 67 void set_tail_array(Gamepad &pad);
JRM1986 16:85ca9feccf3f 68
JRM1986 16:85ca9feccf3f 69 void draw_tail(N5110 &lcd);
JRM1986 16:85ca9feccf3f 70
JRM1986 2:ea90cec2489a 71
JRM1986 2:ea90cec2489a 72 private:
JRM1986 2:ea90cec2489a 73
JRM1986 6:f3f508cea1c4 74
JRM1986 6:f3f508cea1c4 75 Food _food;
JRM1986 6:f3f508cea1c4 76
JRM1986 6:f3f508cea1c4 77 Snake _snake;
JRM1986 10:62d8cb7742c3 78
JRM1986 17:94dd8a691d4a 79 //Direction _snake_current_direction;
JRM1986 13:72bc2579e85e 80 int _snake_position_x;
JRM1986 13:72bc2579e85e 81 int _snake_position_y;
JRM1986 13:72bc2579e85e 82
JRM1986 13:72bc2579e85e 83 Direction _in;
JRM1986 10:62d8cb7742c3 84 Direction _cur;
JRM1986 10:62d8cb7742c3 85
JRM1986 18:406fc298a7c4 86 bool _collision;
JRM1986 18:406fc298a7c4 87
JRM1986 17:94dd8a691d4a 88 int _array_x[100];
JRM1986 17:94dd8a691d4a 89 int _array_y[100];
JRM1986 17:94dd8a691d4a 90
JRM1986 17:94dd8a691d4a 91 int _tail_x;
JRM1986 17:94dd8a691d4a 92 int _tail_y;
JRM1986 17:94dd8a691d4a 93
JRM1986 2:ea90cec2489a 94
JRM1986 2:ea90cec2489a 95 };
JRM1986 2:ea90cec2489a 96 #endif