Steven Mahasin / Mbed 2 deprecated DreamDungeon

Dependencies:   mbed MotionSensor

Files at this revision

API Documentation at this revision

Comitter:
el17sm
Date:
Tue May 07 12:42:12 2019 +0000
Parent:
39:0c2521949429
Child:
41:0697508a28ba
Commit message:
Restart Works

Changed in this revision

Entity/Bosses/Skull/Skull.cpp Show annotated file Show diff for this revision Revisions of this file
Entity/Player/Bullets/Bullets.cpp Show annotated file Show diff for this revision Revisions of this file
Entity/Player/Player.cpp Show annotated file Show diff for this revision Revisions of this file
Entity/Player/Player.h Show annotated file Show diff for this revision Revisions of this file
Entity/Walls/Walls.cpp Show annotated file Show diff for this revision Revisions of this file
Entity/Walls/Walls.h Show annotated file Show diff for this revision Revisions of this file
RoomEngine/Room/Room.cpp Show annotated file Show diff for this revision Revisions of this file
RoomEngine/Room/Room.h Show annotated file Show diff for this revision Revisions of this file
RoomEngine/RoomEngine.cpp Show annotated file Show diff for this revision Revisions of this file
RoomEngine/RoomEngine.h Show annotated file Show diff for this revision Revisions of this file
Title/Title.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/Entity/Bosses/Skull/Skull.cpp	Tue May 07 09:43:36 2019 +0000
+++ b/Entity/Bosses/Skull/Skull.cpp	Tue May 07 12:42:12 2019 +0000
@@ -2,7 +2,7 @@
 #include <complex>
 Skull::Skull(float pos_x, float pos_y)
 {
-    hp = 1;
+    hp = 25;
     attack = 1;
     
     _dash = false;
--- a/Entity/Player/Bullets/Bullets.cpp	Tue May 07 09:43:36 2019 +0000
+++ b/Entity/Player/Bullets/Bullets.cpp	Tue May 07 12:42:12 2019 +0000
@@ -11,7 +11,7 @@
     position.y = pos_y;
     sprite_size.width = 3;
     sprite_size.height = 3;
-    sprite_size.offset_x = 0;
+    sprite_size.offset_x = -1;
     sprite_size.offset_y = -1;
     direction = dir;
 }
--- a/Entity/Player/Player.cpp	Tue May 07 09:43:36 2019 +0000
+++ b/Entity/Player/Player.cpp	Tue May 07 12:42:12 2019 +0000
@@ -138,7 +138,6 @@
 void Player::draw(N5110 &lcd)
 {
     draw_player(lcd);
-    draw_bullets(lcd);
 }
 
 void Player::draw_player(N5110 &lcd)
@@ -150,10 +149,10 @@
                               get_frame());
 }
 
-void Player::draw_bullets(N5110 &lcd)
+void Player::draw_bullets(N5110 &lcd, int j)
 {
     for (int i = 0; i < bullets_max; i++) {
-        if (valid_bullets[i]) {
+        if ((valid_bullets[i]) && (bullets_array[i]->get_pos_y() == j)) {
             bullets_array[i]->draw(lcd);
         }
     }
--- a/Entity/Player/Player.h	Tue May 07 09:43:36 2019 +0000
+++ b/Entity/Player/Player.h	Tue May 07 12:42:12 2019 +0000
@@ -22,7 +22,6 @@
     void increment_frames(float mapped_x, float mapped_y);
     char * get_frame();
     void draw_player(N5110 &lcd);
-    void draw_bullets(N5110 &lcd);
     
 public:
     // Constructors
@@ -40,6 +39,7 @@
     virtual void move(float, float, char * map, bool * doorways);
     virtual void take_damage(int damage);
     virtual void draw(N5110 &lcd);
+    void draw_bullets(N5110 &lcd, int j);
     bool update_bullets(char * map, bool * doorways);
     void delete_bullets();
     void buttons(bool button_A, bool button_B, bool button_Y, bool button_X);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Entity/Walls/Walls.cpp	Tue May 07 12:42:12 2019 +0000
@@ -0,0 +1,45 @@
+//#include "Walls.h"
+//Walls::Walls(float pos_x, float pos_y)
+//{
+//    hp = 1;
+//    
+//    hitbox.width = 19;
+//    hitbox.height = 9;
+//    
+//    sprite_size.width = 21;
+//    sprite_size.height = 23;
+//    sprite_size.offset_x = -1;
+//    sprite_size.offset_y = -14;
+//    
+//    _shadow.width = 19;
+//    _shadow.height = 5;
+//    _shadow.offset_x = 0;
+//    _shadow.offset_y = 5;
+//    
+//    position.x = pos_x;
+//    position.y = pos_y;
+//    update_prev_pos();
+//    
+//    frame.count = 0;
+//    frame.number = 0;
+//    frame.max = 2;
+//    face = 2;
+//    
+//    velocity = 0.2;
+//    _hp_drop_chance = 100;
+//}
+//
+//void move(float unused, float unused1, char * unused2, bool * unused3) // movement control and miscellaneous updates
+//{
+//    ;
+//}
+//
+//void take_damage(int damage)
+//{
+//    
+//}
+//
+//void draw(N5110 &lcd)
+//{
+//    
+//}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Entity/Walls/Walls.h	Tue May 07 12:42:12 2019 +0000
@@ -0,0 +1,16 @@
+//#ifndef WALLS_H
+//#define WALLS_H
+//
+//class Walls : public Entity
+//{
+//public:
+//    // Constructor
+//    Walls(int pos_x, int pos_y, int hitbox_width, int hitbox_length);
+//    
+//    // Functions
+//    virtual void move(float unused, float unused1, char * unused2, bool * unused3); // movement control and miscellaneous updates
+//    virtual void take_damage(int damage);
+//    virtual void draw(N5110 &lcd);
+//}
+//
+//#endif
\ No newline at end of file
--- a/RoomEngine/Room/Room.cpp	Tue May 07 09:43:36 2019 +0000
+++ b/RoomEngine/Room/Room.cpp	Tue May 07 12:42:12 2019 +0000
@@ -22,6 +22,12 @@
     }
 }
 
