- Remodelat un poc el codi
This commit is contained in:
25
main.cpp
25
main.cpp
@@ -3,10 +3,7 @@
|
|||||||
#include "jsound.h"
|
#include "jsound.h"
|
||||||
#include "jfile.h"
|
#include "jfile.h"
|
||||||
#include "info.h"
|
#include "info.h"
|
||||||
#include "modulestaticscreen.h"
|
#include "modules.h"
|
||||||
#include "modulemenu.h"
|
|
||||||
#include "moduleselect.h"
|
|
||||||
#include "modulesequence.h"
|
|
||||||
#include "time.h"
|
#include "time.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -55,28 +52,16 @@ int main( int argc, char* args[] ) {
|
|||||||
switch (info::estat_joc) {
|
switch (info::estat_joc) {
|
||||||
case ESTAT_ICEKAS:
|
case ESTAT_ICEKAS:
|
||||||
case ESTAT_LOGO:
|
case ESTAT_LOGO:
|
||||||
ModuleStaticScreen * moduleStaticScreen;
|
module::staticScreen::go();
|
||||||
moduleStaticScreen = new ModuleStaticScreen();
|
|
||||||
info::estat_joc = moduleStaticScreen->Go();
|
|
||||||
delete moduleStaticScreen;
|
|
||||||
break;
|
break;
|
||||||
case ESTAT_MENU:
|
case ESTAT_MENU:
|
||||||
ModuleMenu * moduleMenu;
|
module::menu::go();
|
||||||
moduleMenu = new ModuleMenu();
|
|
||||||
info::estat_joc = moduleMenu->Go();
|
|
||||||
delete moduleMenu;
|
|
||||||
break;
|
break;
|
||||||
case ESTAT_SELECT:
|
case ESTAT_SELECT:
|
||||||
ModuleSelect * moduleSelect;
|
module::select::go();
|
||||||
moduleSelect = new ModuleSelect();
|
|
||||||
info::estat_joc = moduleSelect->Go();
|
|
||||||
delete moduleSelect;
|
|
||||||
break;
|
break;
|
||||||
case ESTAT_SEQUENCIA:
|
case ESTAT_SEQUENCIA:
|
||||||
ModuleSequence * moduleSequence;
|
module::sequence::go();
|
||||||
moduleSequence = new ModuleSequence();
|
|
||||||
info::estat_joc = moduleSequence->Go();
|
|
||||||
delete moduleSequence;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
325
modulemenu.cpp
325
modulemenu.cpp
@@ -1,4 +1,4 @@
|
|||||||
#include "modulemenu.h"
|
#include "modules.h"
|
||||||
|
|
||||||
#include "jgame.h"
|
#include "jgame.h"
|
||||||
#include "jdraw8.h"
|
#include "jdraw8.h"
|
||||||
@@ -14,162 +14,209 @@
|
|||||||
#define OPCIO_CLASSICMODE 2
|
#define OPCIO_CLASSICMODE 2
|
||||||
#define OPCIO_OPTIONS 3
|
#define OPCIO_OPTIONS 3
|
||||||
|
|
||||||
ModuleMenu::ModuleMenu() {
|
namespace module
|
||||||
}
|
{
|
||||||
|
namespace menu
|
||||||
|
{
|
||||||
|
void go()
|
||||||
|
{
|
||||||
|
// [RZC 31/01/2024] [TODO] Menú del mode nocturn
|
||||||
|
|
||||||
ModuleMenu::~ModuleMenu(void) {
|
// Inicialitzem música i gràfics per al menú
|
||||||
}
|
JS_LoadMusic("mtitle.mid");
|
||||||
|
JS_PlayMusic(-1);
|
||||||
|
|
||||||
int ModuleMenu::Go() {
|
JD8_Surface fondo = JD8_LoadSurface("menu.gif");
|
||||||
|
JD8_Palette pal = JD8_LoadPalette("menu.gif");
|
||||||
|
JD8_Surface opcions = JD8_LoadSurface("menu_s.gif");
|
||||||
|
JD8_Surface gfx = JD8_LoadSurface("sprites.gif");
|
||||||
|
|
||||||
JS_LoadMusic("mtitle.mid");
|
JD8_ClearScreen(0);
|
||||||
JS_PlayMusic(-1);
|
JD8_Flip();
|
||||||
|
|
||||||
JD8_Surface fondo = JD8_LoadSurface("menu.gif");
|
|
||||||
JD8_Palette pal = JD8_LoadPalette("menu.gif");
|
|
||||||
JD8_Surface opcions = JD8_LoadSurface("menu_s.gif");
|
|
||||||
JD8_Surface gfx = JD8_LoadSurface("sprites.gif");
|
|
||||||
|
|
||||||
JD8_ClearScreen(0);
|
// Fade in
|
||||||
JD8_Flip();
|
JD8_Blit(fondo);
|
||||||
|
JG_SetUpdateTicks(1);
|
||||||
|
while (!JD8_FadeToPalAsync(pal) && !JG_Quitting()) {
|
||||||
|
while (!JG_ShouldUpdate()) { JI_Update(); }
|
||||||
|
}
|
||||||
|
|
||||||
// FADE IN
|
|
||||||
JD8_Blit(fondo);
|
|
||||||
JG_SetUpdateTicks(1);
|
|
||||||
while (!JD8_FadeToPalAsync(pal) && !JG_Quitting()) {
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
int x = 320;
|
// Movem la primera opció del menú al lloc
|
||||||
while (!JG_Quitting() && x > 0) {
|
int x = 320;
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); }
|
while (!JG_Quitting() && x > 0) {
|
||||||
JD8_Blit(fondo);
|
while (!JG_ShouldUpdate()) { JI_Update(); }
|
||||||
JD8_BlitCKCut(x, 50, opcions, 0, 50, 320, 38, 0);
|
JD8_Blit(fondo);
|
||||||
JD8_Flip();
|
JD8_BlitCKCut(x, 50, opcions, 0, 50, 320, 38, 0);
|
||||||
x--;
|
JD8_Flip();
|
||||||
}
|
x--;
|
||||||
JD8_BlitCKToSurface(0, 50, opcions, 0, 50, 320, 38, fondo, 0);
|
}
|
||||||
|
JD8_BlitCKToSurface(0, 50, opcions, 0, 50, 320, 38, fondo, 0);
|
||||||
|
|
||||||
x = 320;
|
|
||||||
while (!JG_Quitting() && x > 25) {
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); }
|
|
||||||
JD8_Blit(fondo);
|
|
||||||
JD8_BlitCKCut(x, 88, opcions, 25, 88, 135, 37, 0);
|
|
||||||
JD8_Flip();
|
|
||||||
x--;
|
|
||||||
}
|
|
||||||
JD8_BlitCKToSurface(25, 88, opcions, 25, 88, 135, 37, fondo, 0);
|
|
||||||
|
|
||||||
x = 320;
|
// Movem la segona opció del menú al lloc
|
||||||
while (!JG_Quitting() && x > 0) {
|
x = 320;
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); }
|
while (!JG_Quitting() && x > 25) {
|
||||||
JD8_Blit(fondo);
|
while (!JG_ShouldUpdate()) { JI_Update(); }
|
||||||
JD8_BlitCKCut(x, 125, opcions, 0, 125, 320, 38, 0);
|
JD8_Blit(fondo);
|
||||||
JD8_Flip();
|
JD8_BlitCKCut(x, 88, opcions, 25, 88, 135, 37, 0);
|
||||||
x--;
|
JD8_Flip();
|
||||||
}
|
x--;
|
||||||
JD8_BlitCKToSurface(0, 125, opcions, 0, 125, 320, 38, fondo, 0);
|
}
|
||||||
|
JD8_BlitCKToSurface(25, 88, opcions, 25, 88, 135, 37, fondo, 0);
|
||||||
|
|
||||||
x = 320;
|
|
||||||
while (!JG_Quitting() && x > 0) {
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); }
|
|
||||||
JD8_Blit(fondo);
|
|
||||||
JD8_BlitCKCut(x, 163, opcions, 0, 163, 320, 37, 0);
|
|
||||||
JD8_Flip();
|
|
||||||
x--;
|
|
||||||
}
|
|
||||||
JD8_BlitCKToSurface(0, 163, opcions, 0, 163, 320, 37, fondo, 0);
|
|
||||||
|
|
||||||
int y = 50;
|
// Movem la tercera opció del menú al lloc
|
||||||
while (!JG_Quitting() && y > 0) {
|
x = 320;
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); }
|
while (!JG_Quitting() && x > 0) {
|
||||||
JD8_Blit(fondo);
|
while (!JG_ShouldUpdate()) { JI_Update(); }
|
||||||
JD8_BlitCKCut(0, -y, opcions, 0, 0, 320, 50, 0);
|
JD8_Blit(fondo);
|
||||||
JD8_Flip();
|
JD8_BlitCKCut(x, 125, opcions, 0, 125, 320, 38, 0);
|
||||||
y--;
|
JD8_Flip();
|
||||||
}
|
x--;
|
||||||
JD8_BlitCKToSurface(0, 0, opcions, 0, 0, 320, 50, fondo, 0);
|
}
|
||||||
|
JD8_BlitCKToSurface(0, 125, opcions, 0, 125, 320, 38, fondo, 0);
|
||||||
|
|
||||||
int opcio_seleccionada = OPCIO_TIMEATTACK;
|
|
||||||
int opcio_triada = SENSE_OPCIO;
|
|
||||||
bool fletxa_amunt_pulsada = false;
|
|
||||||
bool fletxa_avall_pulsada = false;
|
|
||||||
float x_fletxa = 0;
|
|
||||||
float x_velocitat = 1;
|
|
||||||
|
|
||||||
JG_SetUpdateTicks(20);
|
// Movem la quarta opció del menú al lloc
|
||||||
|
x = 320;
|
||||||
|
while (!JG_Quitting() && x > 0) {
|
||||||
|
while (!JG_ShouldUpdate()) { JI_Update(); }
|
||||||
|
JD8_Blit(fondo);
|
||||||
|
JD8_BlitCKCut(x, 163, opcions, 0, 163, 320, 37, 0);
|
||||||
|
JD8_Flip();
|
||||||
|
x--;
|
||||||
|
}
|
||||||
|
JD8_BlitCKToSurface(0, 163, opcions, 0, 163, 320, 37, fondo, 0);
|
||||||
|
|
||||||
while (!JG_Quitting() && opcio_triada == SENSE_OPCIO) {
|
|
||||||
while (!JG_ShouldUpdate()) {
|
// Movem el titol del menú al lloc
|
||||||
JI_Update();
|
int y = 50;
|
||||||
if (JI_KeyPressed(SDL_SCANCODE_UP)) {
|
while (!JG_Quitting() && y > 0) {
|
||||||
if (!fletxa_amunt_pulsada) {
|
while (!JG_ShouldUpdate()) { JI_Update(); }
|
||||||
fletxa_amunt_pulsada = true;
|
JD8_Blit(fondo);
|
||||||
opcio_seleccionada--; if (opcio_seleccionada < 0) opcio_seleccionada = 3;
|
JD8_BlitCKCut(0, -y, opcions, 0, 0, 320, 50, 0);
|
||||||
|
JD8_Flip();
|
||||||
|
y--;
|
||||||
|
}
|
||||||
|
JD8_BlitCKToSurface(0, 0, opcions, 0, 0, 320, 50, fondo, 0);
|
||||||
|
|
||||||
|
|
||||||
|
// Variables necessaries per al menú
|
||||||
|
int opcio_seleccionada = OPCIO_TIMEATTACK;
|
||||||
|
int opcio_triada = SENSE_OPCIO;
|
||||||
|
bool fletxa_amunt_pulsada = false;
|
||||||
|
bool fletxa_avall_pulsada = false;
|
||||||
|
float x_fletxa = 0;
|
||||||
|
float x_velocitat = 1;
|
||||||
|
|
||||||
|
JG_SetUpdateTicks(20);
|
||||||
|
|
||||||
|
|
||||||
|
// Gestió del menú en sí (triar opció)
|
||||||
|
// [RZC 31/01/2024] [TODO] Al temps que se fiquen els marcadors
|
||||||
|
while (!JG_Quitting() && opcio_triada == SENSE_OPCIO)
|
||||||
|
{
|
||||||
|
while (!JG_ShouldUpdate())
|
||||||
|
{
|
||||||
|
JI_Update();
|
||||||
|
|
||||||
|
if (JI_KeyPressed(SDL_SCANCODE_UP))
|
||||||
|
{
|
||||||
|
if (!fletxa_amunt_pulsada)
|
||||||
|
{
|
||||||
|
fletxa_amunt_pulsada = true;
|
||||||
|
opcio_seleccionada--; if (opcio_seleccionada < 0) opcio_seleccionada = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fletxa_amunt_pulsada = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JI_KeyPressed(SDL_SCANCODE_DOWN))
|
||||||
|
{
|
||||||
|
if (!fletxa_avall_pulsada)
|
||||||
|
{
|
||||||
|
fletxa_avall_pulsada = true;
|
||||||
|
opcio_seleccionada++; if (opcio_seleccionada > 3) opcio_seleccionada = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fletxa_avall_pulsada = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JI_KeyPressed(SDL_SCANCODE_SPACE))
|
||||||
|
{
|
||||||
|
opcio_triada = opcio_seleccionada;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JI_KeyPressed(SDL_SCANCODE_ESCAPE))
|
||||||
|
{
|
||||||
|
JG_QuitSignal();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
fletxa_amunt_pulsada = false;
|
x_fletxa += x_velocitat;
|
||||||
}
|
x_velocitat -= 0.1;
|
||||||
if (JI_KeyPressed(SDL_SCANCODE_DOWN)) {
|
|
||||||
if (!fletxa_avall_pulsada) {
|
if (x_fletxa < 0)
|
||||||
fletxa_avall_pulsada = true;
|
{
|
||||||
opcio_seleccionada++; if (opcio_seleccionada > 3) opcio_seleccionada = 0;
|
x_fletxa = 0;
|
||||||
|
x_velocitat = 1;
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
fletxa_avall_pulsada = false;
|
JD8_Blit(fondo);
|
||||||
|
JD8_BlitCK(10+x_fletxa, 60+opcio_seleccionada*37, gfx, 18, 5, 9, 10, 255);
|
||||||
|
JD8_Flip();
|
||||||
}
|
}
|
||||||
if (JI_KeyPressed(SDL_SCANCODE_SPACE)) {
|
JD8_BlitCKToSurface(10 + x_fletxa, 60 + opcio_seleccionada * 37, gfx, 18, 5, 9, 10, fondo, 255);
|
||||||
opcio_triada = opcio_seleccionada;
|
|
||||||
|
|
||||||
|
// Blinds out
|
||||||
|
JG_SetUpdateTicks(8);
|
||||||
|
x = 0;
|
||||||
|
while (x < 32 && !JG_Quitting())
|
||||||
|
{
|
||||||
|
while (!JG_ShouldUpdate()) { JI_Update(); }
|
||||||
|
|
||||||
|
for (y = 0; y < 200; y++)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < 10; i++)
|
||||||
|
{
|
||||||
|
JD8_PutPixel(fondo, i * 32 + x, y, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x++;
|
||||||
|
JD8_Blit(fondo);
|
||||||
|
JD8_Flip();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Alliberar memòria
|
||||||
|
JD8_FreeSurface(fondo);
|
||||||
|
JD8_FreeSurface(opcions);
|
||||||
|
JD8_FreeSurface(gfx);
|
||||||
|
free(pal);
|
||||||
|
|
||||||
|
|
||||||
|
// Canviar el estat al que toque
|
||||||
|
if (JG_Quitting())
|
||||||
|
{
|
||||||
|
info::estat_joc = ESTAT_EIXIR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
switch (opcio_triada)
|
||||||
|
{
|
||||||
|
case OPCIO_TIMEATTACK: info::estat_joc = ESTAT_LOGO; break;
|
||||||
|
case OPCIO_WORLDTOUR: info::estat_joc = ESTAT_SELECT; break;
|
||||||
|
case OPCIO_CLASSICMODE: info::estat_joc = ESTAT_MENU; break;
|
||||||
|
case OPCIO_OPTIONS: info::estat_joc = ESTAT_MENU; break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
x_fletxa += x_velocitat;
|
|
||||||
x_velocitat -= 0.1;
|
|
||||||
|
|
||||||
if (x_fletxa < 0) {
|
|
||||||
x_fletxa = 0;
|
|
||||||
x_velocitat = 1;
|
|
||||||
}
|
|
||||||
JD8_Blit(fondo);
|
|
||||||
JD8_BlitCK(10+x_fletxa, 60+opcio_seleccionada*37, gfx, 18, 5, 9, 10, 255);
|
|
||||||
JD8_Flip();
|
|
||||||
}
|
}
|
||||||
JD8_BlitCKToSurface(10 + x_fletxa, 60 + opcio_seleccionada * 37, gfx, 18, 5, 9, 10, fondo, 255);
|
|
||||||
|
|
||||||
// BLINDS OUT
|
|
||||||
JG_SetUpdateTicks(8);
|
|
||||||
x = 0;
|
|
||||||
while (x < 32 && !JG_Quitting()) {
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); }
|
|
||||||
|
|
||||||
for (y = 0; y < 200; y++) {
|
|
||||||
for (int i = 0; i < 10; i++) {
|
|
||||||
JD8_PutPixel(fondo, i * 32 + x, y, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
x++;
|
|
||||||
JD8_Blit(fondo);
|
|
||||||
JD8_Flip();
|
|
||||||
}
|
|
||||||
|
|
||||||
// FREE EVERYTHING
|
|
||||||
JD8_FreeSurface(fondo);
|
|
||||||
JD8_FreeSurface(opcions);
|
|
||||||
JD8_FreeSurface(gfx);
|
|
||||||
free(pal);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (JG_Quitting()) {
|
|
||||||
return ESTAT_EIXIR;
|
|
||||||
} else {
|
|
||||||
switch (opcio_triada) {
|
|
||||||
case OPCIO_TIMEATTACK: return ESTAT_LOGO; break;
|
|
||||||
case OPCIO_WORLDTOUR: return ESTAT_SELECT; break;
|
|
||||||
case OPCIO_CLASSICMODE: return ESTAT_MENU; break;
|
|
||||||
case OPCIO_OPTIONS: return ESTAT_MENU; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ESTAT_EIXIR;
|
|
||||||
}
|
}
|
||||||
|
|||||||
17
modulemenu.h
17
modulemenu.h
@@ -1,17 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
class ModuleMenu {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
ModuleMenu();
|
|
||||||
~ModuleMenu(void);
|
|
||||||
|
|
||||||
int Go();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
//void showMenu();
|
|
||||||
|
|
||||||
int contador;
|
|
||||||
};
|
|
||||||
9
modules.h
Normal file
9
modules.h
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace module
|
||||||
|
{
|
||||||
|
namespace staticScreen { void go(); }
|
||||||
|
namespace menu { void go(); }
|
||||||
|
namespace select { void go(); }
|
||||||
|
namespace sequence { void go(); }
|
||||||
|
}
|
||||||
332
moduleselect.cpp
332
moduleselect.cpp
@@ -1,4 +1,4 @@
|
|||||||
#include "moduleselect.h"
|
#include "modules.h"
|
||||||
|
|
||||||
#include "jgame.h"
|
#include "jgame.h"
|
||||||
#include "jdraw8.h"
|
#include "jdraw8.h"
|
||||||
@@ -8,166 +8,200 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "info.h"
|
#include "info.h"
|
||||||
|
|
||||||
ModuleSelect::ModuleSelect() {
|
namespace module
|
||||||
|
{
|
||||||
|
namespace select
|
||||||
|
{
|
||||||
|
void go()
|
||||||
|
{
|
||||||
|
// Inicialitzem gràfics
|
||||||
|
JD8_Surface fondo = JD8_LoadSurface("select.gif");
|
||||||
|
JD8_Palette pal = JD8_LoadPalette("select.gif");
|
||||||
|
JD8_Surface gfx = JD8_LoadSurface("sprites.gif");
|
||||||
|
|
||||||
}
|
int num_personatges = 3;
|
||||||
|
|
||||||
ModuleSelect::~ModuleSelect(void) {
|
// Llevem els persoantges que encara no estàn desbloquejats
|
||||||
}
|
if (!info::rosita_enabled)
|
||||||
|
{
|
||||||
void pintaMarc(int posicio) {
|
num_personatges--;
|
||||||
for (int i = posicio; i <= posicio + 75; i++) {
|
for (int i = 137; i <= 212; i++) for (int j = 11; j <= 91; j++) JD8_PutPixel(fondo, i, j, 0);
|
||||||
JD8_PutPixel(i, 11, 15);
|
JD8_PutPixel(fondo, 145, 19, 14);
|
||||||
JD8_PutPixel(i, 12, 15);
|
JD8_PutPixel(fondo, 197, 44, 14);
|
||||||
JD8_PutPixel(i, 90, 15);
|
JD8_PutPixel(fondo, 149, 78, 14);
|
||||||
JD8_PutPixel(i, 91, 15);
|
JD8_PutPixel(fondo, 194, 77, 14);
|
||||||
}
|
JD8_PutPixel(fondo, 172, 54, 14);
|
||||||
for (int i = 11; i <= 91; i++) {
|
JD8_PutPixel(fondo, 198, 65, 14);
|
||||||
JD8_PutPixel(posicio, i, 15);
|
JD8_PutPixel(fondo, 177, 38, 9);
|
||||||
JD8_PutPixel(posicio + 1, i, 15);
|
JD8_PutPixel(fondo, 169, 82, 9);
|
||||||
JD8_PutPixel(posicio + 74, i, 15);
|
JD8_PutPixel(fondo, 183, 12, 9);
|
||||||
JD8_PutPixel(posicio + 75, i, 15);
|
JD8_PutPixel(fondo, 139, 37, 9);
|
||||||
}
|
JD8_PutPixel(fondo, 211, 81, 9);
|
||||||
}
|
}
|
||||||
|
if (!info::job_enabled)
|
||||||
int ModuleSelect::Go() {
|
{
|
||||||
|
num_personatges--;
|
||||||
JD8_Surface fondo = JD8_LoadSurface("select.gif");
|
for (int i = 219; i <= 294; i++) for (int j = 11; j <= 91; j++) JD8_PutPixel(fondo, i, j, 0);
|
||||||
JD8_Palette pal = JD8_LoadPalette("select.gif");
|
JD8_PutPixel(fondo, 228, 65, 14);
|
||||||
JD8_Surface gfx = JD8_LoadSurface("sprites.gif");
|
JD8_PutPixel(fondo, 290, 26, 14);
|
||||||
|
JD8_PutPixel(fondo, 264, 63, 14);
|
||||||
int num_personatges = 3;
|
JD8_PutPixel(fondo, 284, 85, 14);
|
||||||
|
JD8_PutPixel(fondo, 262, 13, 14);
|
||||||
if (!info::rosita_enabled) {
|
JD8_PutPixel(fondo, 239, 46, 14);
|
||||||
num_personatges--;
|
JD8_PutPixel(fondo, 266, 74, 9);
|
||||||
for (int i = 137; i <= 212; i++) for (int j = 11; j <= 91; j++) JD8_PutPixel(fondo, i, j, 0);
|
JD8_PutPixel(fondo, 264, 21, 9);
|
||||||
JD8_PutPixel(fondo, 145, 19, 14);
|
JD8_PutPixel(fondo, 248, 84, 9);
|
||||||
JD8_PutPixel(fondo, 197, 44, 14);
|
JD8_PutPixel(fondo, 279, 87, 9);
|
||||||
JD8_PutPixel(fondo, 149, 78, 14);
|
JD8_PutPixel(fondo, 254, 39, 9);
|
||||||
JD8_PutPixel(fondo, 194, 77, 14);
|
|
||||||
JD8_PutPixel(fondo, 172, 54, 14);
|
|
||||||
JD8_PutPixel(fondo, 198, 65, 14);
|
|
||||||
JD8_PutPixel(fondo, 177, 38, 9);
|
|
||||||
JD8_PutPixel(fondo, 169, 82, 9);
|
|
||||||
JD8_PutPixel(fondo, 183, 12, 9);
|
|
||||||
JD8_PutPixel(fondo, 139, 37, 9);
|
|
||||||
JD8_PutPixel(fondo, 211, 81, 9);
|
|
||||||
}
|
|
||||||
if (!info::job_enabled) {
|
|
||||||
num_personatges--;
|
|
||||||
for (int i = 219; i <= 294; i++) for (int j = 11; j <= 91; j++) JD8_PutPixel(fondo, i, j, 0);
|
|
||||||
JD8_PutPixel(fondo, 228, 65, 14);
|
|
||||||
JD8_PutPixel(fondo, 290, 26, 14);
|
|
||||||
JD8_PutPixel(fondo, 264, 63, 14);
|
|
||||||
JD8_PutPixel(fondo, 284, 85, 14);
|
|
||||||
JD8_PutPixel(fondo, 262, 13, 14);
|
|
||||||
JD8_PutPixel(fondo, 239, 46, 14);
|
|
||||||
JD8_PutPixel(fondo, 266, 74, 9);
|
|
||||||
JD8_PutPixel(fondo, 264, 21, 9);
|
|
||||||
JD8_PutPixel(fondo, 248, 84, 9);
|
|
||||||
JD8_PutPixel(fondo, 279, 87, 9);
|
|
||||||
JD8_PutPixel(fondo, 254, 39, 9);
|
|
||||||
}
|
|
||||||
|
|
||||||
JD8_ClearScreen(0);
|
|
||||||
JD8_Flip();
|
|
||||||
|
|
||||||
// FADE IN
|
|
||||||
JD8_Blit(fondo);
|
|
||||||
JG_SetUpdateTicks(1);
|
|
||||||
while (!JD8_FadeToPalAsync(pal) && !JG_Quitting()) {
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
int opcio_seleccionada = info::dificultat;
|
|
||||||
int opcio_triada = SENSE_OPCIO;
|
|
||||||
int personatge_seleccionat = info::personatge;
|
|
||||||
bool fletxa_amunt_pulsada = false;
|
|
||||||
bool fletxa_avall_pulsada = false;
|
|
||||||
bool fletxa_esquerra_pulsada = false;
|
|
||||||
bool fletxa_dreta_pulsada = false;
|
|
||||||
|
|
||||||
JG_SetUpdateTicks(20);
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
int G = 0;
|
|
||||||
int B = 0;
|
|
||||||
|
|
||||||
while (!JG_Quitting() && opcio_triada == SENSE_OPCIO) {
|
|
||||||
while (!JG_ShouldUpdate()) {
|
|
||||||
JI_Update();
|
|
||||||
|
|
||||||
if (JI_KeyPressed(SDL_SCANCODE_UP)) {
|
|
||||||
if (!fletxa_amunt_pulsada) {
|
|
||||||
fletxa_amunt_pulsada = true;
|
|
||||||
opcio_seleccionada--; if (opcio_seleccionada < 0) opcio_seleccionada = 2;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fletxa_amunt_pulsada = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JI_KeyPressed(SDL_SCANCODE_DOWN)) {
|
JD8_ClearScreen(0);
|
||||||
if (!fletxa_avall_pulsada) {
|
JD8_Flip();
|
||||||
fletxa_avall_pulsada = true;
|
|
||||||
opcio_seleccionada++; if (opcio_seleccionada > 2) opcio_seleccionada = 0;
|
|
||||||
}
|
// Fade in
|
||||||
} else {
|
JD8_Blit(fondo);
|
||||||
fletxa_avall_pulsada = false;
|
JG_SetUpdateTicks(1);
|
||||||
|
while (!JD8_FadeToPalAsync(pal) && !JG_Quitting())
|
||||||
|
{
|
||||||
|
while (!JG_ShouldUpdate()) { JI_Update(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JI_KeyPressed(SDL_SCANCODE_LEFT)) {
|
// Variables necessaries per a triar personatge i dificultat
|
||||||
if (!fletxa_esquerra_pulsada) {
|
int opcio_seleccionada = info::dificultat;
|
||||||
fletxa_esquerra_pulsada = true;
|
int opcio_triada = SENSE_OPCIO;
|
||||||
personatge_seleccionat--; if (personatge_seleccionat < 0) personatge_seleccionat = num_personatges-1;
|
int personatge_seleccionat = info::personatge;
|
||||||
|
bool fletxa_amunt_pulsada = false;
|
||||||
|
bool fletxa_avall_pulsada = false;
|
||||||
|
bool fletxa_esquerra_pulsada = false;
|
||||||
|
bool fletxa_dreta_pulsada = false;
|
||||||
|
|
||||||
|
JG_SetUpdateTicks(20);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
int G = 0;
|
||||||
|
int B = 0;
|
||||||
|
|
||||||
|
|
||||||
|
// Ací se controla la tria de opcions en sí
|
||||||
|
while (!JG_Quitting() && opcio_triada == SENSE_OPCIO)
|
||||||
|
{
|
||||||
|
while (!JG_ShouldUpdate())
|
||||||
|
{
|
||||||
|
JI_Update();
|
||||||
|
|
||||||
|
if (JI_KeyPressed(SDL_SCANCODE_UP))
|
||||||
|
{
|
||||||
|
if (!fletxa_amunt_pulsada)
|
||||||
|
{
|
||||||
|
fletxa_amunt_pulsada = true;
|
||||||
|
opcio_seleccionada--; if (opcio_seleccionada < 0) opcio_seleccionada = 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fletxa_amunt_pulsada = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JI_KeyPressed(SDL_SCANCODE_DOWN))
|
||||||
|
{
|
||||||
|
if (!fletxa_avall_pulsada)
|
||||||
|
{
|
||||||
|
fletxa_avall_pulsada = true;
|
||||||
|
opcio_seleccionada++; if (opcio_seleccionada > 2) opcio_seleccionada = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fletxa_avall_pulsada = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JI_KeyPressed(SDL_SCANCODE_LEFT))
|
||||||
|
{
|
||||||
|
if (!fletxa_esquerra_pulsada)
|
||||||
|
{
|
||||||
|
fletxa_esquerra_pulsada = true;
|
||||||
|
personatge_seleccionat--; if (personatge_seleccionat < 0) personatge_seleccionat = num_personatges-1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fletxa_esquerra_pulsada = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JI_KeyPressed(SDL_SCANCODE_RIGHT))
|
||||||
|
{
|
||||||
|
if (!fletxa_dreta_pulsada)
|
||||||
|
{
|
||||||
|
fletxa_dreta_pulsada = true;
|
||||||
|
personatge_seleccionat++; if (personatge_seleccionat > num_personatges-1) personatge_seleccionat = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fletxa_dreta_pulsada = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (JI_KeyPressed(SDL_SCANCODE_SPACE))
|
||||||
|
{
|
||||||
|
opcio_triada = opcio_seleccionada;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
fletxa_esquerra_pulsada = false;
|
// Fer cicle dels colorets de la vora del personatge
|
||||||
|
i = (i + 1) % 127;
|
||||||
|
G = B = abs(63-i);
|
||||||
|
JD8_SetPaletteColor(15, 252, G, B);
|
||||||
|
|
||||||
|
|
||||||
|
// Pintar-ho tot
|
||||||
|
JD8_Blit(fondo);
|
||||||
|
|
||||||
|
const int posicio = 55 + personatge_seleccionat * 82;
|
||||||
|
for (int i = posicio; i <= posicio + 75; i++) {
|
||||||
|
JD8_PutPixel(i, 11, 15);
|
||||||
|
JD8_PutPixel(i, 12, 15);
|
||||||
|
JD8_PutPixel(i, 90, 15);
|
||||||
|
JD8_PutPixel(i, 91, 15);
|
||||||
|
}
|
||||||
|
for (int i = 11; i <= 91; i++) {
|
||||||
|
JD8_PutPixel(posicio, i, 15);
|
||||||
|
JD8_PutPixel(posicio + 1, i, 15);
|
||||||
|
JD8_PutPixel(posicio + 74, i, 15);
|
||||||
|
JD8_PutPixel(posicio + 75, i, 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
JD8_BlitCK(100, 120 + opcio_seleccionada * 25, gfx, 9, 5, 9, 10, 255);
|
||||||
|
JD8_Flip();
|
||||||
|
}
|
||||||
|
JD8_BlitCKToSurface(100, 120 + opcio_seleccionada * 25, gfx, 9, 5, 9, 10, fondo, 255);
|
||||||
|
|
||||||
|
|
||||||
|
// Fade out
|
||||||
|
JG_SetUpdateTicks(2);
|
||||||
|
while (!JD8_FadeOutAsync() && !JG_Quitting())
|
||||||
|
{
|
||||||
|
while (!JG_ShouldUpdate()) { JI_Update(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JI_KeyPressed(SDL_SCANCODE_RIGHT)) {
|
// Alliberem memòria
|
||||||
if (!fletxa_dreta_pulsada) {
|
JD8_FreeSurface(fondo);
|
||||||
fletxa_dreta_pulsada = true;
|
JD8_FreeSurface(gfx);
|
||||||
personatge_seleccionat++; if (personatge_seleccionat > num_personatges-1) personatge_seleccionat = 0;
|
free(pal);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fletxa_dreta_pulsada = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (JI_KeyPressed(SDL_SCANCODE_SPACE)) {
|
|
||||||
opcio_triada = opcio_seleccionada;
|
// Canviar el estat al que toque
|
||||||
|
if (JG_Quitting())
|
||||||
|
{
|
||||||
|
info::estat_joc = ESTAT_EIXIR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
info::dificultat = opcio_triada;
|
||||||
|
info::personatge = personatge_seleccionat;
|
||||||
|
info::estat_joc = ESTAT_SEQUENCIA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
i = (i + 1) % 127;
|
|
||||||
G = B = abs(63-i);
|
|
||||||
JD8_SetPaletteColor(15, 252, G, B);
|
|
||||||
|
|
||||||
JD8_Blit(fondo);
|
|
||||||
pintaMarc(55 + personatge_seleccionat * 82);
|
|
||||||
JD8_BlitCK(100, 120 + opcio_seleccionada * 25, gfx, 9, 5, 9, 10, 255);
|
|
||||||
JD8_Flip();
|
|
||||||
}
|
|
||||||
JD8_BlitCKToSurface(100, 120 + opcio_seleccionada * 25, gfx, 9, 5, 9, 10, fondo, 255);
|
|
||||||
|
|
||||||
// FADE OUT
|
|
||||||
JG_SetUpdateTicks(2);
|
|
||||||
while (!JD8_FadeOutAsync() && !JG_Quitting()) {
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
// FREE EVERYTHING
|
|
||||||
JD8_FreeSurface(fondo);
|
|
||||||
JD8_FreeSurface(gfx);
|
|
||||||
free(pal);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (JG_Quitting()) {
|
|
||||||
return ESTAT_EIXIR;
|
|
||||||
} else {
|
|
||||||
info::dificultat = opcio_triada;
|
|
||||||
info::personatge = personatge_seleccionat;
|
|
||||||
return ESTAT_SEQUENCIA;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
class ModuleSelect {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
ModuleSelect();
|
|
||||||
~ModuleSelect(void);
|
|
||||||
|
|
||||||
int Go();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
};
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "modulesequence.h"
|
#include "modules.h"
|
||||||
|
|
||||||
#include "jgame.h"
|
#include "jgame.h"
|
||||||
#include "jdraw8.h"
|
#include "jdraw8.h"
|
||||||
@@ -8,222 +8,193 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "info.h"
|
#include "info.h"
|
||||||
|
|
||||||
JD8_Surface gfx = nullptr;
|
namespace module
|
||||||
JD8_Surface fondo = nullptr;
|
{
|
||||||
JD8_Palette pal = nullptr;
|
namespace sequence
|
||||||
|
{
|
||||||
|
JD8_Surface gfx = nullptr;
|
||||||
|
JD8_Surface fondo = nullptr;
|
||||||
|
JD8_Surface fondo_temp = nullptr;
|
||||||
|
JD8_Palette pal = nullptr;
|
||||||
|
|
||||||
ModuleSequence::ModuleSequence() {
|
void fadeIn()
|
||||||
gfx = nullptr;
|
{
|
||||||
fondo = nullptr;
|
|
||||||
pal = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
ModuleSequence::~ModuleSequence(void) {
|
|
||||||
}
|
|
||||||
|
|
||||||
int ModuleSequence::Go() {
|
|
||||||
|
|
||||||
JS_LoadMusic("mhist.mid");
|
|
||||||
JS_PlayMusic(-1);
|
|
||||||
|
|
||||||
gfx = JD8_LoadSurface("sprites.gif");
|
|
||||||
|
|
||||||
JD8_ClearScreen(0);
|
|
||||||
JD8_Flip();
|
|
||||||
|
|
||||||
fondo = JD8_LoadSurface("hist01.gif");
|
|
||||||
pal = JD8_LoadPalette("hist01.gif");
|
|
||||||
this->FadeIn();
|
|
||||||
this->ShowText(40, 90, 2, 10, "QUE BON DIA FA NO CREUS PEPE");
|
|
||||||
this->ShowText(50, 80, 10, 10, "EEEE..SS..SSIII.SI");
|
|
||||||
this->ShowText(140, 140, 2, 10, "[SEMPRE QUE M^ACOSTE", "A PEPE ES POSA RARO\\");
|
|
||||||
JD8_Blit(fondo);
|
|
||||||
JD8_Flip();
|
|
||||||
this->Wait(200);
|
|
||||||
this->FadeOut();
|
|
||||||
JD8_FreeSurface(fondo);
|
|
||||||
free(pal);
|
|
||||||
|
|
||||||
if (!JG_Quitting()) {
|
|
||||||
fondo = JD8_LoadSurface("hist02.gif");
|
|
||||||
pal = JD8_LoadPalette("hist02.gif");
|
|
||||||
this->FadeIn();
|
|
||||||
this->ShowText(100, 140, 10, 10, "AAAAY a");
|
|
||||||
this->ShowText(100, 55, 3, 10, "JA T^HE PILLAT PEPE");
|
|
||||||
this->ShowText(145, 125, 2, 1, "AUXILIa");
|
|
||||||
JD8_Blit(fondo);
|
|
||||||
JD8_Flip();
|
|
||||||
this->Wait(200);
|
|
||||||
this->FadeOut();
|
|
||||||
JD8_FreeSurface(fondo);
|
|
||||||
free(pal);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!JG_Quitting()) {
|
|
||||||
fondo = JD8_LoadSurface("hist03.gif");
|
|
||||||
pal = JD8_LoadPalette("hist03.gif");
|
|
||||||
this->FadeIn();
|
|
||||||
this->ShowText(50, 80, 5, 10, "ARA ROSITA ES MEUA");
|
|
||||||
this->ShowText(50, 80, 5, 10, "SI VOLS ACONSEGUIR_LA", "HAURAS DE SEGUIR_ME", "PER TOT EL MONb");
|
|
||||||
this->ShowText(60, 80, 5, 1, "JA JA JA JA JA aa");
|
|
||||||
JD8_Blit(fondo);
|
|
||||||
JD8_Flip();
|
|
||||||
this->Wait(200);
|
|
||||||
this->FadeOut();
|
|
||||||
JD8_FreeSurface(fondo);
|
|
||||||
free(pal);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!JG_Quitting()) {
|
|
||||||
fondo = JD8_LoadSurface("hist04.gif");
|
|
||||||
pal = JD8_LoadPalette("hist04.gif");
|
|
||||||
this->FadeIn();
|
|
||||||
this->ShowText(120, 60, 2, 5, "AJUDA^M PEPEa");
|
|
||||||
this->ShowText(50, 50, 7, 50, "MALEIT SIGUES", "ET TROBAREbbb");
|
|
||||||
this->FadeOut();
|
|
||||||
JD8_FreeSurface(fondo);
|
|
||||||
free(pal);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FREE EVERYTHING
|
|
||||||
JD8_FreeSurface(gfx);
|
|
||||||
|
|
||||||
if (JG_Quitting()) {
|
|
||||||
return ESTAT_EIXIR;
|
|
||||||
} else {
|
|
||||||
return ESTAT_JOC;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModuleSequence::FadeIn() {
|
|
||||||
JD8_Blit(fondo);
|
|
||||||
JG_SetUpdateTicks(1);
|
|
||||||
while (!JD8_FadeToPalAsync(pal) && !JG_Quitting()) {
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModuleSequence::FadeOut() {
|
|
||||||
JG_SetUpdateTicks(2);
|
|
||||||
while (!JD8_FadeOutAsync() && !JG_Quitting()) {
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModuleSequence::ShowText(int x, int y, int color, int speed, const char * text1, const char * text2, const char * text3) {
|
|
||||||
bool eixir = false;
|
|
||||||
|
|
||||||
JG_SetUpdateTicks(10);
|
|
||||||
JD8_SetPaletteColor(254, color);
|
|
||||||
|
|
||||||
// mod 35
|
|
||||||
// A (65) = 23 -> char - 42
|
|
||||||
// Special chars: ( ) <20> ' - : ! .
|
|
||||||
// [ \ ] ^ _ ` a b
|
|
||||||
|
|
||||||
int tamany_text1 = strlen(text1);
|
|
||||||
int temps_total = tamany_text1 * speed;
|
|
||||||
int temps_inicial = JG_GetCycleCounter();
|
|
||||||
|
|
||||||
while ((JG_GetCycleCounter() - temps_inicial < temps_total) && !eixir && !JG_Quitting()) {
|
|
||||||
JD8_Blit(fondo);
|
|
||||||
int num_chars_actual = (JG_GetCycleCounter() - temps_inicial) / speed;
|
|
||||||
|
|
||||||
for (int i = 0; i <= num_chars_actual; i++) {
|
|
||||||
int char_actual = text1[i] - 42; if (char_actual < 0) char_actual = 57;
|
|
||||||
if (text1[i] == '.') char_actual = 56;
|
|
||||||
JD8_BlitCK(x + (i+1) * 8, y, gfx, (char_actual % 35) * 9, 6+floorf(char_actual / 35) * 9, 9, 9, 255);
|
|
||||||
}
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey()) { eixir = true; } }
|
|
||||||
JD8_Flip();
|
|
||||||
}
|
|
||||||
if (eixir) {
|
|
||||||
for (int i = 0; i <= tamany_text1; i++) {
|
|
||||||
int char_actual = text1[i] - 42; if (char_actual < 0) char_actual = 57;
|
|
||||||
if (text1[i] == '.') char_actual = 56;
|
|
||||||
JD8_BlitCK(x + (i + 1) * 8, y, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, 255);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (text2 != NULL) {
|
|
||||||
int tamany_text2 = strlen(text2);
|
|
||||||
temps_total = tamany_text2 * speed;
|
|
||||||
temps_inicial = JG_GetCycleCounter();
|
|
||||||
|
|
||||||
while ((JG_GetCycleCounter() - temps_inicial < temps_total) && !eixir && !JG_Quitting()) {
|
|
||||||
JD8_Blit(fondo);
|
JD8_Blit(fondo);
|
||||||
int num_chars_actual = (JG_GetCycleCounter() - temps_inicial) / speed;
|
JG_SetUpdateTicks(1);
|
||||||
|
while (!JD8_FadeToPalAsync(pal) && !JG_Quitting())
|
||||||
for (int i = 0; i <= tamany_text1; i++) {
|
{
|
||||||
int char_actual = text1[i] - 42; if (char_actual < 0) char_actual = 57;
|
while (!JG_ShouldUpdate()) { JI_Update(); }
|
||||||
if (text1[i] == '.') char_actual = 56;
|
|
||||||
JD8_BlitCK(x + (i + 1) * 8, y, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i <= num_chars_actual; i++) {
|
|
||||||
int char_actual = text2[i] - 42; if (char_actual < 0) char_actual = 57;
|
|
||||||
if (text2[i] == '.') char_actual = 56;
|
|
||||||
JD8_BlitCK(x + (i + 1) * 8, y+10, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, 255);
|
|
||||||
}
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey()) { eixir = true; } }
|
|
||||||
JD8_Flip();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eixir) {
|
|
||||||
for (int i = 0; i <= tamany_text2; i++) {
|
|
||||||
int char_actual = text2[i] - 42; if (char_actual < 0) char_actual = 57;
|
|
||||||
if (text2[i] == '.') char_actual = 56;
|
|
||||||
JD8_BlitCK(x + (i + 1) * 8, y + 10, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, 255);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text3 != NULL) {
|
void fadeOut()
|
||||||
int tamany_text3 = strlen(text3);
|
{
|
||||||
temps_total = tamany_text3 * speed;
|
JG_SetUpdateTicks(2);
|
||||||
temps_inicial = JG_GetCycleCounter();
|
while (!JD8_FadeOutAsync() && !JG_Quitting())
|
||||||
|
{
|
||||||
|
while (!JG_ShouldUpdate()) { JI_Update(); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while ((JG_GetCycleCounter() - temps_inicial < temps_total) && !eixir && !JG_Quitting()) {
|
void drawChar(int x, int y, char char_actual)
|
||||||
JD8_Blit(fondo);
|
{
|
||||||
|
char_actual -= 42; if (char_actual < 0) char_actual = 57;
|
||||||
|
if (char_actual == 4) char_actual = 56;
|
||||||
|
JD8_BlitCKToSurface(x, y, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, fondo_temp, 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wait(int time)
|
||||||
|
{
|
||||||
|
bool eixir = false;
|
||||||
|
int temps_inicial = JG_GetCycleCounter();
|
||||||
|
while ((JG_GetCycleCounter() - temps_inicial < time) && !eixir)
|
||||||
|
{
|
||||||
|
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey() || JG_Quitting()) { eixir = true; } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void showText(int x, int y, int color, int speed, const char * text1, const char * text2 = NULL, const char * text3 = NULL)
|
||||||
|
{
|
||||||
|
bool eixir = false;
|
||||||
|
|
||||||
|
fondo_temp = JD8_NewSurface();
|
||||||
|
JD8_BlitToSurface(0, 0, fondo, 0, 0, 320, 200, fondo_temp);
|
||||||
|
JD8_Blit(fondo_temp);
|
||||||
|
|
||||||
|
JG_SetUpdateTicks(10);
|
||||||
|
JD8_SetPaletteColor(254, color);
|
||||||
|
|
||||||
|
// mod 35
|
||||||
|
// A (65) = 23 -> char - 42
|
||||||
|
// Special chars: ( ) <20> ' - : ! .
|
||||||
|
// [ \ ] ^ _ ` a b
|
||||||
|
|
||||||
|
int tamany_text = strlen(text1);
|
||||||
|
int temps_total = tamany_text * speed;
|
||||||
|
int temps_inicial = JG_GetCycleCounter();
|
||||||
|
|
||||||
|
while ((JG_GetCycleCounter() - temps_inicial < temps_total) && !eixir && !JG_Quitting())
|
||||||
|
{
|
||||||
int num_chars_actual = (JG_GetCycleCounter() - temps_inicial) / speed;
|
int num_chars_actual = (JG_GetCycleCounter() - temps_inicial) / speed;
|
||||||
|
drawChar(x + (num_chars_actual + 1) * 8, y, text1[num_chars_actual]);
|
||||||
|
|
||||||
for (int i = 0; i <= tamany_text1; i++) {
|
|
||||||
int char_actual = text1[i] - 42; if (char_actual < 0) char_actual = 57;
|
|
||||||
if (text1[i] == '.') char_actual = 56;
|
|
||||||
JD8_BlitCK(x + (i + 1) * 8, y, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i <= tamany_text2; i++) {
|
|
||||||
int char_actual = text2[i] - 42; if (char_actual < 0) char_actual = 57;
|
|
||||||
if (text2[i] == '.') char_actual = 56;
|
|
||||||
JD8_BlitCK(x + (i + 1) * 8, y+10, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i <= num_chars_actual; i++) {
|
|
||||||
int char_actual = text3[i] - 42; if (char_actual < 0) char_actual = 57;
|
|
||||||
if (text3[i] == '.') char_actual = 56;
|
|
||||||
JD8_BlitCK(x + (i + 1) * 8, y + 20, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, 255);
|
|
||||||
}
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey()) { eixir = true; } }
|
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey()) { eixir = true; } }
|
||||||
|
JD8_Blit(fondo_temp);
|
||||||
JD8_Flip();
|
JD8_Flip();
|
||||||
}
|
}
|
||||||
|
if (eixir) for (int i = 0; i <= tamany_text; i++) drawChar(x + (i + 1) * 8, y, text1[i]);
|
||||||
|
|
||||||
for (int i = 0; i <= tamany_text3; i++) {
|
|
||||||
int char_actual = text3[i] - 42; if (char_actual < 0) char_actual = 57;
|
if (text2 != NULL)
|
||||||
if (text3[i] == '.') char_actual = 56;
|
{
|
||||||
JD8_BlitCK(x + (i + 1) * 8, y + 20, gfx, (char_actual % 35) * 9, 6 + floorf(char_actual / 35) * 9, 9, 9, 255);
|
tamany_text = strlen(text2);
|
||||||
|
temps_total = tamany_text * speed;
|
||||||
|
temps_inicial = JG_GetCycleCounter();
|
||||||
|
|
||||||
|
while ((JG_GetCycleCounter() - temps_inicial < temps_total) && !eixir && !JG_Quitting())
|
||||||
|
{
|
||||||
|
int num_chars_actual = (JG_GetCycleCounter() - temps_inicial) / speed;
|
||||||
|
drawChar(x + (num_chars_actual + 1) * 8, y+10, text2[num_chars_actual]);
|
||||||
|
|
||||||
|
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey()) { eixir = true; } }
|
||||||
|
JD8_Blit(fondo_temp);
|
||||||
|
JD8_Flip();
|
||||||
|
}
|
||||||
|
if (eixir) for (int i = 0; i <= tamany_text; i++) drawChar(x + (i + 1) * 8, y+10, text2[i]);
|
||||||
|
|
||||||
|
if (text3 != NULL)
|
||||||
|
{
|
||||||
|
tamany_text = strlen(text3);
|
||||||
|
temps_total = tamany_text * speed;
|
||||||
|
temps_inicial = JG_GetCycleCounter();
|
||||||
|
|
||||||
|
while ((JG_GetCycleCounter() - temps_inicial < temps_total) && !eixir && !JG_Quitting())
|
||||||
|
{
|
||||||
|
int num_chars_actual = (JG_GetCycleCounter() - temps_inicial) / speed;
|
||||||
|
drawChar(x + (num_chars_actual + 1) * 8, y+20, text3[num_chars_actual]);
|
||||||
|
|
||||||
|
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey()) { eixir = true; } }
|
||||||
|
JD8_Blit(fondo_temp);
|
||||||
|
JD8_Flip();
|
||||||
|
}
|
||||||
|
if (eixir) for (int i = 0; i <= tamany_text; i++) drawChar(x + (i + 1) * 8, y+10, text3[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JD8_Blit(fondo_temp);
|
||||||
JD8_Flip();
|
JD8_Flip();
|
||||||
|
wait(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
void go()
|
||||||
|
{
|
||||||
|
JS_LoadMusic("mhist.mid");
|
||||||
|
JS_PlayMusic(-1);
|
||||||
|
|
||||||
|
gfx = JD8_LoadSurface("sprites.gif");
|
||||||
|
|
||||||
|
JD8_ClearScreen(0);
|
||||||
|
JD8_Flip();
|
||||||
|
|
||||||
|
fondo = JD8_LoadSurface("hist01.gif");
|
||||||
|
pal = JD8_LoadPalette("hist01.gif");
|
||||||
|
fadeIn();
|
||||||
|
showText(40, 90, 2, 10, "QUE BON DIA FA NO CREUS PEPE");
|
||||||
|
showText(50, 80, 10, 10, "EEEE..SS..SSIII.SI");
|
||||||
|
showText(140, 140, 2, 10, "[SEMPRE QUE M^ACOSTE", "A PEPE ES POSA RARO\\");
|
||||||
|
wait(200);
|
||||||
|
fadeOut();
|
||||||
|
JD8_FreeSurface(fondo);
|
||||||
|
free(pal);
|
||||||
|
|
||||||
|
if (!JG_Quitting())
|
||||||
|
{
|
||||||
|
fondo = JD8_LoadSurface("hist02.gif");
|
||||||
|
pal = JD8_LoadPalette("hist02.gif");
|
||||||
|
fadeIn();
|
||||||
|
showText(100, 140, 10, 10, "AAAAY a");
|
||||||
|
showText(100, 55, 3, 10, "JA T^HE PILLAT PEPE");
|
||||||
|
showText(145, 125, 2, 1, "AUXILIa");
|
||||||
|
wait(200);
|
||||||
|
fadeOut();
|
||||||
|
JD8_FreeSurface(fondo);
|
||||||
|
free(pal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!JG_Quitting())
|
||||||
|
{
|
||||||
|
fondo = JD8_LoadSurface("hist03.gif");
|
||||||
|
pal = JD8_LoadPalette("hist03.gif");
|
||||||
|
fadeIn();
|
||||||
|
showText(50, 80, 5, 10, "ARA ROSITA ES MEUA");
|
||||||
|
showText(50, 80, 5, 10, "SI VOLS ACONSEGUIR_LA", "HAURAS DE SEGUIR_ME", "PER TOT EL MONb");
|
||||||
|
showText(60, 80, 5, 1, "JA JA JA JA JA aa");
|
||||||
|
wait(200);
|
||||||
|
fadeOut();
|
||||||
|
JD8_FreeSurface(fondo);
|
||||||
|
free(pal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!JG_Quitting())
|
||||||
|
{
|
||||||
|
fondo = JD8_LoadSurface("hist04.gif");
|
||||||
|
pal = JD8_LoadPalette("hist04.gif");
|
||||||
|
fadeIn();
|
||||||
|
showText(120, 60, 2, 5, "AJUDA^M PEPEa");
|
||||||
|
showText(50, 50, 7, 50, "MALEIT SIGUES", "ET TROBAREbbb");
|
||||||
|
fadeOut();
|
||||||
|
JD8_FreeSurface(fondo);
|
||||||
|
free(pal);
|
||||||
|
}
|
||||||
|
|
||||||
|
// FREE EVERYTHING
|
||||||
|
JD8_FreeSurface(gfx);
|
||||||
|
|
||||||
|
if (JG_Quitting()) {
|
||||||
|
info::estat_joc = ESTAT_EIXIR;
|
||||||
|
} else {
|
||||||
|
info::estat_joc = ESTAT_MENU;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JD8_Flip();
|
|
||||||
Wait(200);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModuleSequence::Wait(int time) {
|
|
||||||
bool eixir = false;
|
|
||||||
int temps_inicial = JG_GetCycleCounter();
|
|
||||||
while ((JG_GetCycleCounter() - temps_inicial < time) && !eixir) {
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey() || JG_Quitting()) { eixir = true; } }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
class ModuleSequence {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
ModuleSequence();
|
|
||||||
~ModuleSequence(void);
|
|
||||||
|
|
||||||
int Go();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void FadeIn();
|
|
||||||
void FadeOut();
|
|
||||||
void ShowText(int x, int y, int color, int speed, const char* text1, const char* text2 = nullptr, const char* text3 = nullptr);
|
|
||||||
void Wait(int time);
|
|
||||||
};
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "modulestaticscreen.h"
|
#include "modules.h"
|
||||||
|
|
||||||
#include "jgame.h"
|
#include "jgame.h"
|
||||||
#include "jdraw8.h"
|
#include "jdraw8.h"
|
||||||
@@ -8,106 +8,82 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include "info.h"
|
#include "info.h"
|
||||||
|
|
||||||
ModuleStaticScreen::ModuleStaticScreen() {
|
|
||||||
|
|
||||||
}
|
namespace module
|
||||||
|
{
|
||||||
|
namespace staticScreen
|
||||||
|
{
|
||||||
|
void go()
|
||||||
|
{
|
||||||
|
bool eixir = false;
|
||||||
|
JD8_Surface gfx = nullptr;
|
||||||
|
JD8_Palette pal = nullptr;
|
||||||
|
|
||||||
ModuleStaticScreen::~ModuleStaticScreen(void) {
|
// Carrega grafics i música
|
||||||
}
|
switch( info::estat_joc ) {
|
||||||
|
case ESTAT_ICEKAS:
|
||||||
|
JS_LoadMusic("mlogo.mid");
|
||||||
|
JS_PlayMusic(1);
|
||||||
|
|
||||||
int ModuleStaticScreen::Go() {
|
gfx = JD8_LoadSurface( "logo.gif" );
|
||||||
|
pal = JD8_LoadPalette( "logo.gif" );
|
||||||
|
break;
|
||||||
|
|
||||||
switch( info::estat_joc ) {
|
case ESTAT_LOGO:
|
||||||
case ESTAT_ICEKAS:
|
gfx = JD8_LoadSurface("titol.gif");
|
||||||
doIcekas();
|
pal = JD8_LoadPalette("titol.gif");
|
||||||
break;
|
break;
|
||||||
case ESTAT_LOGO:
|
}
|
||||||
doLogo();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
JD8_FadeOut();
|
// Fade in
|
||||||
|
JD8_Blit(gfx);
|
||||||
|
JG_SetUpdateTicks(8);
|
||||||
|
while (!JD8_FadeToPalAsync(pal))
|
||||||
|
{
|
||||||
|
while (!JG_ShouldUpdate())
|
||||||
|
{
|
||||||
|
JI_Update();
|
||||||
|
if (JI_AnyKey() || JG_Quitting())
|
||||||
|
{
|
||||||
|
eixir = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( JG_Quitting() ) {
|
// DELAY
|
||||||
return ESTAT_EIXIR;
|
JG_SetUpdateTicks(100);
|
||||||
} else {
|
int contador = 20;
|
||||||
switch (info::estat_joc) {
|
while (contador > 0 && !eixir) {
|
||||||
case ESTAT_ICEKAS: return ESTAT_LOGO; break;
|
contador--;
|
||||||
case ESTAT_LOGO: return ESTAT_MENU; break;
|
while (!JG_ShouldUpdate())
|
||||||
|
{
|
||||||
|
JI_Update();
|
||||||
|
if (JI_AnyKey() || JG_Quitting())
|
||||||
|
{
|
||||||
|
eixir = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// FADE OUT
|
||||||
|
JG_SetUpdateTicks(2);
|
||||||
|
while (!JD8_FadeOutAsync()) {
|
||||||
|
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey() || JG_Quitting()) { eixir = true; } }
|
||||||
|
}
|
||||||
|
|
||||||
|
JD8_FreeSurface( gfx );
|
||||||
|
free(pal);
|
||||||
|
|
||||||
|
//JD8_FadeOut();
|
||||||
|
|
||||||
|
if( JG_Quitting() ) {
|
||||||
|
info::estat_joc = ESTAT_EIXIR;
|
||||||
|
} else {
|
||||||
|
switch (info::estat_joc) {
|
||||||
|
case ESTAT_ICEKAS: info::estat_joc = ESTAT_LOGO; break;
|
||||||
|
case ESTAT_LOGO: info::estat_joc = ESTAT_MENU; break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModuleStaticScreen::doIcekas() {
|
|
||||||
|
|
||||||
bool eixir = false;
|
|
||||||
|
|
||||||
JS_LoadMusic("mlogo.mid");
|
|
||||||
JS_PlayMusic(1);
|
|
||||||
|
|
||||||
JD8_Surface gfx = JD8_LoadSurface( "logo.gif" );
|
|
||||||
JD8_Palette pal = JD8_LoadPalette( "logo.gif" );
|
|
||||||
|
|
||||||
JD8_ClearScreen( 0 );
|
|
||||||
JD8_Flip();
|
|
||||||
|
|
||||||
// FADE IN
|
|
||||||
JD8_Blit(gfx);
|
|
||||||
JG_SetUpdateTicks(8);
|
|
||||||
while (!JD8_FadeToPalAsync(pal) && !eixir) {
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey() || JG_Quitting()) { eixir = true; } }
|
|
||||||
}
|
|
||||||
|
|
||||||
// DELAY
|
|
||||||
JG_SetUpdateTicks(100);
|
|
||||||
int contador = 20;
|
|
||||||
while (contador > 0 && !eixir) {
|
|
||||||
contador--;
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey() || JG_Quitting()) { eixir = true; } }
|
|
||||||
}
|
|
||||||
|
|
||||||
// FADE OUT
|
|
||||||
JG_SetUpdateTicks(2);
|
|
||||||
while (!JD8_FadeOutAsync() && !eixir) {
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey() || JG_Quitting()) { eixir = true; } }
|
|
||||||
}
|
|
||||||
|
|
||||||
JD8_FreeSurface( gfx );
|
|
||||||
free(pal);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ModuleStaticScreen::doLogo() {
|
|
||||||
|
|
||||||
bool eixir = false;
|
|
||||||
|
|
||||||
JD8_Surface gfx = JD8_LoadSurface("titol.gif");
|
|
||||||
JD8_Palette pal = JD8_LoadPalette("titol.gif");
|
|
||||||
|
|
||||||
JD8_ClearScreen(0);
|
|
||||||
JD8_Flip();
|
|
||||||
|
|
||||||
// FADE IN
|
|
||||||
JD8_Blit(gfx);
|
|
||||||
JG_SetUpdateTicks(8);
|
|
||||||
while (!JD8_FadeToPalAsync(pal) && !eixir) {
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey() || JG_Quitting()) { eixir = true; } }
|
|
||||||
}
|
|
||||||
|
|
||||||
// DELAY
|
|
||||||
JG_SetUpdateTicks(100);
|
|
||||||
int contador = 20;
|
|
||||||
while (contador > 0 && !eixir) {
|
|
||||||
contador--;
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey() || JG_Quitting()) { eixir = true; } }
|
|
||||||
}
|
|
||||||
|
|
||||||
// FADE OUT
|
|
||||||
JG_SetUpdateTicks(2);
|
|
||||||
while (!JD8_FadeOutAsync() && !eixir) {
|
|
||||||
while (!JG_ShouldUpdate()) { JI_Update(); if (JI_AnyKey() || JG_Quitting()) { eixir = true; } }
|
|
||||||
}
|
|
||||||
|
|
||||||
JD8_FreeSurface(gfx);
|
|
||||||
free(pal);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
#pragma once
|
|
||||||
|
|
||||||
class ModuleStaticScreen {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
ModuleStaticScreen();
|
|
||||||
~ModuleStaticScreen(void);
|
|
||||||
|
|
||||||
int Go();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void doIcekas();
|
|
||||||
void doLogo();
|
|
||||||
|
|
||||||
int contador;
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user