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/Mobs/Snake/Snake.h
- Revision:
- 32:fe6359ef9916
- Child:
- 33:4f3948dcd2f7
diff -r ab24d028ddfd -r fe6359ef9916 Entity/Mobs/Snake/Snake.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Entity/Mobs/Snake/Snake.h Mon May 06 08:56:48 2019 +0000
@@ -0,0 +1,291 @@
+#ifndef SNAKE_H
+#define SNAKE_H
+#include "Entity.h"
+
+class Snake : public Entity
+{
+
+public:
+ // Constructor
+ Snake(float, float);
+
+ // Functions
+ virtual void move(float, float, int * map, bool * doorways);
+ virtual void take_damage(int);
+ virtual void draw(N5110 &lcd);
+
+private:
+ // Member Function
+ void update_prev_face();
+ int * get_frame();
+
+ // Member Mutator
+ void update_hitbox(int, int, int, int, int, int, int);
+
+ // Member Variable
+ int _velocity_index;
+ int _prev_face;
+
+};
+
+const float velocity_pattern[6] = {0, 0.15, 0.25, 0.35, 0.25, -0.1};
+
+const int sprite_snake_x[2][4][7][12] = { // Player [Face][SpriteAnimationFrame][Size_Y][Size_X]
+ {
+ // Right
+ {
+ {0,0,0,0,0,0,0,0,1,1,1,0,},
+ {0,0,0,0,0,0,0,1,1,1,2,1,},
+ {0,0,0,0,0,0,0,1,1,1,1,1,},
+ {0,0,0,0,0,0,0,1,1,1,0,0,},
+ {0,0,0,0,0,0,0,0,1,1,1,0,},
+ {0,0,1,1,1,1,0,1,1,1,1,0,},
+ {1,1,1,0,1,1,1,1,1,1,0,0,},
+ },
+ {
+ {0,0,0,0,0,0,0,0,1,1,1,0,},
+ {0,0,0,0,0,0,0,1,1,1,2,1,},
+ {0,0,0,0,0,0,0,1,1,1,1,1,},
+ {0,0,0,0,0,0,0,1,1,1,0,0,},
+ {0,0,0,0,0,0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