Steven Mahasin / Mbed 2 deprecated DreamDungeon

Dependencies:   mbed MotionSensor

Revision:
18:3c030560e31d
Parent:
17:99e533f7f2fb
Child:
22:7abf4581bc9b
diff -r 99e533f7f2fb -r 3c030560e31d Entity/Snake/Snake.cpp
--- a/Entity/Snake/Snake.cpp	Wed Apr 24 23:56:32 2019 +0000
+++ b/Entity/Snake/Snake.cpp	Thu Apr 25 03:32:36 2019 +0000
@@ -26,14 +26,16 @@
 void Snake::update_prev_face(){_prev_face = face;}
 
 // Member Mutator
-void Snake::update_hitbox(int hitbox_width, int hitbox_height, int hitbox_offset_x, int hitbox_offset_y, int sprite_size_width, int sprite_size_height, int sprite_size_offset_x, int sprite_size_offset_y){    // Offset, Hitbox and Frame Count update
+void Snake::update_hitbox(int hitbox_width, int hitbox_height, int hitbox_offset_x, int hitbox_offset_y, int sprite_size_width, int sprite_size_height, int sprite_size_offset_x, int sprite_size_offset_y, int max_frame){    // Offset, Hitbox and Frame Count update
     if (_prev_face != face){
+        frame.number = 0;
         hitbox.width = sprite_size.offset_y;
         hitbox.height = hitbox_height;
         sprite_size.width = sprite_size_width;
         sprite_size.height = sprite_size_height;
         sprite_size.offset_x = sprite_size_offset_x;
         sprite_size.offset_y = sprite_size_offset_y;
+        frame.max = max_frame;
     }
 }
 
@@ -66,19 +68,19 @@
     // Movement
     if (face == 0){
         position.y += velocity;
-        update_hitbox(4, 7, 0, 0, 6, 12, 1, 6);
+        update_hitbox(4, 7, 0, 0, 6, 12, 1, 6, 6);
     }
     else if (face == 1){
         position.x += velocity;
-        update_hitbox(7, 4, 0, 0, 12, 7, 3, 4);
+        update_hitbox(7, 4, 0, 0, 12, 7, 3, 4, 4);
     }
     else if (face == 2){
         position.y -= velocity;
-        update_hitbox(4, 7, 0, 0, 6, 12, 1, 5);
+        update_hitbox(4, 7, 0, 0, 6, 12, 1, 5, 6);
     }
     else if (face == 3){
         position.x -= velocity;
-        update_hitbox(7, 4, 0, 0, 12, 7, 2, 4);
+        update_hitbox(7, 4, 0, 0, 12, 7, 2, 4, 4);
     }
     
     undo_move_x(matrix_collision_test(position.x, prev_pos.y, 0));