Steven Mahasin / Mbed 2 deprecated DreamDungeon

Dependencies:   mbed MotionSensor

Files at this revision

API Documentation at this revision

Comitter:
el17sm
Date:
Thu May 09 08:02:07 2019 +0000
Parent:
52:7d05e5472022
Child:
54:03ddad11d202
Commit message:
Bullets commented

Changed in this revision

Entity/Player/Bullets/Bullets.cpp Show annotated file Show diff for this revision Revisions of this file
Entity/Player/Bullets/Bullets.h Show annotated file Show diff for this revision Revisions of this file
--- a/Entity/Player/Bullets/Bullets.cpp	Thu May 09 07:47:58 2019 +0000
+++ b/Entity/Player/Bullets/Bullets.cpp	Thu May 09 08:02:07 2019 +0000
@@ -1,29 +1,33 @@
 #include "Bullets.h"
 
+// Constructor
 Bullets::Bullets(float pos_x, float pos_y, int dir)
 {
-    face = 0;
+    face = dir;
     hp = 1;
+    
     hitbox.width = 3;
     hitbox.height = 3;
+    
     position.x = pos_x;
     position.y = pos_y;
+    
     sprite_size.width = 3;
     sprite_size.height = 3;
     sprite_size.offset_x = -1;
     sprite_size.offset_y = -4;
-    direction = dir;
 }
 
-void Bullets::move(float speed, float unused, char * unused2, bool * unused3)
+// Functions
+void Bullets::move(float speed, float unused, char * unused2, bool * unused3)   //  Moves regarding face(constant after constructed)
 {
-    if (direction == 0) {
+    if (face == 0) {
         position.y -= speed;
-    } else if (direction == 1) {
+    } else if (face == 1) {
         position.x += speed;
-    } else if (direction == 2) {
+    } else if (face == 2) {
         position.y += speed;
-    } else if (direction == 3) {
+    } else if (face == 3) {
         position.x -= speed;
     }
 }
@@ -34,15 +38,15 @@
                               position.y+sprite_size.offset_y,
                               sprite_size.height,
                               sprite_size.width,
-                              get_frame());
+                              (char *) bullets_sprite);
 }
 
-void Bullets::take_damage(int damage)
+void Bullets::take_damage(int damage)   // Taking damage, currently not used(has to be inherited, as well as useful for possible future use)
 {
     hp -= damage;
 }
 
-bool Bullets::out_of_bounds_check(char * map, bool * doorways)
+bool Bullets::out_of_bounds_check(char * map, bool * doorways)  // Returns true when bullets exit map or collide with walls
 {
     if (entity_to_map_collision_test(position.x, position.y, map, doorways)) {
         return true;
@@ -51,9 +55,4 @@
         return true;
     }
     return false;
-}
-
-char * Bullets::get_frame()
-{
-    return (char *) bullets_sprite;
 }
\ No newline at end of file
--- a/Entity/Player/Bullets/Bullets.h	Thu May 09 07:47:58 2019 +0000
+++ b/Entity/Player/Bullets/Bullets.h	Thu May 09 08:02:07 2019 +0000
@@ -14,12 +14,6 @@
     virtual void draw(N5110 &lcd);
     virtual void take_damage(int damage);
     bool out_of_bounds_check(char * map, bool * doorways);
-
-private:
-    // Private Functions
-    char * get_frame();
-    // Member Variable
-    int direction;
 };
 
 const char bullets_sprite[3][3] = {{1,1,1},