aboutsummaryrefslogtreecommitdiffstats
path: root/src/gameplay.cpp
diff options
context:
space:
mode:
authorsalaaad2 <arthurdurant263@gmail.com>2022-01-04 17:57:03 +0100
committersalaaad2 <arthurdurant263@gmail.com>2022-01-04 17:57:03 +0100
commit93cb5d260de89da61ee0ffc7478dd0cd2f5e7011 (patch)
tree6fc702d8b2baf27c4a821f6f2bbcde7bb5c71c65 /src/gameplay.cpp
parentdumb pellet implementation (diff)
downloadthreshold-93cb5d260de89da61ee0ffc7478dd0cd2f5e7011.tar.gz
threshold-93cb5d260de89da61ee0ffc7478dd0cd2f5e7011.tar.bz2
threshold-93cb5d260de89da61ee0ffc7478dd0cd2f5e7011.tar.xz
threshold-93cb5d260de89da61ee0ffc7478dd0cd2f5e7011.tar.zst
threshold-93cb5d260de89da61ee0ffc7478dd0cd2f5e7011.zip
cool fury !
Diffstat (limited to 'src/gameplay.cpp')
-rw-r--r--src/gameplay.cpp36
1 files changed, 27 insertions, 9 deletions
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index f04d2ef..decbd74 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -56,7 +56,7 @@ void Game::start() const
void Game::draw() const
{
- auto left = std::to_string(nEnemies);
+ auto left = std::to_string(enemies->size());
for (auto & en : *enemies)
{
DrawCircleV((Vector2){en.posX, en.posY}, en.radius, RED);
@@ -64,6 +64,9 @@ void Game::draw() const
DrawCircleV((Vector2){player->posX, player->posY}, 10, GREEN);
DrawText("Enemies left : ", 10, 10, 20, GREEN);
DrawText(left.c_str(), 150, 10, 20,RED);
+ if (player->victims >= 5) {
+ DrawText("[E] FURY", SCREENWIDTH - 150, 10, 50, RED);
+ }
}
@@ -111,6 +114,9 @@ int Game::getKeys() const
player->posX += 4;
player->posY += 0;
}
+ if (player->victims >= 5 && IsKeyDown(KEY_E)) {
+ player->threshold = true;
+ }
if (IsKeyDown(KEY_LEFT)) {
player->direction = Vector2Rotate(player->direction, -0.1f); // left
}
@@ -120,24 +126,36 @@ int Game::getKeys() const
if (IsKeyPressed(KEY_SPACE)) {
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), (en->radius * 2)))
+ if (CheckCollisionPointLine((Vector2){en->posX, en->posY}, (Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, Vector2Rotate(player->direction, -0.2f)), (en->radius * 2)) ||
+ CheckCollisionPointLine((Vector2){en->posX, en->posY}, (Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, Vector2Rotate(player->direction, 0.0f)), (en->radius * 2)) ||
+ CheckCollisionPointLine((Vector2){en->posX, en->posY}, (Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, Vector2Rotate(player->direction, 0.2f)), (en->radius * 2)))
{
std::cout << "hit enemy at " << en->posX << "|" << en->posY
<< std::endl;
enemies->erase(en);
+ player->victims++;
return (0);
}
}
- DrawLineEx((Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, (Vector2){player->direction.x + 15, player->direction.y + 15}), 10, ORANGE);
- DrawLineEx((Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, (Vector2){player->direction.x + 7, player->direction.y + 7}), 10, ORANGE);
+ DrawLineEx((Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, Vector2Rotate(player->direction, -0.2f)), 10, ORANGE);
DrawLineEx((Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, player->direction), 10, ORANGE);
- DrawLineEx((Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, (Vector2){player->direction.x - 7, player->direction.y - 7}), 10, ORANGE);
- DrawLineEx((Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, (Vector2){player->direction.x - 15, player->direction.y - 15}), 10, ORANGE);
+ DrawLineEx((Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, Vector2Rotate(player->direction, 0.2f)), 10, ORANGE);
}
- if (this->tick()) {
- return (1);
+ if (player->threshold)
+ {
+ if (oldX != player->posX ||
+ oldY != player->posY)
+ {
+ if (this->tick()) {
+ return (1);
+ }
+ }
+ } else {
+ if (this->tick()) {
+ return (1);
+ }
}
+
aimer.x = (player->direction.x / 3);
aimer.y = (player->direction.y / 3);
DrawLineEx((Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, aimer), 5, GREEN);