Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
SnakeEngine/SnakeEngine.h
- Committer:
- Psy1990
- Date:
- 2020-06-05
- Revision:
- 13:c20acb3b1adf
- Parent:
- 12:8eb40a18f15d
- Child:
- 16:8cb23849b95a
File content as of revision 13:c20acb3b1adf:
#ifndef SNAKEENGINE_H
#define SNAKEENGINE_H
#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"
#include "Apple.h"
#include "Snake.h"
#include "Bitmap.h"
/** Apple Class File
* @brief Class containing the engine that runs the game.
* @author Simon Atkinson
* @date June 2020
*/
// gap from edge of screen
#define GAP 2
class SnakeEngine
{
public:
    SnakeEngine();
    ~SnakeEngine();
    void init(int apple_size, int snake_speed, int snake_score, int snake_snakeheight, int snake_snakewidth);
    void read_input(Gamepad &pad);  //Allows us to read the input from the thumbstick
    void update(Gamepad &pad, N5110 &lcd);      //Allows us to update the gamepad 
    void draw(N5110 &lcd);          //Allows us to draw on the screen
    void dead(N5110 &lcd, Gamepad &pad); // The snake is DEAD :(
    void eat(N5110 &lcd, Gamepad &pad); // Deals with the snake eating the apple
private:
    void print_score(N5110 &lcd);
    
    int sx;  //Snake X
    int sy;  //Snake Y
    int ax;  //Apple X
    int ay;  //Apple Y
    int _apple_size;  //Apple size is defined and taken from main.cpp
    int _snake_speed; //Stores the speed the snake goes
    int _snake_score; //Stores the score
    int _snake_snakeheight; // Snake Hight
    int _snake_snakewidth; // Snake Width
    bool _dead;
    
    Snake _s;   //Allows us to use the Snake 
    Apple _a;   //Allows us to use the Apple 
    Direction _d; //Direction
    float _mag;   //Magnitude
    
};
#endif