Compare commits
3 Commits
d391827fe1
...
f9d2ac66e8
| Author | SHA1 | Date | |
|---|---|---|---|
| f9d2ac66e8 | |||
| 0b80fc1674 | |||
| d8404ce752 |
@@ -30,6 +30,8 @@ namespace gamestate
|
|||||||
bool loop_pause();
|
bool loop_pause();
|
||||||
bool loop_menu();
|
bool loop_menu();
|
||||||
|
|
||||||
|
void backToLoop();
|
||||||
|
|
||||||
void draw();
|
void draw();
|
||||||
void draw_aigua();
|
void draw_aigua();
|
||||||
|
|
||||||
@@ -54,7 +56,6 @@ namespace gamestate
|
|||||||
play::aigua = draw::loadSurface("aigua.gif");
|
play::aigua = draw::loadSurface("aigua.gif");
|
||||||
play::faded = draw::createSurface(320, 200);
|
play::faded = draw::createSurface(320, 200);
|
||||||
|
|
||||||
// [TODO] CREAR AIGUA PROCESSOR
|
|
||||||
// [TODO] CREAR MARCADOR PROCESSOR
|
// [TODO] CREAR MARCADOR PROCESSOR
|
||||||
|
|
||||||
// [TODO] Crear el primer Arounder
|
// [TODO] Crear el primer Arounder
|
||||||
@@ -72,10 +73,21 @@ namespace gamestate
|
|||||||
|
|
||||||
bool loop()
|
bool loop()
|
||||||
{
|
{
|
||||||
|
if (play::exit) {
|
||||||
|
if (!draw::isfading()) {
|
||||||
|
play::finalize();
|
||||||
|
if (exit==1) gamestate::postfase::init();
|
||||||
|
// [TODO] if (exit==2) gamestate::mort::init();
|
||||||
|
}
|
||||||
|
draw::render();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
play::draw();
|
play::draw();
|
||||||
|
|
||||||
if (input::keyPressed(SDL_SCANCODE_P) || input::mouseClk(2) || !game::windowHasFocus)
|
if (input::keyPressed(SDL_SCANCODE_P) || input::mouseClk(input::mouse::button::middle) || !game::windowHasFocus)
|
||||||
{
|
{
|
||||||
|
arounderCount = game::getTicks() - arounderCount;
|
||||||
draw::setSource(nullptr);
|
draw::setSource(nullptr);
|
||||||
draw::setDestination(play::faded);
|
draw::setDestination(play::faded);
|
||||||
draw::draw();
|
draw::draw();
|
||||||
@@ -97,6 +109,7 @@ namespace gamestate
|
|||||||
|
|
||||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE))
|
if (input::keyPressed(SDL_SCANCODE_ESCAPE))
|
||||||
{
|
{
|
||||||
|
arounderCount = game::getTicks() - arounderCount;
|
||||||
draw::setSource(nullptr);
|
draw::setSource(nullptr);
|
||||||
draw::setDestination(play::faded);
|
draw::setDestination(play::faded);
|
||||||
draw::draw();
|
draw::draw();
|
||||||
@@ -124,14 +137,64 @@ namespace gamestate
|
|||||||
|
|
||||||
draw::setSource(cursor);
|
draw::setSource(cursor);
|
||||||
draw::draw(input::mouseX(), input::mouseY());
|
draw::draw(input::mouseX(), input::mouseY());
|
||||||
|
|
||||||
draw::render();
|
draw::render();
|
||||||
|
|
||||||
|
if (input::mouseClk(input::mouse::button::right))
|
||||||
|
{
|
||||||
|
// [TODO] arounders::abortarAccio();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input::mouseClk(input::mouse::button::left))
|
||||||
|
{
|
||||||
|
/* [TODO]
|
||||||
|
if (!arounders::seleccionar())
|
||||||
|
{
|
||||||
|
if (input::mouseY()<165 && arounders::seleccionat != nullptr && arounders::seleccionat->accio == arounders::accions::caminar)
|
||||||
|
{
|
||||||
|
arounders::seleccionat->orientacio = input::mouseX() > arounders::seleccionat->x ? arounders::orientacions::dreta : arounders::orientacions::esquerra;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const int botoPulsat = mapa::procesar();
|
||||||
|
if (botoPulsat != -1 && arounders::seleccionat != nullptr)
|
||||||
|
{
|
||||||
|
if (botoPulsat == arounders::seleccionat->prevista) {
|
||||||
|
arounders::seleccionat->prevista = arounders::seleccionat->accio;
|
||||||
|
} else {
|
||||||
|
arounders::seleccionat->prevista = botoPulsat;
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
currentTicks = game::getTicks() - startTicks;
|
currentTicks = game::getTicks() - startTicks;
|
||||||
if( currentTicks >= mapa::velocitat ) {
|
if( currentTicks >= mapa::velocitat ) {
|
||||||
startTicks = game::getTicks();
|
startTicks = game::getTicks();
|
||||||
aigua_frame1 = (aigua_frame1+1)%10;
|
aigua_frame1 = (aigua_frame1+1)%10;
|
||||||
aigua_frame2 = (aigua_frame2+1)%10;
|
aigua_frame2 = (aigua_frame2+1)%10;
|
||||||
|
|
||||||
|
// [TODO] arounders::update();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* [TODO]
|
||||||
|
if ( (game::getTicks() - arounderCount) >= mapa::velocitat*58) {
|
||||||
|
if (mapa::arounders::eixits < mapa::arounders::totals) {
|
||||||
|
arounders::afegir();
|
||||||
|
mapa::arounders::eixits++;
|
||||||
|
arounderCount = game::getTicks();
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
if (mapa::arounders::arrivats + mapa::arounders::morts == mapa::arounders::totals) {
|
||||||
|
if (mapa::arounders::arrivats >= mapa::arounders::necessaris) {
|
||||||
|
game::setConfig("fase", game::getConfig("fase")+1);
|
||||||
|
draw::fadeout();
|
||||||
|
audio::fadeoutMusic();
|
||||||
|
play::exit = 1;
|
||||||
|
} else {
|
||||||
|
draw::fadeout();
|
||||||
|
audio::fadeoutMusic();
|
||||||
|
play::exit = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@@ -147,9 +210,7 @@ namespace gamestate
|
|||||||
|
|
||||||
if (input::keyPressed(SDL_SCANCODE_P) || input::keyPressed(SDL_SCANCODE_ESCAPE))
|
if (input::keyPressed(SDL_SCANCODE_P) || input::keyPressed(SDL_SCANCODE_ESCAPE))
|
||||||
{
|
{
|
||||||
draw::setPalette(play::original_palette, 256);
|
play::backToLoop();
|
||||||
free(play::original_palette);
|
|
||||||
game::setState(gamestate::play::loop);
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -174,18 +235,14 @@ namespace gamestate
|
|||||||
|
|
||||||
if (input::keyPressed(SDL_SCANCODE_ESCAPE))
|
if (input::keyPressed(SDL_SCANCODE_ESCAPE))
|
||||||
{
|
{
|
||||||
draw::setPalette(play::original_palette, 256);
|
play::backToLoop();
|
||||||
free(play::original_palette);
|
|
||||||
game::setState(gamestate::play::loop);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (input::mouseClk(1))
|
if (input::mouseClk(input::mouse::button::left))
|
||||||
{
|
{
|
||||||
if (input::mouseX() >= 97 && input::mouseX() <= 223) {
|
if (input::mouseX() >= 97 && input::mouseX() <= 223) {
|
||||||
if (input::mouseY() >= 60 && input::mouseY() <= 65) {
|
if (input::mouseY() >= 60 && input::mouseY() <= 65) {
|
||||||
draw::setPalette(play::original_palette, 256);
|
play::backToLoop();
|
||||||
free(play::original_palette);
|
|
||||||
game::setState(gamestate::play::loop);
|
|
||||||
}
|
}
|
||||||
if (input::mouseY() >= 71 && input::mouseY() <= 76) {
|
if (input::mouseY() >= 71 && input::mouseY() <= 76) {
|
||||||
free(play::original_palette);
|
free(play::original_palette);
|
||||||
@@ -208,6 +265,14 @@ namespace gamestate
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void backToLoop()
|
||||||
|
{
|
||||||
|
draw::setPalette(play::original_palette, 256);
|
||||||
|
free(play::original_palette);
|
||||||
|
game::setState(gamestate::play::loop);
|
||||||
|
arounderCount = game::getTicks() - arounderCount;
|
||||||
|
}
|
||||||
|
|
||||||
void draw()
|
void draw()
|
||||||
{
|
{
|
||||||
draw::draw(play::fondo);
|
draw::draw(play::fondo);
|
||||||
|
|||||||
@@ -3,6 +3,16 @@
|
|||||||
|
|
||||||
namespace input
|
namespace input
|
||||||
{
|
{
|
||||||
|
namespace mouse
|
||||||
|
{
|
||||||
|
namespace button
|
||||||
|
{
|
||||||
|
const int left = 1;
|
||||||
|
const int middle = 2;
|
||||||
|
const int right = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// @brief Inicialitza els sistemes de teclat, ratolí i gamepad
|
/// @brief Inicialitza els sistemes de teclat, ratolí i gamepad
|
||||||
void init(const int zoom);
|
void init(const int zoom);
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,19 @@
|
|||||||
#include "aux_font.h"
|
#include "aux_font.h"
|
||||||
namespace mapa
|
namespace mapa
|
||||||
{
|
{
|
||||||
|
namespace botons
|
||||||
|
{
|
||||||
|
const int caminar = 0;
|
||||||
|
const int parar = 1;
|
||||||
|
const int cavar = 2;
|
||||||
|
const int escalar = 3;
|
||||||
|
const int perforar = 4;
|
||||||
|
const int escalera = 5;
|
||||||
|
const int pasarela = 6;
|
||||||
|
const int corda = 7;
|
||||||
|
const int suicidi = 8;
|
||||||
|
const int fastforward = 9;
|
||||||
|
}
|
||||||
namespace arounders
|
namespace arounders
|
||||||
{
|
{
|
||||||
int orientacio_inicial {0};
|
int orientacio_inicial {0};
|
||||||
@@ -148,9 +161,46 @@ namespace mapa
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int procesar(int mousex, int mousey);
|
const int procesar()
|
||||||
|
{
|
||||||
|
int boto = -1;
|
||||||
|
|
||||||
void setAroundersNum(const int orient, const int total, const int necessaris);
|
if (input::mouseY() >= 171 && input::mouseY() <= 187 && input::mouseX() >= 5 && input::mouseX() <= 165) {
|
||||||
void setActions(const int parar, const int cavar, const int escalar, const int perforar, const int escalera, const int pasarela, const int corda);
|
boto = (input::mouseX()-5) / 16;
|
||||||
|
|
||||||
|
switch(boto) {
|
||||||
|
case mapa::botons::parar:
|
||||||
|
if (mapa::accions::parar == 0) boto = -1;
|
||||||
|
break;
|
||||||
|
case mapa::botons::cavar:
|
||||||
|
if (mapa::accions::cavar == 0) boto = -1;
|
||||||
|
break;
|
||||||
|
case mapa::botons::escalar:
|
||||||
|
if (mapa::accions::escalar == 0) boto = -1;
|
||||||
|
break;
|
||||||
|
case mapa::botons::perforar:
|
||||||
|
if (mapa::accions::perforar == 0) boto = -1;
|
||||||
|
break;
|
||||||
|
case mapa::botons::escalera:
|
||||||
|
if (mapa::accions::escalera == 0) boto = -1;
|
||||||
|
break;
|
||||||
|
case mapa::botons::pasarela:
|
||||||
|
if (mapa::accions::pasarela == 0) boto = -1;
|
||||||
|
break;
|
||||||
|
case mapa::botons::corda:
|
||||||
|
if (mapa::accions::corda == 0) boto = -1;
|
||||||
|
break;
|
||||||
|
case botons::fastforward:
|
||||||
|
if (mapa::velocitat == 70) {
|
||||||
|
mapa::velocitat = 10;
|
||||||
|
} else {
|
||||||
|
mapa::velocitat = 70;
|
||||||
|
}
|
||||||
|
boto = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return boto;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -29,9 +29,5 @@ namespace mapa
|
|||||||
void carregar();
|
void carregar();
|
||||||
|
|
||||||
void pintar(int accio, int prevista);
|
void pintar(int accio, int prevista);
|
||||||
int procesar(int mousex, int mousey);
|
const int procesar();
|
||||||
|
|
||||||
void setAroundersNum(const int orient, const int total, const int necessaris);
|
|
||||||
void setActions(const int parar, const int cavar, const int escalar, const int perforar, const int escalera, const int pasarela, const int corda);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user