diff --git a/src/components.h b/src/components.h index 23f3eeb..d0c9d8c 100644 --- a/src/components.h +++ b/src/components.h @@ -15,10 +15,6 @@ class Entity{ virtual void process() {} virtual void draw() const {} virtual void tick() {} - virtual void collision(Entity* with) {} - void queue_free(); - private: - bool free_queued; }; @@ -40,7 +36,6 @@ class Pacman : public Entity{ void process() override; void animation_tick(); void draw() const override; - void collision(Entity* with) override; }; class Wall : public Entity { diff --git a/src/entity.cpp b/src/entity.cpp deleted file mode 100644 index 7df294f..0000000 --- a/src/entity.cpp +++ /dev/null @@ -1,17 +0,0 @@ -#include "components.h" -#include "world.h" - -void Entity::queue_free() { - if (this->free_queued) - return; - - this->free_queued = true; - World& world = get_world(); - - for(int i = 0; i < world.entities.size(); i++) - if(world.entities[i] == this) { - delete world.entities[i]; - world.entities.erase(world.entities.begin()+i); - break; - } -} diff --git a/src/pacman.cpp b/src/pacman.cpp index c1b4755..e8a958f 100644 --- a/src/pacman.cpp +++ b/src/pacman.cpp @@ -37,7 +37,7 @@ void Pacman::tick() { World& world = get_world(); - if (dynamic_cast(world.grid[indexify_position(new_position)]) == nullptr){ + if (world.grid[indexify_position(new_position)] == nullptr){ this->position=new_position; } @@ -73,12 +73,5 @@ void Pacman::draw() const { DrawTextureRec(this->texture.get_texture(), this->getTextureRect(), this->position, WHITE); } -void Pacman::collision(Entity* with){ - Scorepoint* score = dynamic_cast(with); - if (score != nullptr) { - score->queue_free(); - } - -} diff --git a/src/wall.cpp b/src/wall.cpp index 87f5db7..e3c3f05 100644 --- a/src/wall.cpp +++ b/src/wall.cpp @@ -1,8 +1,10 @@ #include "components.h" #include "world.h" +#include #include Wall::Wall() { + std::cout << get_world().get_atlas() <<'\n'; this->texture = TextureAtlas(get_world().get_atlas(),0,64,16,16); } diff --git a/src/world.cpp b/src/world.cpp index e03690b..2577a32 100644 --- a/src/world.cpp +++ b/src/world.cpp @@ -92,13 +92,6 @@ void World::update_grid() { int indexified_position = indexify_position(this->entities[i]->position); if (indexified_position < 0 || indexified_position >= GRID_CAPACITY) continue; - if(grid[indexified_position] != nullptr){ - Entity* entity = this->entities[i]; - grid[indexified_position]->collision(entity); - if(entity != nullptr && grid[indexified_position] != nullptr && grid[indexified_position] != entity){ - entity->collision(grid[indexified_position]); - } - } grid[indexified_position] = this->entities[i]; } }