Compare commits

...

6 Commits

19 changed files with 697 additions and 736 deletions

2
.gitignore vendored
View File

@@ -1,12 +1,14 @@
syntax: glob
pepe
pepe_debug
recursos/*
bin/*
obj/*
Debug/*
Release/*
data/*
build/*
*.suo
*.sdf
*.opensdf

2
Makefile Normal file
View File

@@ -0,0 +1,2 @@
build:
g++ -g *.cpp -lSDL2 -lSDL2_mixer -o pepe_debug

View File

@@ -434,6 +434,9 @@ static unsigned char* process_gif_stream(unsigned char *buffer, unsigned short*
// sizeof( screen_descriptor_t ) = 8!
READ(&screen_descriptor, 7);
if (w) *w = screen_descriptor.width;
if (h) *h = screen_descriptor.height;
color_resolution_bits = ( ( screen_descriptor.fields & 0x70 ) >> 4 ) + 1;
if ( screen_descriptor.fields & 0x80 )

10
info.cpp Normal file
View File

@@ -0,0 +1,10 @@
#include "info.h"
namespace info
{
int estat_joc;
bool rosita_enabled;
bool job_enabled;
int dificultat;
int personatge;
}

14
info.h
View File

@@ -21,10 +21,10 @@
#define PERSONATGE_ROSITA 1
#define PERSONATGE_JOB 2
struct Info {
int estat_joc;
bool rosita_enabled;
bool job_enabled;
int dificultat;
int personatge;
};
namespace info{
extern int estat_joc;
extern bool rosita_enabled;
extern bool job_enabled;
extern int dificultat;
extern int personatge;
}

View File

@@ -1,7 +1,7 @@
#include "jdraw8.h"
#include "jfile.h"
#include <fstream>
#include "gif.c"
#include "gif.h"
#ifdef GCWZERO
#define SCREEN_WIDTH 320
@@ -27,15 +27,15 @@ SDL_Renderer* sdlRenderer = NULL;
SDL_Texture* sdlTexture = NULL;
void JD8_Init(const char *title) {
screen = (JD8_Surface)calloc( 1, 64000 );
main_palette = (JD8_Palette)calloc( 1, 768 );
screen = (JD8_Surface)calloc( 1, 320 * 200 );
main_palette = (JD8_Palette)calloc( 1, 256 * sizeof(uint32_t) );
pixel_data = (Uint32*)calloc(1, 320 * 200 * 4); // 1048576 );
sdlWindow = SDL_CreateWindow( title, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
sdlWindow = SDL_CreateWindow( title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_WIDTH, SCREEN_HEIGHT, SDL_WINDOW_SHOWN );
sdlRenderer = SDL_CreateRenderer(sdlWindow, -1, 0);
SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "nearest");
sdlTexture = SDL_CreateTexture(sdlRenderer, SDL_PIXELFORMAT_ABGR8888, SDL_TEXTUREACCESS_STREAMING, 320, 200);
sdlTexture = SDL_CreateTexture(sdlRenderer, SDL_PIXELFORMAT_ARGB8888, SDL_TEXTUREACCESS_STREAMING, 320, 200);
}
void JD8_Quit() {
@@ -50,9 +50,9 @@ void JD8_ClearScreen(Uint8 color) {
memset( screen, color, 64000 );
}
JD8_Surface JD8_NewSurface() {
JD8_Surface surface = (JD8_Surface)malloc( 64000 );
memset( surface, 0, 64000 );
JD8_Surface JD8_NewSurface(const int w, const int h) {
JD8_Surface surface = (JD8_Surface)malloc( w * h );
memset( surface, 0, w*h );
return surface;
}
@@ -70,8 +70,8 @@ JD8_Surface JD8_LoadSurface(const char *file) {
exit(1);
}
JD8_Surface image = JD8_NewSurface();
memcpy(image, pixels, 64000);
JD8_Surface image = JD8_NewSurface(w, h);
memcpy(image, pixels, w * h);
free(pixels);
return image;
@@ -82,8 +82,15 @@ JD8_Palette JD8_LoadPalette(const char *file) {
char *buffer = NULL;
buffer = JF_GetBufferFromResource(file, filesize);
JD8_Palette palette = (JD8_Palette)LoadPalette((unsigned char*)buffer);
uint8_t *pal = LoadPalette((unsigned char*)buffer);
JD8_Palette palette = (JD8_Palette)malloc(256 * sizeof(uint32_t));
for (int i=0; i<256; ++i) {
palette[i].r = pal[i*3];
palette[i].g = pal[1 + i*3];
palette[i].b = pal[2 + i*3];
//palette[i].hex = 0xff0000;
}
return palette;
}
@@ -173,12 +180,7 @@ void JD8_BlitCKToSurface(int x, int y, JD8_Surface surface, int sx, int sy, int
SDL_Rect rect{0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
void JD8_Flip() {
for( int x = 0; x < 320; x++ ) {
for( int y = 0; y < 200; y++ ) {
Uint32 color = 0xFF000000 + main_palette[screen[x + ( y * 320 )]].r + ( main_palette[screen[x + ( y * 320 )]].g << 8 ) + ( main_palette[screen[x + ( y * 320 )]].b << 16 );
pixel_data[x + ( y * 320 )] = color;
}
}
for (int i=0; i<64000; ++i) pixel_data[i] = main_palette[screen[i]].hex;
SDL_UpdateTexture(sdlTexture, NULL, pixel_data, 320 * sizeof(Uint32));
SDL_RenderCopy(sdlRenderer, sdlTexture, NULL, &rect);
SDL_RenderPresent(sdlRenderer);

View File

@@ -1,10 +1,11 @@
#pragma once
#include <SDL2/SDL.h>
struct Color {
Uint8 r;
Uint8 g;
Uint8 b;
union Color {
struct {
uint8_t b, g, r, a;
};
uint32_t hex;
};
typedef Uint8* JD8_Surface;
@@ -16,7 +17,7 @@ void JD8_Quit();
void JD8_ClearScreen(Uint8 color);
JD8_Surface JD8_NewSurface();
JD8_Surface JD8_NewSurface(const int w, const int h);
JD8_Surface JD8_LoadSurface(const char *file);

View File

@@ -1,6 +1,5 @@
#include "jsound.h"
#include "jfile.h"
#include <string>
Mix_Music *music = NULL;
char currentMusic[12];

5
lagueirtofile Normal file
View File

@@ -0,0 +1,5 @@
libs = -lSDL2 -lSDL2_mixer
cppflags = -D DEBUG -g
executable = pepe_debug
sourcepath = .
buildpath = build

View File

@@ -3,12 +3,8 @@
#include "jsound.h"
#include "jfile.h"
#include "info.h"
#include "modulestaticscreen.h"
#include "modulemenu.h"
#include "moduleselect.h"
#include "modulesequence.h"
#include "modules.h"
#include "time.h"
#include <string>
#ifndef WIN32
#include <libgen.h>
@@ -36,48 +32,35 @@ int main( int argc, char* args[] ) {
JD8_Init("Pepe El Pintor");
JS_Init();
Info info;
info.estat_joc = ESTAT_ICEKAS; // ESTAT_SEQUENCIA; // ESTAT_ICEKAS;
info.rosita_enabled = false;
info.job_enabled = false;
info.dificultat = MODE_FACIL;
info.personatge = PERSONATGE_PEPE;
info::estat_joc = ESTAT_ICEKAS; // ESTAT_SEQUENCIA; // ESTAT_ICEKAS;
info::rosita_enabled = false;
info::job_enabled = false;
info::dificultat = MODE_FACIL;
info::personatge = PERSONATGE_PEPE;
FILE* ini = fopen("trick.ini", "rb");
if (ini != NULL) {
unsigned char contingut = 0;
fread(&contingut, 1, 1, ini);
fclose(ini);
if (contingut > 0) info.rosita_enabled = true;
if (contingut > 1) info.job_enabled = true;
if (contingut > 0) info::rosita_enabled = true;
if (contingut > 1) info::job_enabled = true;
}
while (info.estat_joc != ESTAT_EIXIR) {
switch (info.estat_joc) {
while (info::estat_joc != ESTAT_EIXIR) {
switch (info::estat_joc) {
case ESTAT_ICEKAS:
case ESTAT_LOGO:
ModuleStaticScreen * moduleStaticScreen;
moduleStaticScreen = new ModuleStaticScreen(&info);
info.estat_joc = moduleStaticScreen->Go();
delete moduleStaticScreen;
module::staticScreen::go();
break;
case ESTAT_MENU:
ModuleMenu * moduleMenu;
moduleMenu = new ModuleMenu(&info);
info.estat_joc = moduleMenu->Go();
delete moduleMenu;
module::menu::go();
break;
case ESTAT_SELECT:
ModuleSelect * moduleSelect;
moduleSelect = new ModuleSelect(&info);
info.estat_joc = moduleSelect->Go();
delete moduleSelect;
module::select::go();
break;
case ESTAT_SEQUENCIA:
ModuleSequence * moduleSequence;
moduleSequence = new ModuleSequence(&info);
info.estat_joc = moduleSequence->Go();
delete moduleSequence;
module::sequence::go();
break;
}
}

View File

@@ -1,4 +1,4 @@
#include "modulemenu.h"
#include "modules.h"
#include "jgame.h"
#include "jdraw8.h"
@@ -6,6 +6,7 @@
#include "jsound.h"
#include <stdlib.h>
#include <string>
#include "info.h"
#define SENSE_OPCIO -1
#define OPCIO_TIMEATTACK 0
@@ -13,163 +14,209 @@
#define OPCIO_CLASSICMODE 2
#define OPCIO_OPTIONS 3
ModuleMenu::ModuleMenu(Info* info) {
this->info = info;
}
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");
JS_PlayMusic(-1);
JD8_ClearScreen(0);
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);
JD8_Flip();
// Fade in
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;
while (!JG_Quitting() && x > 0) {
while (!JG_ShouldUpdate()) { JI_Update(); }
JD8_Blit(fondo);
JD8_BlitCKCut(x, 50, opcions, 0, 50, 320, 38, 0);
JD8_Flip();
x--;
}
JD8_BlitCKToSurface(0, 50, opcions, 0, 50, 320, 38, fondo, 0);
// Movem la primera opció del menú al lloc
int x = 320;
while (!JG_Quitting() && x > 0) {
while (!JG_ShouldUpdate()) { JI_Update(); }
JD8_Blit(fondo);
JD8_BlitCKCut(x, 50, opcions, 0, 50, 320, 38, 0);
JD8_Flip();
x--;
}
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;
while (!JG_Quitting() && x > 0) {
while (!JG_ShouldUpdate()) { JI_Update(); }
JD8_Blit(fondo);
JD8_BlitCKCut(x, 125, opcions, 0, 125, 320, 38, 0);
JD8_Flip();
x--;
}
JD8_BlitCKToSurface(0, 125, opcions, 0, 125, 320, 38, fondo, 0);
// Movem la segona opció del menú al lloc
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;
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;
while (!JG_Quitting() && y > 0) {
while (!JG_ShouldUpdate()) { JI_Update(); }
JD8_Blit(fondo);
JD8_BlitCKCut(0, -y, opcions, 0, 0, 320, 50, 0);
JD8_Flip();
y--;
}
JD8_BlitCKToSurface(0, 0, opcions, 0, 0, 320, 50, fondo, 0);
// Movem la tercera opció del menú al lloc
x = 320;
while (!JG_Quitting() && x > 0) {
while (!JG_ShouldUpdate()) { JI_Update(); }
JD8_Blit(fondo);
JD8_BlitCKCut(x, 125, opcions, 0, 125, 320, 38, 0);
JD8_Flip();
x--;
}
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()) {
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;
// Movem el titol del menú al lloc
int y = 50;
while (!JG_Quitting() && y > 0) {
while (!JG_ShouldUpdate()) { JI_Update(); }
JD8_Blit(fondo);
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;
}
if (JI_KeyPressed(SDL_SCANCODE_DOWN)) {
if (!fletxa_avall_pulsada) {
fletxa_avall_pulsada = true;
opcio_seleccionada++; if (opcio_seleccionada > 3) opcio_seleccionada = 0;
x_fletxa += x_velocitat;
x_velocitat -= 0.1;
if (x_fletxa < 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)) {
opcio_triada = opcio_seleccionada;
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();
}
// 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;
}

View File

@@ -1,20 +0,0 @@
#pragma once
#include "info.h"
class ModuleMenu {
public:
ModuleMenu(Info* info);
~ModuleMenu(void);
int Go();
private:
//void showMenu();
Info* info;
int contador;
};

9
modules.h Normal file
View 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(); }
}

View File

@@ -1,4 +1,4 @@
#include "moduleselect.h"
#include "modules.h"
#include "jgame.h"
#include "jdraw8.h"
@@ -6,167 +6,202 @@
#include "jsound.h"
#include <stdlib.h>
#include <string>
#include "info.h"
ModuleSelect::ModuleSelect(Info* info) {
this->info = info;
}
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");
ModuleSelect::~ModuleSelect(void) {
}
int num_personatges = 3;
void pintaMarc(int posicio) {
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);
}
}
int ModuleSelect::Go() {
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;
if (!this->info->rosita_enabled) {
num_personatges--;
for (int i = 137; i <= 212; i++) for (int j = 11; j <= 91; j++) JD8_PutPixel(fondo, i, j, 0);
JD8_PutPixel(fondo, 145, 19, 14);
JD8_PutPixel(fondo, 197, 44, 14);
JD8_PutPixel(fondo, 149, 78, 14);
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 (!this->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 = this->info->dificultat;
int opcio_triada = SENSE_OPCIO;
int personatge_seleccionat = this->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;
// Llevem els persoantges que encara no estàn desbloquejats
if (!info::rosita_enabled)
{
num_personatges--;
for (int i = 137; i <= 212; i++) for (int j = 11; j <= 91; j++) JD8_PutPixel(fondo, i, j, 0);
JD8_PutPixel(fondo, 145, 19, 14);
JD8_PutPixel(fondo, 197, 44, 14);
JD8_PutPixel(fondo, 149, 78, 14);
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);
}
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;
JD8_ClearScreen(0);
JD8_Flip();
// Fade in
JD8_Blit(fondo);
JG_SetUpdateTicks(1);
while (!JD8_FadeToPalAsync(pal) && !JG_Quitting())
{
while (!JG_ShouldUpdate()) { JI_Update(); }
}
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;
// Variables necessaries per a triar personatge i dificultat
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;
// 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)) {
if (!fletxa_dreta_pulsada) {
fletxa_dreta_pulsada = true;
personatge_seleccionat++; if (personatge_seleccionat > num_personatges-1) personatge_seleccionat = 0;
}
} else {
fletxa_dreta_pulsada = false;
}
// Alliberem memòria
JD8_FreeSurface(fondo);
JD8_FreeSurface(gfx);
free(pal);
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 {
this->info->dificultat = opcio_triada;
this->info->personatge = personatge_seleccionat;
return ESTAT_SEQUENCIA;
}
}

View File

@@ -1,17 +0,0 @@
#pragma once
#include "info.h"
class ModuleSelect {
public:
ModuleSelect(Info* info);
~ModuleSelect(void);
int Go();
private:
Info* info;
};

View File

@@ -1,229 +1,199 @@
#include "modulesequence.h"
#include "modules.h"
#include "jgame.h"
#include "jdraw8.h"
#include "jinput.h"
#include "jsound.h"
#include <stdlib.h>
#include <string>
#include "info.h"
JD8_Surface gfx = nullptr;
JD8_Surface fondo = nullptr;
JD8_Palette pal = nullptr;
namespace module
{
namespace sequence
{
JD8_Surface gfx = nullptr;
JD8_Surface fondo = nullptr;
JD8_Surface fondo_temp = nullptr;
JD8_Palette pal = nullptr;
ModuleSequence::ModuleSequence(Info* info) {
this->info = info;
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()) {
void fadeIn()
{
JD8_Blit(fondo);
int num_chars_actual = (JG_GetCycleCounter() - temps_inicial) / speed;
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 <= 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);
JG_SetUpdateTicks(1);
while (!JD8_FadeToPalAsync(pal) && !JG_Quitting())
{
while (!JG_ShouldUpdate()) { JI_Update(); }
}
}
if (text3 != NULL) {
int tamany_text3 = strlen(text3);
temps_total = tamany_text3 * speed;
temps_inicial = JG_GetCycleCounter();
void fadeOut()
{
JG_SetUpdateTicks(2);
while (!JD8_FadeOutAsync() && !JG_Quitting())
{
while (!JG_ShouldUpdate()) { JI_Update(); }
}
}
while ((JG_GetCycleCounter() - temps_inicial < temps_total) && !eixir && !JG_Quitting()) {
JD8_Blit(fondo);
void drawChar(int x, int y, char char_actual)
{
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(320, 200);
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;
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);
}
drawChar(x + (num_chars_actual + 1) * 8, y, text1[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, text1[i]);
for (int i = 0; i <= tamany_text3; 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);
if (text2 != NULL)
{
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();
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; } }
}
}

View File

@@ -1,22 +0,0 @@
#pragma once
#include "info.h"
class ModuleSequence {
public:
ModuleSequence(Info* info);
~ModuleSequence(void);
int Go();
private:
Info * info;
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);
};

View File

@@ -1,4 +1,4 @@
#include "modulestaticscreen.h"
#include "modules.h"
#include "jgame.h"
#include "jdraw8.h"
@@ -6,111 +6,84 @@
#include "jsound.h"
#include <stdlib.h>
#include <string>
#include "info.h"
ModuleStaticScreen::ModuleStaticScreen( Info* info ) {
this->info = info;
}
ModuleStaticScreen::~ModuleStaticScreen(void) {
}
namespace module
{
namespace staticScreen
{
void go()
{
bool eixir = false;
JD8_Surface gfx = nullptr;
JD8_Palette pal = nullptr;
int ModuleStaticScreen::Go() {
// Carrega grafics i música
switch( info::estat_joc ) {
case ESTAT_ICEKAS:
JS_LoadMusic("mlogo.mid");
JS_PlayMusic(1);
switch( this->info->estat_joc ) {
case ESTAT_ICEKAS:
doIcekas();
break;
case ESTAT_LOGO:
doLogo();
break;
}
gfx = JD8_LoadSurface( "logo.gif" );
pal = JD8_LoadPalette( "logo.gif" );
break;
JD8_FadeOut();
case ESTAT_LOGO:
gfx = JD8_LoadSurface("titol.gif");
pal = JD8_LoadPalette("titol.gif");
break;
}
if( JG_Quitting() ) {
return ESTAT_EIXIR;
} else {
switch (this->info->estat_joc) {
case ESTAT_ICEKAS: return ESTAT_LOGO; break;
case ESTAT_LOGO: return ESTAT_MENU; break;
// Fade in
JD8_Blit(gfx);
JG_SetUpdateTicks(8);
while (!JD8_FadeToPalAsync(pal))
{
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()) {
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;
}
const int minim( const int a, const int b ) {
if( b < a ) { return b; } else { return a; }
}
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);
}

View File

@@ -1,21 +0,0 @@
#pragma once
#include "info.h"
class ModuleStaticScreen {
public:
ModuleStaticScreen( Info* info );
~ModuleStaticScreen(void);
int Go();
private:
void doIcekas();
void doLogo();
Info* info;
int contador;
};