Compare commits

...

2 Commits

Author SHA1 Message Date
5173edd7f0 - Intentant que l'aigua se pinte i tal 2023-10-18 20:04:10 +02:00
c9e1760698 - [FIX] nom de musica incorrecte
- [FIX] Al carregar el mapa nomes contaba fins a x=10 en compte de 20.
- Aplicats els nous draw::draw()
- Fora tots els draw::setTrans(), el color transparent no canvia en tot el joc.
2023-10-18 19:44:48 +02:00
8 changed files with 57 additions and 25 deletions

View File

@@ -32,7 +32,6 @@ namespace font
void print(const int x, const int y, const std::string text)
{
draw::setSource(font::mode == font::type::colored ? font::font2 : font::font1);
draw::setTrans(0);
if (font::mode == font::type::fade) for (int i=64;i<=67;++i) draw::swapcol(i, i+4);
@@ -47,8 +46,6 @@ namespace font
}
for (int i=64;i<=67;++i) draw::restorecol(i);
draw::setTrans(255);
}
void print(const int x, const int y, const int num)

View File

@@ -41,13 +41,10 @@ namespace gamestate
const int x = input::mouseX();
const int y = input::mouseY();
draw::setTrans(255);
draw::setSource(fondo);
draw::draw(0, 0, 320, 200, 0, 0);
draw::draw(fondo);
draw::setTrans(0);
draw::setSource(cursor);
draw::draw(x, y, cursor->w, cursor->h, 0, 0);
draw::draw(x, y);
draw::render();

View File

@@ -10,12 +10,19 @@ 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()
{
@@ -30,7 +37,8 @@ namespace gamestate
draw::setPalette(pal, 128);
// [TODO] Carreagar la resta de gifs que facen falta
//cursor = drawManager->LoadFont("cursor.gif");
cursor = draw::loadSurface("cursor.gif");
aigua = draw::loadSurface("aigua.gif");
//menu = drawManager->LoadFont("menu.gif");
// [TODO] CREAR AIGUA PROCESSOR
@@ -40,7 +48,7 @@ namespace gamestate
mapa::arounders::eixits++;
// arounder_seleccionat = primerArounders
audio::loadMusic((fase+1) % 5 == 0 ? "mus6.ogg" : "mus4.mp3");
audio::loadMusic((fase+1) % 5 == 0 ? "mus6.ogg" : "mus4.ogg");
audio::playMusic();
play::arounderCount = play::startTicks = game::getTicks();
@@ -52,20 +60,28 @@ namespace gamestate
bool loop()
{
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;
}
void draw()
{
draw::setSource(play::fondo);
draw::draw();
draw::draw(play::fondo);
int accio = -1;
int prevista = -1;
int accio = 0;
int prevista = 0;
// [TODO] if (arounders::seleccionat) { accio = arounders::seleccionat->accio; prevista = arounders::seleccionat->prevista; }
// [QUESTION] Potser lo del seleccionat se deuria mirar dins de "mapa"?
mapa::pintar(0, 0); // [TODO] if (arounders::seleccionat) existeix, pillar la accio i la prevista de ell
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"
@@ -75,6 +91,25 @@ namespace gamestate
draw::draw(arounderSeleccionat->X-3, arounderSeleccionat->Y-3);
}
*/
draw::setSource(cursor);
draw::draw(input::mouseX(), input::mouseY());
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);
}
}
}
}

View File

@@ -48,13 +48,10 @@ namespace gamestate
{
static bool salir = false;
draw::setTrans(255);
draw::setSource(fondo);
draw::draw(0, 0, 320, 200, 0, 0);
draw::draw(fondo);
draw::setTrans(0);
draw::setSource(cursor);
draw::draw(input::mouseX(), input::mouseY(), cursor->w, cursor->h, 0, 0);
draw::draw(input::mouseX(), input::mouseY());
draw::render();

View File

@@ -16,7 +16,6 @@ namespace gamestate
void init()
{
draw::setTrans(255);
font::selectFont(font::type::colored);
std::string filename;
@@ -118,8 +117,7 @@ namespace gamestate
void drawPic(std::string filename)
{
draw::surface *pic = draw::loadSurface(filename, true);
draw::setSource(pic);
draw::draw(0, 0, 320, 200, 0, 0);
draw::draw(pic);
draw::freeSurface(pic);
}

View File

@@ -5,6 +5,8 @@
void game::init()
{
draw::init("Arounders", 320, 200, 3);
draw::setTrans(0);
input::init(3);
audio::init();

View File

@@ -38,6 +38,9 @@ namespace mapa
void carregar()
{
mapa::velocitat = 70;
mapa::contador = game::getTicks();
textfile::open("mapes.txt");
do {
@@ -72,9 +75,10 @@ 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<10; ++x)
for (int x=0; x<20; ++x)
{
int tile = textfile::toInt(textfile::getNextToken());
if (tile > 0) draw::draw(x*16, y*16, 16, 16, (tile-1)*16, tileset*16);

View File

@@ -24,6 +24,8 @@ namespace mapa
extern int corda;
}
extern int velocitat;
void carregar();
void pintar(int accio, int prevista);