aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsalaaad2 <arthurdurant263@gmail.com>2022-01-14 01:19:37 +0100
committersalaaad2 <arthurdurant263@gmail.com>2022-01-14 01:19:37 +0100
commit05314c67655e5030d89e85087fba0a699d8a4ba7 (patch)
tree4a955061ede8fc39dfc74272a0062e6aa6fd7236
parentshit background image featureing hit-- bowser. I meant bowser... (diff)
downloadthreshold-05314c67655e5030d89e85087fba0a699d8a4ba7.tar.gz
threshold-05314c67655e5030d89e85087fba0a699d8a4ba7.tar.bz2
threshold-05314c67655e5030d89e85087fba0a699d8a4ba7.tar.xz
threshold-05314c67655e5030d89e85087fba0a699d8a4ba7.tar.zst
threshold-05314c67655e5030d89e85087fba0a699d8a4ba7.zip
background can now be specified in map file
-rw-r--r--meta/maps/stage_1_start.bfm1
-rw-r--r--src/gameplay.cpp8
-rw-r--r--src/gameplay.hpp2
-rw-r--r--src/main.cpp9
4 files changed, 15 insertions, 5 deletions
diff --git a/meta/maps/stage_1_start.bfm b/meta/maps/stage_1_start.bfm
index 91ca04e..de9023d 100644
--- a/meta/maps/stage_1_start.bfm
+++ b/meta/maps/stage_1_start.bfm
@@ -2,3 +2,4 @@ BOSS 0 0
ENEMIES 10 20
WAVES 2 5
NEXT stage_1_1.bfm
+BACKGROUND ../meta/media/sprites/background.png
diff --git a/src/gameplay.cpp b/src/gameplay.cpp
index 88da5ec..dd395ca 100644
--- a/src/gameplay.cpp
+++ b/src/gameplay.cpp
@@ -54,6 +54,10 @@ Game::Game(std::string const& path) : current(path) {
ifs >> tok;
nPerWave = std::atoi(tok.c_str());
}
+ if (tok == "BACKGROUND") {
+ ifs >> tok;
+ background = tok;
+ }
}
ifs.close();
enemies = new std::vector<Entity>;
@@ -334,3 +338,7 @@ std::string const& Game::getNext() const {
std::string const& Game::getCurrent() const {
return current;
}
+
+std::string const& Game::getBackground() const {
+ return background;
+}
diff --git a/src/gameplay.hpp b/src/gameplay.hpp
index 7567efc..62103f4 100644
--- a/src/gameplay.hpp
+++ b/src/gameplay.hpp
@@ -58,6 +58,7 @@ class Game {
std::string next; // next level
std::string current; // next level
+ std::string background; // next level
int frameWidth;
int frameHeight;
@@ -84,6 +85,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
};
#endif // GAMEPLAY_H_
diff --git a/src/main.cpp b/src/main.cpp
index 5d7c3be..56ad3e5 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -22,11 +22,10 @@ int main(void) {
initWindow();
InitWindow(SCREENWIDTH, SCREENHEIGHT, "WIP -- muchashooter THRESHOLD");
auto nPick = 0;
-
+ Texture2D background;
Game* game = nullptr;
- Texture2D background = LoadTexture("../meta/media/sprites/background.png");
std::string path = "../meta/maps";
int i = 0;
for (const auto& entry :
@@ -53,6 +52,7 @@ int main(void) {
s += "/";
s += pick[nPick];
game = new Game(s);
+ background = LoadTexture(game->getBackground().c_str());
gs = GAMEPLAY;
game->start();
}
@@ -158,10 +158,9 @@ int main(void) {
break;
}
case (NEXT): {
- ClearBackground(COOLPURPLE);
DrawCircle(SCREENWIDTH / 2, SCREENHEIGHT / 2, 200, BLACK);
- DrawText("STAGE CLEARED\nNEXT LEVEL :\n",
- (SCREENWIDTH / 2) - 200, (SCREENHEIGHT / 2) - 50, 40,
+ DrawText("STAGE CLEARED\nNEXT LEVEL :",
+ (SCREENWIDTH / 2) - 200, 200, 40,
WHITE);
DrawText(game->getNext().c_str(), (SCREENWIDTH / 2) - 100,
(SCREENHEIGHT / 2) + 60, 40, WHITE);