diff options
author | salaaad2 <arthurdurant263@gmail.com> | 2022-01-04 15:02:05 +0100 |
---|---|---|
committer | salaaad2 <arthurdurant263@gmail.com> | 2022-01-04 15:02:05 +0100 |
commit | 418452ccc933dc66609d98d5efd5e753f02f0211 (patch) | |
tree | a585565e71f9af187009d6dd549c9b35afc9f199 /src/gameplay.cpp | |
parent | start menu and retry (diff) | |
download | threshold-418452ccc933dc66609d98d5efd5e753f02f0211.tar.gz threshold-418452ccc933dc66609d98d5efd5e753f02f0211.tar.bz2 threshold-418452ccc933dc66609d98d5efd5e753f02f0211.tar.xz threshold-418452ccc933dc66609d98d5efd5e753f02f0211.tar.zst threshold-418452ccc933dc66609d98d5efd5e753f02f0211.zip |
release v0.0.1
Diffstat (limited to 'src/gameplay.cpp')
-rw-r--r-- | src/gameplay.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
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); |