aboutsummaryrefslogtreecommitdiffstats
path: root/src
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
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 'src')
-rw-r--r--src/gameplay.cpp18
-rw-r--r--src/gameplay.hpp4
-rw-r--r--src/main.cpp23
-rw-r--r--src/window.hpp4
4 files changed, 35 insertions, 14 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);
}
diff --git a/src/gameplay.hpp b/src/gameplay.hpp
index 151b591..4ff3608 100644
--- a/src/gameplay.hpp
+++ b/src/gameplay.hpp
@@ -19,8 +19,8 @@ class Game {
void start() const ;
void draw() const ;
- void tick() const ;
- void getKeys() const ;
+ int tick() const ;
+ int getKeys() const ;
};
#endif // GAMEPLAY_H_
diff --git a/src/main.cpp b/src/main.cpp
index 20a6cdc..0912639 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,3 +1,12 @@
+/*********************************/
+/* THRESHOLD ( // */
+/* main ( )/ */
+/* by salade )(/ */
+/* ________________ ( /) */
+/* ()__)____________))))) :^} */
+/*********************************/
+
+
#include "window.hpp"
#include "gameplay.hpp"
#include <iostream>
@@ -28,6 +37,10 @@ int main(void) {
}
case (ENDING):
{
+ if (IsKeyPressed(KEY_ENTER))
+ {
+ gs = TITLE;
+ }
break ;
}
}
@@ -38,18 +51,22 @@ int main(void) {
switch (gs) {
case (TITLE):
{
- DrawText("LOGO SCREEN", 20, 20, 40, LIGHTGRAY);
+ DrawText("THRESHOLD", (SCREENWIDTH / 2) - 150, SCREENHEIGHT / 2, 40, RED);
+ DrawText("PRESS ENTER", (SCREENWIDTH / 2) - 150, (SCREENHEIGHT / 2) + 50, 40, MAROON);
break ;
}
case (GAMEPLAY):
{
- game->getKeys();
+ if (game->getKeys()) {
+ gs = ENDING;
+ }
game->draw();
break ;
}
case (ENDING):
{
- DrawText("GOOD BYE SCREEN", 20, 20, 40, LIGHTGRAY);
+ DrawCircle(SCREENWIDTH / 2, SCREENHEIGHT / 2, 200, BLACK);
+ DrawText("GOOD BYE", (SCREENWIDTH / 2) - 100, SCREENHEIGHT / 2, 40, WHITE);
break ;
}
}
diff --git a/src/window.hpp b/src/window.hpp
index 82abd2a..74fd3ec 100644
--- a/src/window.hpp
+++ b/src/window.hpp
@@ -5,8 +5,8 @@
int initWindow(void);
-#define SCREENWIDTH 800
-#define SCREENHEIGHT 450
+#define SCREENWIDTH 1600
+#define SCREENHEIGHT 900
typedef enum gameState {
TITLE = 0, GAMEPLAY, ENDING