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
snake_engine/snake_engine.h
- Committer:
- weiway
- Date:
- 2018-05-08
- Revision:
- 20:980b37fde361
- Parent:
- 18:e58a1f8e72ad
File content as of revision 20:980b37fde361:
#include "mbed.h"
#include "N5110.h"
#include "Gamepad.h"
#include "snake.h"
#include "Fruit.h"
#ifndef SNAKE_ENGINE_H
#define SNAKE_ENGINE_H
/** snake_engine Class
* @author Wei Wei
* @date 3rd May
*/
class snake_engine
{
public:
snake_engine();
~snake_engine();
void init();//initialise
void draw(N5110 &lcd);//draw snake ,fruit and a squre on lcd screen
void update(Gamepad &pad, N5110 &lcd);//update the new fruit, snake and point
void read_input(Gamepad &pad);//get the command from gamepad
bool getfruit(Gamepad &pad);//a boolean value used for the snake while it eats the fruit return the ture , else false
void collision(Gamepad &pad, N5110 &lcd);//check the snake collision
int clision;
private:
void printpoint(N5110 &lcd);//lcd print the point on the screen
Fruit f;//fruit function
snake s;//snake function
Direction _d;//direction
float _mag;
};
#endif