aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorsalaaad2 <arthurdurant263@gmail.com>2022-01-14 01:49:11 +0100
committersalaaad2 <arthurdurant263@gmail.com>2022-01-14 01:49:11 +0100
commit42a5777b370853f8957c101956a300d7991977e5 (patch)
treea1092b8e45358accbeff2926f28ca4b4967c6190 /src
parentbackground can now be specified in map file (diff)
downloadthreshold-42a5777b370853f8957c101956a300d7991977e5.tar.gz
threshold-42a5777b370853f8957c101956a300d7991977e5.tar.bz2
threshold-42a5777b370853f8957c101956a300d7991977e5.tar.xz
threshold-42a5777b370853f8957c101956a300d7991977e5.tar.zst
threshold-42a5777b370853f8957c101956a300d7991977e5.zip
add license, better next screen and begin savestate
Diffstat (limited to 'src')
-rw-r--r--src/gameplay.cpp12
-rw-r--r--src/gameplay.hpp3
-rw-r--r--src/main.cpp24
3 files changed, 22 insertions, 17 deletions
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index dd395ca..ba1c07a 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -102,11 +102,6 @@ Game::Game(std::string const& path) : current(path) {
crosshair = LoadTexture(CROSSHAIR_TEX);
- cam.target = (Vector2){player->posX, player->posY};
- cam.offset = (Vector2){SCREENWIDTH / 2.0f, SCREENHEIGHT / 2.0f};
- cam.rotation = 0.0f;
- cam.zoom = 1.0f;
-
player->wp[0] = shotty;
player->wp[1] = ar;
player->currentWeapon = player->wp[0];
@@ -135,11 +130,8 @@ void Game::start() {
void Game::draw() {
auto left = std::to_string(enemies->size());
- cam.target.x = player->posX;
- EndMode2D();
for (auto& en : *enemies) {
- DrawCircle(en.posX, en.posY, en.radius, GREEN);
if (en.hp == 0)
DrawTextureEx(en.hurtTex, (Vector2){en.posX - 20, en.posY - 20},
1.0f, 0.6f, WHITE);
@@ -342,3 +334,7 @@ std::string const& Game::getCurrent() const {
std::string const& Game::getBackground() const {
return background;
}
+
+int const& Game::getKills() const {
+ return player->victims;
+}
diff --git a/src/gameplay.hpp b/src/gameplay.hpp
index 62103f4..4f16504 100644
--- a/src/gameplay.hpp
+++ b/src/gameplay.hpp
@@ -74,8 +74,6 @@ class Game {
Game(std::string const& path);
~Game();
- Camera2D cam;
-
void start();
void draw();
int tick() ;
@@ -86,6 +84,7 @@ class Game {
std::string const& getNext() const; // returns next level's string
std::string const& getCurrent() const; // returns next level's string
std::string const& getBackground() const; // returns next level's string
+ int const& getKills() const; // returns next level's string
};
#endif // GAMEPLAY_H_
diff --git a/src/main.cpp b/src/main.cpp
index 56ad3e5..ab6e60c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -8,6 +8,7 @@
#include <raylib.h> // basic libs
#include <iostream>
+#include <fstream>
#include "gameplay.hpp"
#include "window.hpp"
@@ -24,6 +25,7 @@ int main(void) {
auto nPick = 0;
Texture2D background;
Game* game = nullptr;
+ std::ofstream ifs("../meta/maps/savestate");
std::string path = "../meta/maps";
@@ -81,6 +83,7 @@ int main(void) {
if (IsKeyPressed(KEY_ENTER)) {
std::string next("../meta/maps/");
next += game->getNext();
+ ifs << game->getCurrent() ;
delete game;
CloseAudioDevice();
@@ -153,17 +156,23 @@ int main(void) {
gs = NEXT;
}
}
- BeginMode2D(game->cam);
+ // BeginMode2D(game->cam); // I think this might be useless
+ // NOTE: it was lol
game->draw();
break;
}
case (NEXT): {
- DrawCircle(SCREENWIDTH / 2, SCREENHEIGHT / 2, 200, BLACK);
- DrawText("STAGE CLEARED\nNEXT LEVEL :",
- (SCREENWIDTH / 2) - 200, 200, 40,
- WHITE);
- DrawText(game->getNext().c_str(), (SCREENWIDTH / 2) - 100,
- (SCREENHEIGHT / 2) + 60, 40, WHITE);
+ ClearBackground(COOLPURPLE);
+ DrawRectangle(200, 100, 1200, 700, RAYWHITE);
+ DrawRectangle(250, 150, 1100, 600, COOLPURPLE);
+ DrawRectangle(300, 200, 1000, 500, RAYWHITE);
+ DrawText("THRESHOLD", 260, 160, 30, RAYWHITE);
+ DrawText("CONGRATULATIONS\n", 350, 240, 30, COOLPURPLE);
+ DrawText("KILLS :", 350, 280, 30, COOLPURPLE);
+ auto kills = std::to_string(game->getKills()).c_str();
+ DrawText(kills, 460, 280, 30, RED);
+ DrawText("TIME\n", 350, 320, 30, COOLPURPLE);
+
break;
}
case (ENDING): {
@@ -175,6 +184,7 @@ int main(void) {
}
EndDrawing();
}
+ ifs.close();
CloseWindow();
return 0;
}