Compare commits

...

4 Commits

Author SHA1 Message Date
6b63dbd70a - Ja funcionen els arounders, pero la corda falla. A investigar. 2023-10-20 20:08:25 +02:00
136bc86f68 - [FIX] El modul arounders no s'inicialitzava
- [FIX] Quan reintentaves un mapa, no se recarregava
2023-10-20 20:07:57 +02:00
61b429eb8b - [FIX] El nom del fitxer de la cançò estava mal 2023-10-20 20:07:09 +02:00
5dcf2e582a - [FIX] Algunes variables no se reinicialitzaven 2023-10-20 20:06:25 +02:00
4 changed files with 37 additions and 7 deletions

View File

@@ -65,6 +65,7 @@ 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);
arounders::init();
// [TODO] Crear el primer Arounder // [TODO] Crear el primer Arounder
// REALMENT NO. PREFEREIXC QUE PASEN UNS SEGONS ABANS QUE ARRIBE EL PRIMER // REALMENT NO. PREFEREIXC QUE PASEN UNS SEGONS ABANS QUE ARRIBE EL PRIMER
// mapa::arounders::eixits++; // mapa::arounders::eixits++;
@@ -256,7 +257,10 @@ namespace gamestate
if (play::exit) { if (play::exit) {
if (!draw::isfading()) { if (!draw::isfading()) {
play::finalize(); play::finalize();
if (exit==1) gamestate::play::init(); if (exit==1) {
mapa::carregar();
gamestate::play::init();
}
if (exit==2) gamestate::menu::init(); if (exit==2) gamestate::menu::init();
} }
draw::render(); draw::render();

View File

@@ -34,7 +34,7 @@ namespace gamestate
gamestate::sequence::init(); gamestate::sequence::init();
return; return;
} else { } else {
audio::loadMusic("mus3.mp3"); audio::loadMusic("mus3.ogg");
audio::playMusic(); audio::playMusic();
} }

View File

@@ -74,8 +74,8 @@ namespace arounders
void afegir() void afegir()
{ {
arounder *a = new arounder(); arounder *a = new arounder();
a->x = mapa::ini_x; a->x = mapa::ini_x*16+8;
a->y = mapa::ini_y; a->y = mapa::ini_y*16+8;
a->orientacio = mapa::arounders::orientacio_inicial; a->orientacio = mapa::arounders::orientacio_inicial;
a->frame = a->frameX = a->frameY = a->altura = 0; a->frame = a->frameX = a->frameY = a->altura = 0;
@@ -97,9 +97,9 @@ namespace arounders
{ {
arounder *a = arounders::first; arounder *a = arounders::first;
draw::setSource(sprites);
while (a) while (a)
{ {
draw::setSource(sprites);
draw::draw(a->x, a->y, 8, 8, a->frameX*8, a->frameY); draw::draw(a->x, a->y, 8, 8, a->frameX*8, a->frameY);
a = a->siguiente; a = a->siguiente;
} }
@@ -168,10 +168,30 @@ namespace arounders
case arounders::accions::suicidi: procesarSuicidi(a); break; case arounders::accions::suicidi: procesarSuicidi(a); break;
} }
if (a->x == mapa::fin_x && a->y == mapa::fin_y) initArrivat(a); if (a->x == (mapa::fin_x*16)+8 && a->y == (mapa::fin_y*16)+8) initArrivat(a);
a = a->siguiente; a = a->siguiente;
} }
a = arounders::first;
if (a)
{
while (a->siguiente) a = a->siguiente;
while (a) {
if (a->accio == arounders::accions::mort) {
arounder *borrar = a;
if (borrar->siguiente) borrar->siguiente->anterior = borrar->anterior;
if (borrar->anterior) borrar->anterior->siguiente = borrar->siguiente;
if (borrar == arounders::first) arounders::first = borrar->siguiente;
if (borrar == arounders::seleccionat) arounders::seleccionat = nullptr;
a = borrar->anterior;
delete borrar;
} else {
a = a->anterior;
}
}
}
} }
uint8_t get_pixel(const int x, const int y) uint8_t get_pixel(const int x, const int y)
@@ -316,7 +336,11 @@ namespace arounders
{ {
a->frame = 0; a->frame = 0;
a->prevista = arounders::accions::baixarcorda; a->prevista = arounders::accions::baixarcorda;
a->x = a->orientacio == arounders::orientacions::dreta ? a->x + 2 : a->x - 2; if (a->orientacio == arounders::orientacions::dreta) {
a->x += 2;
} else {
a->x -= 2;
}
procesarBaixarCorda(a); procesarBaixarCorda(a);
} }

View File

@@ -79,6 +79,8 @@ namespace mapa
fin_x = textfile::getIntValue("final"); fin_x = textfile::getIntValue("final");
fin_y = textfile::toInt(textfile::getNextToken()); fin_y = textfile::toInt(textfile::getNextToken());
arounders::arrivats = arounders::eixits = arounders::morts = 0;
//int tilemap[200]; //int tilemap[200];
//for (int y=0; y<10; ++y) for (int x=0; x<10; ++x) fscanf(f, "%i", &tilemap[x+y*20]); //for (int y=0; y<10; ++y) for (int x=0; x<10; ++x) fscanf(f, "%i", &tilemap[x+y*20]);