From 418452ccc933dc66609d98d5efd5e753f02f0211 Mon Sep 17 00:00:00 2001 From: salaaad2 Date: Tue, 4 Jan 2022 15:02:05 +0100 Subject: release v0.0.1 --- src/gameplay.cpp | 10 +++++++--- src/main.cpp | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gameplay.cpp b/src/gameplay.cpp index 979dd6a..16fc240 100644 --- a/src/gameplay.cpp +++ b/src/gameplay.cpp @@ -94,10 +94,14 @@ int Game::getKeys() const player->direction = Vector2Rotate(player->direction, 0.1f); } if (IsKeyPressed(KEY_SPACE)) { - for (auto & en : *enemies) + for (auto en = enemies->begin(); en != enemies->end(); en++) { - if (CheckCollisionPointLine((Vector2){en.posX, en.posY}, (Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, player->direction), 20)) - std::cout << "hit enemy at " << en.posX << "|" << en.posY << std::endl; + if (CheckCollisionPointLine((Vector2){en->posX, en->posY}, (Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, player->direction), 20)) + { + std::cout << "hit enemy at " << en->posX << "|" << en->posY + << std::endl; + enemies->erase(en); + } } DrawLineEx((Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, player->direction), 20, RED); diff --git a/src/main.cpp b/src/main.cpp index 0912639..b4525c2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,6 +40,8 @@ int main(void) { if (IsKeyPressed(KEY_ENTER)) { gs = TITLE; + delete game; + game = new Game; } break ; } -- cgit v1.2.3