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
Diff: SnakeEngine/SnakeEngine.h
- Revision:
- 7:9bd49beccdd1
- Child:
- 8:32825d724856
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SnakeEngine/SnakeEngine.h Thu Jun 04 21:04:55 2020 +0000
@@ -0,0 +1,53 @@
+#ifndef SNAKEENGINE_H
+#define SNAKEENGINE_H
+
+#include "mbed.h"
+#include "N5110.h"
+#include "Gamepad.h"
+#include "SnakeApple.h"
+#include "SnakeTail.h"
+
+
+
+
+class SnakeEngine
+{
+
+public:
+ SnakeEngine();
+ ~SnakeEngine();
+
+ void init(int borderW,int borderH,int appleY,int appleX,int snakeX,int snakeY,int score);
+ void read_input(Gamepad &pad);
+
+ void update(Gamepad &pad);
+ void draw(N5110 &lcd);
+
+private:
+
+ void check_wall_collision(Gamepad &pad);
+ void check_snake_collisions(Gamepad &pad);
+ void check_score(Gamepad &pad);
+ void print_score(N5110 &lcd);
+
+
+ int _borderW;
+ int _borderH;
+ int _score;
+ // Poistion of apple
+ int _appleY;
+ int _applex;
+
+ // Position of the snake
+ int _snakeX;
+ int _snakeY;
+
+ // Head _head;
+ // Apple _apple;
+
+ Direction _dir;
+ float _mag;
+
+};
+
+#endif
\ No newline at end of file