Skip to content

Commit

Permalink
Win and lose condition!
Browse files Browse the repository at this point in the history
  • Loading branch information
42yeah committed Feb 28, 2020
1 parent 8908a8c commit a85016a
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
58 changes: 58 additions & 0 deletions Shear3D/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void Game::init() {
hallucinating = 0.0f;
luciferiumFlipper = 1.0f;
stuck = true;
won = false;
}

void Game::clear() {
Expand All @@ -79,6 +80,9 @@ void Game::clear() {
}

void Game::render() {
if (day >= 365 || won) {
return;
}
// std::cout << camera.position.x << ", " << camera.position.y << ", " << camera.position.z << std::endl;
glViewport(0, 0, windowSize.x, windowSize.y);
renderPass.use();
Expand Down Expand Up @@ -726,6 +730,15 @@ void Game::escape(bool es) {
}

void Game::renderGUI() {
if (day >= 365) {
escape(escaping = true);
lose();
return;
} else if (won) {
escape(escaping = true);
win();
return;
}
float y = 10.0f;
bool open = true;
for (int i = 0; i < notifications.size(); i++) {
Expand Down Expand Up @@ -1267,6 +1280,51 @@ void Game::load() {
fclose(file);
}

void Game::lose() {
ImGui::SetNextWindowPos(ImVec2(100.0f, 100.0f), ImGuiCond_FirstUseEver);
ImGui::SetNextWindowSize(ImVec2(400.0f, 300.0f), ImGuiCond_FirstUseEver);
ImGui::Begin("LOSE");
ImGui::Text("After 365 days, you failed to fullfill your promise...");
ImGui::Text("And you've lost your game! Don't worry, you will be better luck next time :D");
ImGui::Text("Here's your latest inventory:");
for (int i = 0; i < items.size(); i++) {
ImGui::Text("%s", items[i].getItemName(true).c_str());
}
ImGui::Separator();
ImGui::Text("Credits:");
ImGui::Text("Creator:\n- Me! (42yeah)");
ImGui::Text("Playtesting:\n- Zambon21\n- Penegrine\n- Some other online good peoples\n- And you!");
ImGui::Separator();
ImGui::Text("Thank you for playing!");
if (ImGui::Button("Awww.")) {
exit(0);
}
ImGui::End();
}

void Game::win() {
ImGui::SetNextWindowPos(ImVec2(100.0f, 100.0f), ImGuiCond_FirstUseEver);
ImGui::SetNextWindowSize(ImVec2(400.0f, 300.0f), ImGuiCond_FirstUseEver);
ImGui::Begin("WIN!");
ImGui::Text("You WIN the game!\nOh my god! I didn't even get to win it once!");
ImGui::Text("You are at your %d day of promise fullfillment", day);
ImGui::Text("When you win, those things are in your inventory:");
for (int i = 0; i < items.size(); i++) {
ImGui::Text("%s", items[i].getItemName(true).c_str());
}
ImGui::Text("And of course, 1000 fecking eggs!");
ImGui::Separator();
ImGui::Text("Credits:");
ImGui::Text("Creator:\n- Me! (42yeah)");
ImGui::Text("Playtesting:\n- Zambon21\n- Penegrine\n- Some other online good peoples\n- And you!");
ImGui::Separator();
ImGui::Text("Thank you Amsterdam! Good night!");
if (ImGui::Button("Horray!")) {
exit(0);
}
ImGui::End();
}


int distrib = 0;

Expand Down
3 changes: 3 additions & 0 deletions Shear3D/Game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class Game {
void save();
void load();
void escape(bool es);
void win();
void lose();

private:
friend class Item;
Expand Down Expand Up @@ -123,6 +125,7 @@ class Game {
std::vector<Notification> notifications;
std::vector<Notification> mails;
std::vector<Item> items;
bool won;

// === LOW VALUES === //
double time;
Expand Down
4 changes: 4 additions & 0 deletions Shear3D/Monster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1083,6 +1083,10 @@ void Monster::interact(Game *game) {
if (id == 11 && conversationId == 3) {
game->jail("You were found beating the beggar up.");
}
if (id == 2 && rampIndex == 1 && conversationId == 3) {
// WIN CONDITION
game->won = true;
}
if (begging) {
game->notifications.push_back(Notification("Won't let go", "The beggar won't let you go!", true, 10.0f));
} else {
Expand Down

0 comments on commit a85016a

Please sign in to comment.