diff --git a/source/gamestate_play.cpp b/source/gamestate_play.cpp index ba226d3..25097d5 100644 --- a/source/gamestate_play.cpp +++ b/source/gamestate_play.cpp @@ -11,12 +11,18 @@ namespace gamestate draw::surface *fondo = nullptr; draw::surface *mapa = nullptr; draw::surface *cursor = nullptr; + draw::surface *aigua = nullptr; uint32_t arounderCount; uint32_t startTicks; + uint32_t currentTicks; + + int aigua_frame1 = 0; + int aigua_frame2 = 5; bool loop(); void draw(); + void draw_aigua(); void init() { @@ -32,6 +38,7 @@ namespace gamestate // [TODO] Carreagar la resta de gifs que facen falta cursor = draw::loadSurface("cursor.gif"); + aigua = draw::loadSurface("aigua.gif"); //menu = drawManager->LoadFont("menu.gif"); // [TODO] CREAR AIGUA PROCESSOR @@ -54,6 +61,13 @@ namespace gamestate { play::draw(); + currentTicks = game::getTicks() - startTicks; + if( currentTicks >= mapa::velocitat ) { + startTicks = game::getTicks(); + aigua_frame1 = (aigua_frame1+1)%10; + aigua_frame2 = (aigua_frame2+1)%10; + } + return true; } @@ -67,7 +81,7 @@ namespace gamestate // [QUESTION] Potser lo del seleccionat se deuria mirar dins de "mapa"? mapa::pintar(accio, prevista); // [TODO] if (arounders::seleccionat) existeix, pillar la accio i la prevista de ell - // [TODO] aigua::pintar(); + void draw_aigua(); // [TODO] arounders::pintar(); // [TODO] de fet, pintar la marca en el modul "arounders" @@ -83,5 +97,19 @@ namespace gamestate draw::render(); } + + void draw_aigua() + { + static int frames1[10] = {0,1,2,1,0,3,4,5,4,3}; + static int frames2[10] = {6,7,8,7,6,9,10,11,10,9}; + int *frames; + frames = (game::getConfig("fase")+1) % 5 == 0 ? frames2 : frames1; + + draw::setSource(aigua); + for (int i=0;i<10;i++) { + draw::draw(i*32, 150, 16, 15, frames[aigua_frame1]*16, 0); + draw::draw(16+i*32, 150, 16, 15, frames[aigua_frame2]*16, 0); + } + } } } \ No newline at end of file diff --git a/source/proc_mapa.cpp b/source/proc_mapa.cpp index 806ed52..c6900b8 100644 --- a/source/proc_mapa.cpp +++ b/source/proc_mapa.cpp @@ -38,6 +38,9 @@ namespace mapa void carregar() { + mapa::velocitat = 70; + mapa::contador = game::getTicks(); + textfile::open("mapes.txt"); do { @@ -72,6 +75,7 @@ namespace mapa if (mapa) draw::freeSurface(mapa); mapa = draw::createSurface(320, 200); draw::setDestination(mapa); + draw::cls(0); for (int y=0; y<10; ++y) for (int x=0; x<20; ++x) diff --git a/source/proc_mapa.h b/source/proc_mapa.h index 341aa5e..f99847b 100644 --- a/source/proc_mapa.h +++ b/source/proc_mapa.h @@ -24,6 +24,8 @@ namespace mapa extern int corda; } + extern int velocitat; + void carregar(); void pintar(int accio, int prevista);