diff --git a/source/gamestate_menu.cpp b/source/gamestate_menu.cpp index cb42031..fa216c7 100644 --- a/source/gamestate_menu.cpp +++ b/source/gamestate_menu.cpp @@ -5,6 +5,13 @@ namespace gamestate { namespace menu { + namespace eixir + { + const int no = 0; + const int sequence = 1; + const int password = 2; + } + draw::surface *fondo = nullptr; draw::surface *cursor = nullptr; int exit = 0; @@ -32,8 +39,8 @@ namespace gamestate if (!draw::isfading()) { draw::freeSurface(fondo); draw::freeSurface(cursor); - if (exit==1) gamestate::sequence::init(); - //if (exit==2) gamestate::password::init(); + if (exit==menu::eixir::sequence) gamestate::sequence::init(); + //if (exit==menu::eixir::password) gamestate::password::init(); } draw::render(); return true; @@ -53,12 +60,12 @@ namespace gamestate if (x >= 200 && y >= 100 && x <= 270 && y <= 120) { draw::fadeout(); game::setConfig("fase", 0); - exit = 1; + exit = menu::eixir::sequence; return true; } else if (x >= 175 && y >= 125 && x <= 290 && y <= 145) { draw::fadeout(); game::setConfig("fase", 0); - exit = 2; + exit = menu::eixir::password; return true; } else if (x >= 200 && y >= 150 && x <= 265 && y <= 170) { return false; diff --git a/source/gamestate_mort.cpp b/source/gamestate_mort.cpp new file mode 100644 index 0000000..632f97b --- /dev/null +++ b/source/gamestate_mort.cpp @@ -0,0 +1,75 @@ +#include "gamestates.h" +#include "jgame.h" + +namespace gamestate +{ + namespace mort + { + namespace eixir + { + const int no = 0; + const int prefase = 1; + const int menu = 2; + } + + draw::surface *fondo = nullptr; + draw::surface *cursor = nullptr; + int exit = 0; + + bool loop(); + + void init() + { + exit = mort::eixir::no; + fondo = draw::loadSurface("mort.gif", true); + cursor = draw::loadSurface("cursor.gif"); + + audio::playMusic(audio::loadMusic("mus5.ogg")); + + draw::fadein(); + + game::setState(&gamestate::mort::loop); + } + + bool loop() + { + if (exit) { + if (!draw::isfading()) { + draw::freeSurface(fondo); + draw::freeSurface(cursor); + if (exit==mort::eixir::prefase) gamestate::prefase::init(); + if (exit==mort::eixir::menu) gamestate::menu::init(); + } + draw::render(); + return true; + } + const int x = input::mouseX(); + const int y = input::mouseY(); + + draw::draw(fondo); + + draw::setSource(cursor); + draw::draw(x, y); + + draw::render(); + + if (input::mouseClk(1)) + { + if (x >= 100 && y >= 50 && x <= 210 && y <= 70) { + draw::fadeout(); + exit = mort::eixir::prefase; + return true; + } else if (x >= 120 && y >= 72 && x <= 190 && y <= 95) { + draw::fadeout(); + exit = mort::eixir::menu; + return true; + } else if (x >= 120 && y >= 95 && x <= 190 && y <= 115) { + return false; + } + } + + return true; + } + + } +} \ No newline at end of file diff --git a/source/gamestate_play.cpp b/source/gamestate_play.cpp index cd7faf8..b4f7ebd 100644 --- a/source/gamestate_play.cpp +++ b/source/gamestate_play.cpp @@ -94,7 +94,7 @@ namespace gamestate // I anem on toque if (play::exit==play::eixir::postfase) gamestate::postfase::init(); - // [TODO] else if (play::exit==play::eixir::mort) gamestate::mort::init(); + else if (play::exit==play::eixir::mort) gamestate::mort::init(); } // En qualsevol cas, renderitzem i eixim ja del bucle (fins que acabe el fadeout) draw::render(); diff --git a/source/gamestates.h b/source/gamestates.h index add1918..0bc56be 100644 --- a/source/gamestates.h +++ b/source/gamestates.h @@ -7,4 +7,5 @@ namespace gamestate namespace prefase { void init(); } namespace play { void init(); } namespace postfase { void init(); } + namespace mort { void init(); } }