Assumptes #1 al #6 finiquitats. Piràmide secreta funcionant, amb la seua intro.

This commit is contained in:
2016-02-22 17:52:49 +01:00
parent f00afcf9a2
commit de9bac2b2c
12 changed files with 188 additions and 34 deletions

View File

@@ -80,6 +80,7 @@ JD8_Palette JD8_LoadPalette(const char *file) {
}
void JD8_SetScreenPalette(JD8_Palette palette) {
if (main_palette == palette) return;
if( main_palette != NULL) free( main_palette );
main_palette = palette;
}
@@ -158,6 +159,12 @@ void JD8_PutPixel( JD8_Surface surface, int x, int y, Uint8 pixel ) {
surface[x + (y*320)] = pixel;
}
void JD8_SetPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b) {
main_palette[index].r = r << 2;
main_palette[index].g = g << 2;
main_palette[index].b = b << 2;
}
void JD8_FadeOut() {
for( int j = 0; j < 32; j++ ) {
for( int i = 0; i < 256; i++ ) {

View File

@@ -42,6 +42,8 @@ Uint8 JD8_GetPixel( JD8_Surface surface, int x, int y );
void JD8_PutPixel( JD8_Surface surface, int x, int y, Uint8 pixel );
void JD8_SetPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b);
void JD8_FadeOut();
void JD8_FadeToPal( JD8_Palette pal );

View File

@@ -6,6 +6,11 @@ const Uint8 *keystates;// = SDL_GetKeyboardState( NULL );
SDL_Event event;
Uint8 cheat[5];
bool key_pressed = false;
int waitTime = 0;
void JI_DisableKeyboard(Uint32 time) {
waitTime = time;
}
void JI_moveCheats( Uint8 new_key ) {
cheat[0] = cheat[1];
@@ -19,6 +24,8 @@ void JI_Update() {
key_pressed = false;
keystates = SDL_GetKeyboardState( NULL );
if (waitTime > 0) waitTime--;
while ( SDL_PollEvent( &event ) ) {
if ( event.type == SDL_QUIT ) JG_QuitSignal();
if( event.type == SDL_KEYUP ) {
@@ -29,7 +36,7 @@ void JI_Update() {
}
bool JI_KeyPressed(int key) {
return (keystates[key] != 0);
return waitTime > 0 ? false : (keystates[key] != 0);
}
bool JI_CheatActivated( const char* cheat_code ) {
@@ -41,5 +48,5 @@ bool JI_CheatActivated( const char* cheat_code ) {
}
bool JI_AnyKey() {
return key_pressed;
return waitTime > 0 ? false : key_pressed;
}

View File

@@ -1,6 +1,8 @@
#pragma once
#include "SDL.h"
void JI_DisableKeyboard(Uint32 time);
void JI_Update();
bool JI_KeyPressed(int key);

View File

@@ -1,11 +1,14 @@
#include "jsound.h"
#include "jfile.h"
#include <string>
Mix_Music *music = NULL;
char currentMusic[12];
bool JS_Init() {
Mix_OpenAudio(MIX_DEFAULT_FREQUENCY, MIX_DEFAULT_FORMAT, 2, 1024);
Mix_AllocateChannels(8);
currentMusic[0] = 0;
return true;
}
@@ -22,6 +25,7 @@ void JS_LoadMusic(const char *musicFilename)
SDL_RWops *rw = SDL_RWFromMem(buffer, filesize);
music = Mix_LoadMUS_RW(rw, 1);
strcpy(currentMusic, musicFilename);
}
void JS_SetMusicVolume(int volume) {
@@ -44,6 +48,10 @@ bool JS_MusicPlaying() {
return (Mix_PlayingMusic() == 1);// && (Mix_FadingMusic() != MIX_FADING_OUT);
}
const char* JS_GetMusicName() {
return currentMusic;
}
JS_Sound *JS_LoadSound(char *soundFilename) {
int filesize = 0;
char *buffer = JF_GetBufferFromResource(soundFilename, filesize);

View File

@@ -17,6 +17,8 @@ void JS_FadeOutMusic();
bool JS_MusicPlaying();
const char* JS_GetMusicName();
JS_Sound *JS_LoadSound(char *soundFilename);
void JS_SetSoundVolume(JS_Sound *sound, int volume);

View File

@@ -49,6 +49,14 @@ void Mapa::draw() {
}
JD8_Blit( this->fondo );
// Pinta tombes
for (int y = 0; y < 4; y++) {
for (int x = 0; x < 4; x++) {
JD8_BlitCK(35 + (x * 65), 45 + (y * 35), this->gfx, this->tombes[x + y * 4].x, this->tombes[x + y * 4].y, 50, 20, 255);
}
}
JD8_BlitCK( 45, 15, this->gfx, 30 + ( this->frame_torxes * 25 ), 80, 25, 15, 255 );
JD8_BlitCK( 95, 15, this->gfx, 30 + ( this->frame_torxes * 25 ), 80, 25, 15, 255 );
JD8_BlitCK( 195, 15, this->gfx, 30 + ( this->frame_torxes * 25 ), 80, 25, 15, 255 );
@@ -89,10 +97,16 @@ void Mapa::preparaFondoEstatic() {
// Prepara el fondo est<73>tic de l'habitaci<63>
this->fondo = JD8_NewSurface();
if (info->num_piramide == 6) {
JD8_BlitToSurface(9, 2, this->gfx, 227, 185, 92, 7, this->fondo); // Text "SECRETA"
}
else {
JD8_BlitToSurface(9, 2, this->gfx, 60, 185, 39, 7, this->fondo); // Text "NIVELL"
JD8_BlitToSurface(72, 6, this->gfx, 153, 189, 3, 1, this->fondo); // Ralleta entre num piramide i num habitacio
}
JD8_BlitToSurface(130, 2, this->gfx, 225, 192, 19, 8, this->fondo); // Montonet de monedes + signe '='
JD8_BlitToSurface(220, 2, this->gfx, 160, 185, 48, 7, this->fondo); // Text "ENERGIA"
if (this->info->diners >= 200) JD8_BlitToSurface(175, 3, this->gfx, 60, 193, 7, 6, this->fondo);
// Pinta taulells
for( int y = 0; y < 11; y++ ) {
@@ -113,16 +127,13 @@ void Mapa::preparaFondoEstatic() {
case 5:
JD8_BlitToSurface( 20+(x*15), 30+(y*15), this->gfx, 130, 80, 15, 15, this->fondo );
break;
case 6:
JD8_BlitToSurface(20 + (x * 15), 30 + (y * 15), this->gfx, 145, 80, 15, 15, this->fondo);
break;
}
}
}
// Pinta tombes
for( int y = 0; y < 4; y++ ) {
for( int x = 0; x < 4; x++ ) {
JD8_BlitCKToSurface( 35+(x*65), 45+(y*35), this->gfx, 0, 0, 50, 20, this->fondo, 255 );
}
}
// Pinta vores de les parets
JD8_BlitCKToSurface( 5, 15, this->gfx, 30, 110, 15, 15, this->fondo, 255 );
@@ -157,14 +168,21 @@ void swap( Uint8& a, Uint8& b ) {
}
void Mapa::preparaTombes() {
const Uint8 contingut = this->info->num_piramide == 6 ? CONTE_DIAMANT : CONTE_RES;
int cx = this->info->num_piramide == 6 ? 270 : 0;
int cy = this->info->num_piramide == 6 ? 50 : 0;
for( int i = 0; i < 16; i++ ) {
this->tombes[i].contingut = CONTE_RES;
this->tombes[i].contingut = contingut;
this->tombes[i].oberta = false;
this->tombes[i].costat[0] = false;
this->tombes[i].costat[1] = false;
this->tombes[i].costat[2] = false;
this->tombes[i].costat[3] = false;
this->tombes[i].x = cx;
this->tombes[i].y = cy;
}
if (this->info->num_piramide == 6) return;
this->tombes[0].contingut = CONTE_FARAO;
this->tombes[1].contingut = CONTE_CLAU;
this->tombes[2].contingut = CONTE_PERGAMI;
@@ -228,30 +246,37 @@ void Mapa::comprovaCaixa( Uint8 num ) {
int y = num / 4;
switch( this->tombes[num].contingut ) {
case CONTE_RES:
JD8_BlitCKToSurface( 35+(x*65), 45+(y*35), this->gfx, 50, 0, 50, 20, this->fondo, 255 );
//JD8_BlitCKToSurface( 35+(x*65), 45+(y*35), this->gfx, 50, 0, 50, 20, this->fondo, 255 );
this->tombes[num].x = 50;
break;
case CONTE_TRESOR:
JD8_BlitCKToSurface( 35+(x*65), 45+(y*35), this->gfx, 100, 0, 50, 20, this->fondo, 255 );
//JD8_BlitCKToSurface( 35+(x*65), 45+(y*35), this->gfx, 100, 0, 50, 20, this->fondo, 255 );
this->tombes[num].x = 100;
info->diners++;
break;
case CONTE_FARAO:
JD8_BlitCKToSurface( 35+(x*65), 45+(y*35), this->gfx, 150, 0, 50, 20, this->fondo, 255 );
//JD8_BlitCKToSurface( 35+(x*65), 45+(y*35), this->gfx, 150, 0, 50, 20, this->fondo, 255 );
this->tombes[num].x = 150;
this->farao = true;
break;
case CONTE_CLAU:
JD8_BlitCKToSurface( 35+(x*65), 45+(y*35), this->gfx, 200, 0, 50, 20, this->fondo, 255 );
//JD8_BlitCKToSurface( 35+(x*65), 45+(y*35), this->gfx, 200, 0, 50, 20, this->fondo, 255 );
this->tombes[num].x = 200;
this->clau = true;
break;
case CONTE_MOMIA:
JD8_BlitCKToSurface( 35+(x*65), 45+(y*35), this->gfx, 0, 175, 50, 20, this->fondo, 255 );
//JD8_BlitCKToSurface( 35+(x*65), 45+(y*35), this->gfx, 0, 175, 50, 20, this->fondo, 255 );
this->tombes[num].y = 175;
this->nova_momia = true;
break;
case CONTE_PERGAMI:
JD8_BlitCKToSurface( 35+(x*65), 45+(y*35), this->gfx, 250, 0, 50, 20, this->fondo, 255 );
//JD8_BlitCKToSurface( 35+(x*65), 45+(y*35), this->gfx, 250, 0, 50, 20, this->fondo, 255 );
this->tombes[num].x = 250;
this->sam->pergami = true;
break;
case CONTE_DIAMANT:
JD8_BlitCKToSurface( 35+(x*65), 45+(y*35), this->gfx, 150, 0, 50, 20, this->fondo, 255 );
//JD8_BlitCKToSurface( 35+(x*65), 45+(y*35), this->gfx, 270, 70, 50, 20, this->fondo, 255 );
this->tombes[num].y = 70;
info->diamants++;
info->diners += VALOR_DIAMANT;
break;

1
mapa.h
View File

@@ -18,6 +18,7 @@ struct Tomba {
bool costat[4];
Uint8 contingut;
bool oberta;
Uint16 x, y;
};
struct Vertex {

View File

@@ -13,8 +13,10 @@ Marcador::~Marcador(void) {
void Marcador::draw() {
if (this->info->num_piramide < 6) {
this->pintaNumero(55, 2, this->info->num_piramide);
this->pintaNumero(80, 2, this->info->num_habitacio);
}
this->pintaNumero( 149, 2, this->info->diners / 100 );
this->pintaNumero( 156, 2, ( this->info->diners % 100 ) / 10 );

View File

@@ -10,6 +10,9 @@ ModuleGame::ModuleGame( Info* info ) {
this->info = info;
//this->info->num_piramide = 6;
//this->info->diners = 200;
this->gfx = JD8_LoadSurface( "frames.gif" );
JG_SetUpdateTicks(10);
@@ -49,8 +52,11 @@ int ModuleGame::Go() {
this->Draw();
JS_LoadMusic(this->info->num_piramide==3 ? "00000008.xm" : (this->info->num_piramide==2 ? "00000007.xm" : "00000006.xm"));
const char* music = this->info->num_piramide == 3 ? "00000008.xm" : (this->info->num_piramide == 2 ? "00000007.xm" : (this->info->num_piramide == 6 ? "00000002.xm" : "00000006.xm"));
if (!JS_MusicPlaying() || !(SDL_strcmp(music, JS_GetMusicName()) == 0)) {
JS_LoadMusic(music);
JS_PlayMusic(-1);
}
JD8_FadeToPal( JD8_LoadPalette( "frames.gif" ) );
@@ -60,7 +66,7 @@ int ModuleGame::Go() {
this->Update();
}
JS_FadeOutMusic();
//JS_FadeOutMusic();
if( this->final == 1 ) {
this->info->num_habitacio++;
@@ -144,16 +150,17 @@ void ModuleGame::Update() {
void ModuleGame::iniciarMomies() {
if( this->info->num_habitacio == 10 ) { this->info->momies = 1; } else { this->info->momies++; }
if( this->info->num_habitacio == 1 ) { this->info->momies = 1; } else { this->info->momies++; }
if (this->info->num_piramide == 6) this->info->momies = 8;
int x = 20;
int y = 170;
bool dimonis = this->info->num_piramide == 6;
for( int i = 0; i < info->momies; i++ ) {
if( this->momies == NULL) {
this->momies = new Momia( this->gfx, this->info, false, x, y, this->sam );
this->momies = new Momia( this->gfx, this->info, dimonis, x, y, this->sam );
} else {
this->momies->insertar( new Momia( this->gfx, this->info, false, x, y, this->sam ) );
this->momies->insertar( new Momia( this->gfx, this->info, dimonis, x, y, this->sam ) );
}
x += 65;
if( x == 345 ) { x = 20; y -= 35; }

View File

@@ -27,6 +27,7 @@ int ModuleSequence::Go() {
break;
case 1: // Slides
case 7:
//doSecreta();
doSlides();
break;
case 2: // Pre-pir<69>mide
@@ -751,6 +752,91 @@ void ModuleSequence::doBanner() {
}
void ModuleSequence::doSecreta() {
JS_LoadMusic("00000002.xm");
JS_PlayMusic(-1);
JG_SetUpdateTicks(20);
JD8_FadeOut();
JD8_Surface gfx = JD8_LoadSurface("tomba1.gif");
JD8_Palette pal_aux = JD8_LoadPalette("tomba1.gif");
JD8_Palette pal = (JD8_Palette)malloc(768);
memcpy(pal, pal_aux, 768);
JD8_ClearScreen(255);
JD8_SetScreenPalette(pal);
bool exit = false;
int step = 0;
contador = 1;
while (!exit && !JG_Quitting()) {
if (JG_ShouldUpdate()) {
JI_Update();
if (JI_AnyKey()) {
exit = true;
}
switch (step) {
case 0:
JD8_Blit(70, 60, gfx, 0, contador, 178, 70); //Put_Sprite(from, where, 0 + (320 * i), 178, 70, 70, 60);
JD8_BlitCK(70, 60, gfx, 178, contador >> 1, 142, 70, 255); //Put_Sprite(from, where, 178 + (320 * (i div 2)), 142, 70, 70, 60);
JD8_Flip();
contador++;
if (contador == 128) step++;
break;
case 1:
case 4:
case 7:
case 9:
contador--;
if (contador == 0) step++;
break;
case 2:
JD8_ClearScreen(255);
JD8_Flip();
gfx = JD8_LoadSurface("tomba2.gif");
pal_aux = JD8_LoadPalette("tomba2.gif");
memcpy(pal, pal_aux, 768);
JD8_SetScreenPalette(pal);
step++;
break;
case 3:
JD8_Blit(55, 53, gfx, 0, 158-contador, 211, contador); //Put_Sprite(from, where, 0 + ((158 - i) * 320), 211, i, 55, 53);
JD8_Flip();
contador++;
if (contador == 94) step++;
break;
case 5:
JD8_ClearScreen(0);
JD8_Flip();
JD8_SetPaletteColor(254, 12, 11, 11);
JD8_SetPaletteColor(253, 12, 11, 11);
step++;
break;
case 6:
JD8_Blit(80, 68, gfx, 160 - (contador*2), 0, contador*2, 64); //Put_Sprite(from, where, 160 - (i * 2), (i * 2), 64, 80, 68);
JD8_Flip();
contador++;
if (contador == 80) step++;
break;
case 8:
JD8_SetPaletteColor(254, contador+12, 11, 11);
JD8_SetPaletteColor(253, (contador+12) >> 1, 11, 11);
JD8_Flip();
contador++;
if (contador == 51) step++;
break;
case 10:
JD8_FadeOut();
memcpy(pal, pal_aux, 768);
JD8_ClearScreen(255);
JS_FadeOutMusic();
exit = true;
break;
}
}
}
JD8_FreeSurface(gfx);
free(pal_aux);
}
void ModuleSequence::doCredits() {
@@ -758,9 +844,12 @@ void ModuleSequence::doCredits() {
void ModuleSequence::doMort() {
JS_LoadMusic("00000001.xm");
JS_PlayMusic(-1);
JS_PlayMusic(1);
this->contador = 5000;
JI_DisableKeyboard(60);
this->info->vida = 5;
this->contador = 1000;
JD8_Surface gfx = JD8_LoadSurface( "gameover.gif" );
JD8_Palette pal = JD8_LoadPalette( "gameover.gif" );
@@ -784,6 +873,7 @@ void ModuleSequence::doMort() {
if( contador == 0 ) exit = true;
}
}
JS_FadeOutMusic();
JS_LoadMusic("00000003.xm");
JS_PlayMusic(-1);
}

View File

@@ -61,9 +61,10 @@ Prota::Prota( JD8_Surface gfx, Info* info ) : Sprite( gfx ) {
this->entitat->animacions[4].frames = (Uint8*)malloc( 50 );
for( int i = 0; i < 50; i++ ) this->entitat->animacions[4].frames[i] = i + 20;
this->entitat->animacions[5].num_frames = 12;
this->entitat->animacions[5].frames = (Uint8*)malloc( 12 );
this->entitat->animacions[5].num_frames = 48;
this->entitat->animacions[5].frames = (Uint8*)malloc( 48 );
for( int i = 0; i < 12; i++ ) this->entitat->animacions[5].frames[i] = i + 70;
for (int i = 12; i < 48; i++) this->entitat->animacions[5].frames[i] = 81;
this->cur_frame = 0;
this->x = 150;