- [NEW] L'explosió puja més alta, que ara tots els pixels anaven cap avall
- [NEW] Comentaris i pijades en el modul play
This commit is contained in:
@@ -34,7 +34,7 @@ namespace explosio
|
|||||||
exp[numexp].pix[i].x = x;
|
exp[numexp].pix[i].x = x;
|
||||||
exp[numexp].pix[i].y = y;
|
exp[numexp].pix[i].y = y;
|
||||||
exp[numexp].pix[i].xa = float((rand()%expansio) - (expansio >> 1))/1000.0f;
|
exp[numexp].pix[i].xa = float((rand()%expansio) - (expansio >> 1))/1000.0f;
|
||||||
exp[numexp].pix[i].ya = float((rand()%expansio) - (expansio >> 1))/1000.0f;
|
exp[numexp].pix[i].ya = -float((rand()%expansio))/1000.0f;
|
||||||
exp[numexp].pix[i].g = 0.05;
|
exp[numexp].pix[i].g = 0.05;
|
||||||
exp[numexp].pix[i].c = rand()%60;
|
exp[numexp].pix[i].c = rand()%60;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace gamestate
|
|||||||
int aigua_frame1 = 0;
|
int aigua_frame1 = 0;
|
||||||
int aigua_frame2 = 5;
|
int aigua_frame2 = 5;
|
||||||
|
|
||||||
int exit = 0;
|
int exit = play::eixir::no;
|
||||||
|
|
||||||
bool loop();
|
bool loop();
|
||||||
|
|
||||||
@@ -182,68 +182,92 @@ namespace gamestate
|
|||||||
arounders::abortarAccio();
|
arounders::abortarAccio();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Si pulsem el botó de l'esquerra... pos es més complicat! Anem pas per pas...
|
||||||
if (input::mouseClk(input::mouse::button::left))
|
if (input::mouseClk(input::mouse::button::left))
|
||||||
{
|
{
|
||||||
|
// Si al pulsar no havem seleccionat cap arounder (o siga, no havem fet click sobre un arounder)...
|
||||||
if (!arounders::seleccionar())
|
if (!arounders::seleccionar())
|
||||||
{
|
{
|
||||||
|
// Si no havem pulsat en la zona de baix dels botons, i hi ha un arounder seleccionat, i està caminant...
|
||||||
if (input::mouseY()<165 && arounders::seleccionat != nullptr && arounders::seleccionat->accio == arounders::accions::caminar)
|
if (input::mouseY()<165 && arounders::seleccionat != nullptr && arounders::seleccionat->accio == arounders::accions::caminar)
|
||||||
{
|
{
|
||||||
|
// Fem que camine en la direcció en que està el cursor
|
||||||
arounders::seleccionat->orientacio = input::mouseX() > arounders::seleccionat->x ? arounders::orientacions::dreta : arounders::orientacions::esquerra;
|
arounders::seleccionat->orientacio = input::mouseX() > arounders::seleccionat->x ? arounders::orientacions::dreta : arounders::orientacions::esquerra;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mirem si havem pulsat un botó... (si el botó està a 0, no conta com a pulsat)
|
||||||
const int botoPulsat = mapa::procesar();
|
const int botoPulsat = mapa::procesar();
|
||||||
|
// Si havem pulsat un botó i tenim un arounder seleccionat...
|
||||||
if (botoPulsat != -1 && arounders::seleccionat != nullptr)
|
if (botoPulsat != -1 && arounders::seleccionat != nullptr)
|
||||||
{
|
{
|
||||||
|
// Si el botó pulsat se correspon en la accio encolada
|
||||||
if (botoPulsat == arounders::seleccionat->prevista) {
|
if (botoPulsat == arounders::seleccionat->prevista) {
|
||||||
|
// La desencolem
|
||||||
arounders::seleccionat->prevista = arounders::seleccionat->accio;
|
arounders::seleccionat->prevista = arounders::seleccionat->accio;
|
||||||
} else {
|
} else {
|
||||||
|
// Pero si no, la encolem (atenció, moltes accions comencen instantàneament)
|
||||||
arounders::seleccionat->prevista = botoPulsat;
|
arounders::seleccionat->prevista = botoPulsat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Si ha passat el temps suficient, actualitzem els arounders (i les ones)
|
||||||
|
// Açò pot ser mes tard o mes prompte depenent de si havem accelerat el temps
|
||||||
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;
|
||||||
|
|
||||||
|
// Ací passa quasi tot lo interessant!!! No t'ho perdes!!
|
||||||
arounders::procesar();
|
arounders::procesar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Si ha passat el temps suficient...
|
||||||
|
// (també depen de si havem pulsat el botó de passar rapid el temps)
|
||||||
if ( (game::getTicks() - arounderCount) >= mapa::velocitat*58) {
|
if ( (game::getTicks() - arounderCount) >= mapa::velocitat*58) {
|
||||||
|
// I encara queden arounders per eixir...
|
||||||
if (mapa::arounders::eixits < mapa::arounders::totals) {
|
if (mapa::arounders::eixits < mapa::arounders::totals) {
|
||||||
|
// Traguem un nou arounder per la porta
|
||||||
arounders::afegir();
|
arounders::afegir();
|
||||||
mapa::arounders::eixits++;
|
mapa::arounders::eixits++;
|
||||||
arounderCount = game::getTicks();
|
arounderCount = game::getTicks();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Si tots els arounders ja han arribat o han mort...
|
||||||
if (mapa::arounders::arrivats + mapa::arounders::morts == mapa::arounders::totals) {
|
if (mapa::arounders::arrivats + mapa::arounders::morts == mapa::arounders::totals) {
|
||||||
|
// Si han arribat els necessaris...
|
||||||
if (mapa::arounders::arrivats >= mapa::arounders::necessaris) {
|
if (mapa::arounders::arrivats >= mapa::arounders::necessaris) {
|
||||||
|
// Pujem el numero de fase en el config i anem a la postfase
|
||||||
game::setConfig("fase", game::getConfig("fase")+1);
|
game::setConfig("fase", game::getConfig("fase")+1);
|
||||||
draw::fadeout();
|
draw::fadeout();
|
||||||
audio::fadeOutMusic();
|
audio::fadeOutMusic();
|
||||||
play::exit = 1;
|
play::exit = play::eixir::postfase;
|
||||||
} else {
|
} else {
|
||||||
|
// Sino, anem a la pantalla de mort
|
||||||
draw::fadeout();
|
draw::fadeout();
|
||||||
audio::fadeOutMusic();
|
audio::fadeOutMusic();
|
||||||
play::exit = 2;
|
play::exit = play::eixir::mort;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mentres estem en pausa, este es el bucle principal
|
||||||
bool loop_pause()
|
bool loop_pause()
|
||||||
{
|
{
|
||||||
|
// Consisteix en pintar la surface sobre la que havem pintat la foto del que hi havia en pantalla
|
||||||
draw::draw(faded);
|
draw::draw(faded);
|
||||||
|
// ...I el cursor...
|
||||||
draw::setSource(cursor);
|
draw::setSource(cursor);
|
||||||
draw::draw(input::mouseX(), input::mouseY());
|
draw::draw(input::mouseX(), input::mouseY());
|
||||||
|
|
||||||
draw::render();
|
draw::render();
|
||||||
|
|
||||||
|
// I mirem si s'ha polsat P o ESC, per a tornat al bucle principal del mòdul de joc
|
||||||
if (input::keyPressed(SDL_SCANCODE_P) || input::keyPressed(SDL_SCANCODE_ESCAPE))
|
if (input::keyPressed(SDL_SCANCODE_P) || input::keyPressed(SDL_SCANCODE_ESCAPE))
|
||||||
{
|
{
|
||||||
play::backToLoop();
|
play::backToLoop();
|
||||||
@@ -251,10 +275,14 @@ namespace gamestate
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Mentres estem en el menú, este es el bucle principal
|
||||||
bool loop_menu()
|
bool loop_menu()
|
||||||
{
|
{
|
||||||
|
// Si havem triat eixir...
|
||||||
if (play::exit) {
|
if (play::exit) {
|
||||||
|
// esperem a que acabe el fade...
|
||||||
if (!draw::isfading()) {
|
if (!draw::isfading()) {
|
||||||
|
// I quan acabe
|
||||||
play::finalize();
|
play::finalize();
|
||||||
if (exit==1) {
|
if (exit==1) {
|
||||||
mapa::carregar();
|
mapa::carregar();
|
||||||
|
|||||||
Reference in New Issue
Block a user