- [NEW] gamestate_mort
- Millorades les constants en gamestate_menu
This commit is contained in:
@@ -5,6 +5,13 @@ namespace gamestate
|
|||||||
{
|
{
|
||||||
namespace menu
|
namespace menu
|
||||||
{
|
{
|
||||||
|
namespace eixir
|
||||||
|
{
|
||||||
|
const int no = 0;
|
||||||
|
const int sequence = 1;
|
||||||
|
const int password = 2;
|
||||||
|
}
|
||||||
|
|
||||||
draw::surface *fondo = nullptr;
|
draw::surface *fondo = nullptr;
|
||||||
draw::surface *cursor = nullptr;
|
draw::surface *cursor = nullptr;
|
||||||
int exit = 0;
|
int exit = 0;
|
||||||
@@ -32,8 +39,8 @@ namespace gamestate
|
|||||||
if (!draw::isfading()) {
|
if (!draw::isfading()) {
|
||||||
draw::freeSurface(fondo);
|
draw::freeSurface(fondo);
|
||||||
draw::freeSurface(cursor);
|
draw::freeSurface(cursor);
|
||||||
if (exit==1) gamestate::sequence::init();
|
if (exit==menu::eixir::sequence) gamestate::sequence::init();
|
||||||
//if (exit==2) gamestate::password::init();
|
//if (exit==menu::eixir::password) gamestate::password::init();
|
||||||
}
|
}
|
||||||
draw::render();
|
draw::render();
|
||||||
return true;
|
return true;
|
||||||
@@ -53,12 +60,12 @@ namespace gamestate
|
|||||||
if (x >= 200 && y >= 100 && x <= 270 && y <= 120) {
|
if (x >= 200 && y >= 100 && x <= 270 && y <= 120) {
|
||||||
draw::fadeout();
|
draw::fadeout();
|
||||||
game::setConfig("fase", 0);
|
game::setConfig("fase", 0);
|
||||||
exit = 1;
|
exit = menu::eixir::sequence;
|
||||||
return true;
|
return true;
|
||||||
} else if (x >= 175 && y >= 125 && x <= 290 && y <= 145) {
|
} else if (x >= 175 && y >= 125 && x <= 290 && y <= 145) {
|
||||||
draw::fadeout();
|
draw::fadeout();
|
||||||
game::setConfig("fase", 0);
|
game::setConfig("fase", 0);
|
||||||
exit = 2;
|
exit = menu::eixir::password;
|
||||||
return true;
|
return true;
|
||||||
} else if (x >= 200 && y >= 150 && x <= 265 && y <= 170) {
|
} else if (x >= 200 && y >= 150 && x <= 265 && y <= 170) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
75
source/gamestate_mort.cpp
Normal file
75
source/gamestate_mort.cpp
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -94,7 +94,7 @@ namespace gamestate
|
|||||||
|
|
||||||
// I anem on toque
|
// I anem on toque
|
||||||
if (play::exit==play::eixir::postfase) gamestate::postfase::init();
|
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)
|
// En qualsevol cas, renderitzem i eixim ja del bucle (fins que acabe el fadeout)
|
||||||
draw::render();
|
draw::render();
|
||||||
|
|||||||
@@ -7,4 +7,5 @@ namespace gamestate
|
|||||||
namespace prefase { void init(); }
|
namespace prefase { void init(); }
|
||||||
namespace play { void init(); }
|
namespace play { void init(); }
|
||||||
namespace postfase { void init(); }
|
namespace postfase { void init(); }
|
||||||
|
namespace mort { void init(); }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user