aboutsummaryrefslogtreecommitdiffstats
path: root/src/gameplay.cpp
diff options
context:
space:
mode:
authorsalaaad2 <arthurdurant263@gmail.com>2022-01-04 14:41:22 +0100
committersalaaad2 <arthurdurant263@gmail.com>2022-01-04 14:41:22 +0100
commitb99e5b1d2c6ccef7e9a714d2d4bcef050b99ff01 (patch)
treef5c5dd1b839568bd13ab9a94b81dd04bcfcc3649 /src/gameplay.cpp
parentshooting is fun hahahahahaha (diff)
downloadthreshold-b99e5b1d2c6ccef7e9a714d2d4bcef050b99ff01.tar.gz
threshold-b99e5b1d2c6ccef7e9a714d2d4bcef050b99ff01.tar.bz2
threshold-b99e5b1d2c6ccef7e9a714d2d4bcef050b99ff01.tar.xz
threshold-b99e5b1d2c6ccef7e9a714d2d4bcef050b99ff01.tar.zst
threshold-b99e5b1d2c6ccef7e9a714d2d4bcef050b99ff01.zip
start menu and retry
Diffstat (limited to '')
-rw-r--r--src/gameplay.cpp18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 2a208ee..979dd6a 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -6,9 +6,7 @@
Game::Game(void)
{
- // nEnemies = GetRandomValue(5, 15);
-
- nEnemies = 4;
+ nEnemies = 9;
enemies = new std::vector<Entity>(nEnemies);
player = new Entity;
@@ -43,7 +41,7 @@ void Game::draw() const
}
-void Game::tick() const
+int Game::tick() const
{
for (auto & en : *enemies)
{
@@ -60,11 +58,13 @@ void Game::tick() const
if (CheckCollisionCircles((Vector2){player->posX, player->posY}, 10,
(Vector2){en.posX, en.posY}, 10)) {
std::cout << "you died" << std::endl;
+ return (1);
}
}
+ return (0);
}
-void Game::getKeys() const
+int Game::getKeys() const
{
auto oldX = 0, oldY = 0;
auto aimer = player->direction;
@@ -102,11 +102,15 @@ void Game::getKeys() const
DrawLineEx((Vector2){player->posX, player->posY}, Vector2Add((Vector2){player->posX, player->posY}, player->direction), 20, RED);
}
- if (oldX != player->posX || oldY != player->posY)
+ if (oldX != player->posX ||
+ oldY != player->posY)
{
- this->tick();
+ 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);
+ return (0);
}