+// Deconstructor
+Room::~Room()
+{
+    
+}
+
 void Room::init_normal_room(int no_of_enemies)
 {
     for (int id = 0; id < MAX_ENEMIES; id++) {
@@ -58,12 +64,6 @@
     }
 }
 
-// Deconstructor
-Room::~Room()
-{
-    terminate();
-}
-
 // Accessors
 char * Room::get_current_map_2d(){
     return ((char *)level_map[0][0]);
--- a/RoomEngine/Room/Room.h	Tue May 07 09:43:36 2019 +0000
+++ b/RoomEngine/Room/Room.h	Tue May 07 12:42:12 2019 +0000
@@ -7,6 +7,7 @@
 #include "Headless.h"
 #include "Snake.h"
 #include "Skull.h"
+#include "Walls.h"
 
 #include "N5110.h"
 
--- a/RoomEngine/RoomEngine.cpp	Tue May 07 09:43:36 2019 +0000
+++ b/RoomEngine/RoomEngine.cpp	Tue May 07 12:42:12 2019 +0000
@@ -1,16 +1,17 @@
 #include "RoomEngine.h"
 // Constructor
-RoomEngine::RoomEngine(float global_contrast)
+RoomEngine::RoomEngine(float global_contrast, Player *current_player)
 {
     _room_x = 5;
     _room_y = 5;
     _global_contrast = global_contrast;
+    current_player->set_position(39, 27);
 }
 
 // Destructor
 RoomEngine::~RoomEngine()
 {
-    delete player;
+    room->unload();
 }
 
 // Public Functions
@@ -409,6 +410,7 @@
         if (j == player->get_pos_y()) {
             player->draw(lcd);
         }
+        player->draw_bullets(lcd, j);
         room->draw_enemies(lcd, j);
         room->draw_collectibles(lcd, j);   
     }
--- a/RoomEngine/RoomEngine.h	Tue May 07 09:43:36 2019 +0000
+++ b/RoomEngine/RoomEngine.h	Tue May 07 12:42:12 2019 +0000
@@ -14,7 +14,7 @@
 {
 public:
     // Constructor
-    RoomEngine(float global_contrast);
+    RoomEngine(float global_contrast, Player *current_player);
     // Destructor
     ~RoomEngine();
     
--- a/Title/Title.cpp	Tue May 07 09:43:36 2019 +0000
+++ b/Title/Title.cpp	Tue May 07 12:42:12 2019 +0000
@@ -38,6 +38,7 @@
             title_option_hi_scores(lcd);
         }
     }
+    player.~Player();
 }
 
 void Title::draw_title_screen(N5110 &lcd)
@@ -84,6 +85,7 @@
         lcd.printString("using the", 0, 1);
         lcd.printString("potentiometer", 0, 2);
         player.draw(lcd);
+        player.draw_bullets(lcd, player.get_pos_y() - 2);
         lcd.refresh();
         player.move(1, 0, (char *)level_map[0][0], (bool *)sprite_transparent_player);
         player.buttons(false, true, false, false);
--- a/main.cpp	Tue May 07 09:43:36 2019 +0000
+++ b/main.cpp	Tue May 07 12:42:12 2019 +0000
@@ -50,14 +50,18 @@
     while(1) { // Gameloop
         
         title.main(lcd, gamepad, global_contrast);
-        delete player;
         
         srand(title.get_seed());
         player = new Player(39, 27);
-        room_engine = new RoomEngine(global_contrast);
+        room_engine = new RoomEngine(global_contrast, player);
         
         game_loop();
         game_over();
+        for (int i = 0; i < MAX_ROOMS_MAP_X; i++) {
+                for (int j = 0; j < MAX_ROOMS_MAP_Y; j++) {
+                    delete rooms[j][i];
+                }
+            }
         delete room_engine;
         delete player;
     }
@@ -105,7 +109,6 @@
                 lcd.printString("Game Over", 0, 0);
                 lcd.printString("Retry?", 0, 1);
                 lcd.refresh();
-                wait(0.05);
                 while(!gamepad.check_event(Gamepad::A_PRESSED)) {
                 }
                 wait(0.05);