diff --git a/Assignment3Project/Assignment3Project/Assignment3Project.vcxproj b/Assignment3Project/Assignment3Project/Assignment3Project.vcxproj index 5f5ccd1..cf9b104 100644 --- a/Assignment3Project/Assignment3Project/Assignment3Project.vcxproj +++ b/Assignment3Project/Assignment3Project/Assignment3Project.vcxproj @@ -146,7 +146,6 @@ - @@ -158,7 +157,6 @@ - diff --git a/Assignment3Project/Assignment3Project/Assignment3Project.vcxproj.filters b/Assignment3Project/Assignment3Project/Assignment3Project.vcxproj.filters index dfbe102..cac8692 100644 --- a/Assignment3Project/Assignment3Project/Assignment3Project.vcxproj.filters +++ b/Assignment3Project/Assignment3Project/Assignment3Project.vcxproj.filters @@ -63,9 +63,6 @@ Header Files\Engine - - Header Files\Engine - @@ -92,9 +89,6 @@ Source Files\EngineImplement - - Source Files\EngineImplement - diff --git a/Assignment3Project/Assignment3Project/game_screen.cpp b/Assignment3Project/Assignment3Project/game_screen.cpp index 63a227a..26def4b 100644 --- a/Assignment3Project/Assignment3Project/game_screen.cpp +++ b/Assignment3Project/Assignment3Project/game_screen.cpp @@ -223,23 +223,8 @@ void GameScreen::run(ALLEGRO_FONT* font) { //Redraw all elements of the screen void GameScreen::redraw(ALLEGRO_FONT* font) { //MapDrawBG(0, map_y, 0, SCREEN_L_B, SCREEN_W - 80, SCREEN_H); - - objects.player->draw(); - - vector unload; - for (unsigned int i = 0; i < objects.player_bullets.size(); i++) { - if (objects.player_bullets.at(i)->oob) { - unload.push_back(i); - } - else { - objects.player_bullets.at(i)->move(U); - objects.player_bullets.at(i)->draw(); - } - } - for (unsigned int i = 0; i < unload.size(); i++) { - int x = unload.at(i); - objects.player_bullets.erase(objects.player_bullets.begin() + x); - } + + objects.draw_objects(); } void GameScreen::back() { diff --git a/Assignment3Project/Assignment3Project/object_manager.cpp b/Assignment3Project/Assignment3Project/object_manager.cpp index 7404ad7..de6989f 100644 --- a/Assignment3Project/Assignment3Project/object_manager.cpp +++ b/Assignment3Project/Assignment3Project/object_manager.cpp @@ -1,5 +1,7 @@ #include "object_manager.h" +using std::vector; + ObjectManager::ObjectManager() { } @@ -15,3 +17,23 @@ bool ObjectManager::chk_player_col() { int ObjectManager::chk_bullet_col() { return 0; } + +void ObjectManager::draw_objects() +{ + player->draw(); + + bool unload = false; + for (unsigned int i = 0; i < player_bullets.size(); i++) { + if (player_bullets.at(i)->oob) { + unload = true; + } + else { + player_bullets.at(i)->move(U); + player_bullets.at(i)->draw(); + } + } + if (unload) { + player_bullets.pop_back(); + } +} + diff --git a/Assignment3Project/Assignment3Project/object_manager.h b/Assignment3Project/Assignment3Project/object_manager.h index 88fe0fb..72ad32b 100644 --- a/Assignment3Project/Assignment3Project/object_manager.h +++ b/Assignment3Project/Assignment3Project/object_manager.h @@ -17,4 +17,5 @@ public: void initiate(Ship* _player); bool chk_player_col(); int chk_bullet_col(); + void draw_objects(); }; \ No newline at end of file