ELEC2645 (2019/20) / Mbed 2 deprecated ELEC2645_Project_el18s2a_2

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Snake.h Source File

Snake.h

00001 #ifndef Snake_H
00002 #define Snake_H
00003 
00004 #include "mbed.h"
00005 #include "N5110.h"
00006 #include "Gamepad.h"
00007 
00008 /** Snake Class File
00009 * @brief Class containing the snake for the actual game.
00010 * @author Simon Atkinson
00011 * @date June 2020
00012 */
00013 
00014 class Snake
00015 {
00016 public:
00017 
00018     Snake();
00019     ~Snake();
00020     /**
00021     @pram The Initial setup of the of the snake
00022     */
00023     void init(int _x, int _y, int score, int _speed, int snakeheight, int snakewidth); 
00024     /**
00025     @pram For drawing the snake on the screen allows the use of the LCD
00026     */
00027     void draw(N5110 &lcd); 
00028     /**
00029     @return Gets the direction from the thumbstick
00030     */
00031     void update (Direction d,float mag); 
00032     /**
00033     @pram Eating an apple will add to the score
00034     */
00035     void add_score();
00036     /**
00037     @return Gives us the score
00038     */
00039     int get_score ();
00040     /**
00041     @return Gets the position of the snake
00042     */
00043     Vector2D get_pos (); 
00044     /**
00045     @return Gets the value the determines how fast the snake moves
00046     */
00047     Vector2D get_move (); 
00048     /**
00049     @return Gets the direction the snake travels in can be only North, East, South or West and the snake can't move in other directions.
00050     */
00051     Vector2D get_Direction (); 
00052     /**
00053     @pram Sets the Movement of the snake
00054     */
00055     void set_move(Vector2D m);
00056 
00057 
00058 
00059 private:
00060 
00061     Vector2D _move;  //Move value
00062     Vector2D _d;     // Direction
00063     int _x;          // X position of snake
00064     int _y;          // Y Position of snake
00065     int _score;      // Scoring system
00066     int _speed;      // Speed the snake goes
00067     int _snakeheight;      // set in main.cpp
00068     int _snakewidth;      // set in main.cpp
00069 
00070 
00071 };
00072 #endif