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 MotionSensor
Diff: Entity/Snake/Snake.h
- Revision:
- 16:ddb203a74dfc
- Child:
- 17:99e533f7f2fb
- Child:
- 19:bfe410c82b45
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Entity/Snake/Snake.h Wed Apr 24 21:21:37 2019 +0000
@@ -0,0 +1,294 @@
+#ifndef SNAKE_H
+#define SNAKE_H
+#include "Entity.h"
+
+class Snake : public Entity {
+
+ public:
+ // Constructor
+ Snake(float, float);
+
+ // Functions
+ virtual void move(float, float);
+ virtual int * get_frame();
+
+};
+
+const float velocity_pattern[6] = {0, 0.3, 0.5, 0.7, 0.5, -0.2};
+
+const int sprite_snake[4][6][12][6] = { // Player [Face][SpriteAnimationFrame][Size_Y][Size_X]
+ { // Up
+ {
+ {0,0,0,0,0,0,},
+ {1,0,0,0,0,0,},
+ {0,1,1,1,1,0,},
+ {1,0,1,1,0,1,},
+ {0,0,1,1,0,0,},
+ {0,0,1,1,0,0,},
+ {0,1,0,0,1,0,},
+ {0,1,0,0,1,0,},
+ {0,1,0,0,1,0,}
+ },
+ {
+ {0,0,0,0,0,0,},
+ {0,0,0,1,0,0,},
+ {0,1,1,1,1,0,},
+ {1,0,1,1,0,1,},
+ {0,0,1,1,0,0,},
+ {0,0,1,1,0,0,},
+ {0,1,0,0,1,0,},
+ {0,1,0,0,1,0,},
+ {0,0,0,0,1,0,}
+ },
+ {
+ {0,0,0,0,1,0,},
+ {0,0,1,0,0,0,},
+ {0,1,1,1,1,0,},
+ {1,0,1,1,0,1,},
+ {0,0,1,1,0,0,},
+ {0,0,1,1,0,0,},
+ {0,1,0,0,1,0,},
+ {0,1,0,0,1,0,},
+ {0,1,0,0,1,0,}
+ },
+ {
+ {0,1,0,0,0,0,},
+ {0,0,0,0,0,0,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