Canvis varios

This commit is contained in:
2019-12-12 19:00:56 +01:00
parent 875d2894df
commit 60af56270f
7 changed files with 73 additions and 30 deletions

4
info.h
View File

@@ -11,5 +11,7 @@
#define ESTAT_MORT 7 #define ESTAT_MORT 7
struct Info { struct Info {
int estat_joc; int estat_joc;
bool rosita_enabled;
bool job_enabled;
}; };

View File

@@ -196,6 +196,10 @@ void JD8_PutPixel( JD8_Surface surface, int x, int y, Uint8 pixel ) {
surface[x + (y*320)] = pixel; surface[x + (y*320)] = pixel;
} }
void JD8_PutPixel(int x, int y, Uint8 pixel) {
screen[x + (y * 320)] = pixel;
}
void JD8_SetPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b) { void JD8_SetPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b) {
main_palette[index].r = r << 2; main_palette[index].r = r << 2;
main_palette[index].g = g << 2; main_palette[index].g = g << 2;

View File

@@ -47,6 +47,7 @@ void JD8_FreeSurface(JD8_Surface surface);
Uint8 JD8_GetPixel( JD8_Surface surface, int x, int y ); Uint8 JD8_GetPixel( JD8_Surface surface, int x, int y );
void JD8_PutPixel( JD8_Surface surface, int x, int y, Uint8 pixel ); void JD8_PutPixel( JD8_Surface surface, int x, int y, Uint8 pixel );
void JD8_PutPixel(int x, int y, Uint8 pixel);
void JD8_SetPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b); void JD8_SetPaletteColor(Uint8 index, Uint8 r, Uint8 g, Uint8 b);

View File

@@ -5,6 +5,7 @@
#include "info.h" #include "info.h"
#include "modulestaticscreen.h" #include "modulestaticscreen.h"
#include "modulemenu.h" #include "modulemenu.h"
#include "moduleselect.h"
#include "time.h" #include "time.h"
#include <string> #include <string>
@@ -36,12 +37,17 @@ int main( int argc, char* args[] ) {
Info info; Info info;
info.estat_joc = ESTAT_ICEKAS; info.estat_joc = ESTAT_ICEKAS;
info.rosita_enabled = false;
info.job_enabled = false;
/* FILE* ini = fopen("trick.ini", "rb"); FILE* ini = fopen("trick.ini", "rb");
if (ini != NULL) { if (ini != NULL) {
info.nou_personatge = true; unsigned char contingut = 0;
fread(&contingut, 1, 1, ini);
fclose(ini); fclose(ini);
}*/ if (contingut > 0) info.rosita_enabled = true;
if (contingut > 1) info.job_enabled = true;
}
while (info.estat_joc != ESTAT_EIXIR) { while (info.estat_joc != ESTAT_EIXIR) {
switch (info.estat_joc) { switch (info.estat_joc) {
@@ -58,6 +64,12 @@ int main( int argc, char* args[] ) {
info.estat_joc = moduleMenu->Go(); info.estat_joc = moduleMenu->Go();
delete moduleMenu; delete moduleMenu;
break; break;
case ESTAT_SELECT:
ModuleSelect * moduleSelect;
moduleSelect = new ModuleSelect(&info);
info.estat_joc = moduleSelect->Go();
delete moduleSelect;
break;
} }
} }

View File

@@ -7,6 +7,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <string> #include <string>
#define SENSE_OPCIO -1
#define OPCIO_TIMEATTACK 0
#define OPCIO_WORLDTOUR 1
#define OPCIO_CLASSICMODE 2
#define OPCIO_OPTIONS 3
ModuleMenu::ModuleMenu(Info* info) { ModuleMenu::ModuleMenu(Info* info) {
this->info = info; this->info = info;
} }
@@ -42,51 +48,50 @@ int ModuleMenu::Go() {
JD8_Flip(); JD8_Flip();
x--; x--;
} }
JD8_BlitCKToSurface(0, 50, opcions, 0, 50, 320, 38, fondo, 0);
x = 320; x = 320;
while (!JG_Quitting() && x > 25) { while (!JG_Quitting() && x > 25) {
while (!JG_ShouldUpdate()) { JI_Update(); } while (!JG_ShouldUpdate()) { JI_Update(); }
JD8_Blit(fondo); JD8_Blit(fondo);
JD8_BlitCK(0, 50, opcions, 0, 50, 320, 38, 0);
JD8_BlitCKCut(x, 88, opcions, 25, 88, 135, 37, 0); JD8_BlitCKCut(x, 88, opcions, 25, 88, 135, 37, 0);
JD8_Flip(); JD8_Flip();
x--; x--;
} }
JD8_BlitCKToSurface(25, 88, opcions, 25, 88, 135, 37, fondo, 0);
x = 320; x = 320;
while (!JG_Quitting() && x > 0) { while (!JG_Quitting() && x > 0) {
while (!JG_ShouldUpdate()) { JI_Update(); } while (!JG_ShouldUpdate()) { JI_Update(); }
JD8_Blit(fondo); JD8_Blit(fondo);
JD8_BlitCK(0, 50, opcions, 0, 50, 320, 38, 0);
JD8_BlitCK(25, 88, opcions, 25, 88, 135, 37, 0);
JD8_BlitCKCut(x, 125, opcions, 0, 125, 320, 38, 0); JD8_BlitCKCut(x, 125, opcions, 0, 125, 320, 38, 0);
JD8_Flip(); JD8_Flip();
x--; x--;
} }
JD8_BlitCKToSurface(0, 125, opcions, 0, 125, 320, 38, fondo, 0);
x = 320; x = 320;
while (!JG_Quitting() && x > 0) { while (!JG_Quitting() && x > 0) {
while (!JG_ShouldUpdate()) { JI_Update(); } while (!JG_ShouldUpdate()) { JI_Update(); }
JD8_Blit(fondo); JD8_Blit(fondo);
JD8_BlitCK(0, 50, opcions, 0, 50, 320, 38, 0);
JD8_BlitCK(25, 88, opcions, 25, 88, 135, 37, 0);
JD8_BlitCK(0, 125, opcions, 0, 125, 320, 38, 0);
JD8_BlitCKCut(x, 163, opcions, 0, 163, 320, 37, 0); JD8_BlitCKCut(x, 163, opcions, 0, 163, 320, 37, 0);
JD8_Flip(); JD8_Flip();
x--; x--;
} }
JD8_BlitCKToSurface(0, 163, opcions, 0, 163, 320, 37, fondo, 0);
int y = 50; int y = 50;
while (!JG_Quitting() && y > 0) { while (!JG_Quitting() && y > 0) {
while (!JG_ShouldUpdate()) { JI_Update(); } while (!JG_ShouldUpdate()) { JI_Update(); }
JD8_Blit(fondo); JD8_Blit(fondo);
JD8_BlitCK(0, 50, opcions, 0, 50, 320, 38, 0);
JD8_BlitCK(25, 88, opcions, 25, 88, 135, 37, 0);
JD8_BlitCK(0, 125, opcions, 0, 125, 320, 38, 0);
JD8_BlitCK(0, 163, opcions, 0, 163, 320, 37, 0);
JD8_BlitCKCut(0, -y, opcions, 0, 0, 320, 50, 0); JD8_BlitCKCut(0, -y, opcions, 0, 0, 320, 50, 0);
JD8_Flip(); JD8_Flip();
y--; y--;
} }
JD8_BlitCKToSurface(0, 0, opcions, 0, 0, 320, 50, fondo, 0);
int opcio_seleccionada = 0; int opcio_seleccionada = OPCIO_TIMEATTACK;
int opcio_triada = -1; int opcio_triada = SENSE_OPCIO;
bool fletxa_amunt_pulsada = false; bool fletxa_amunt_pulsada = false;
bool fletxa_avall_pulsada = false; bool fletxa_avall_pulsada = false;
float x_fletxa = 0; float x_fletxa = 0;
@@ -94,7 +99,7 @@ int ModuleMenu::Go() {
JG_SetUpdateTicks(20); JG_SetUpdateTicks(20);
while (!JG_Quitting() && opcio_triada == -1) { while (!JG_Quitting() && opcio_triada == SENSE_OPCIO) {
while (!JG_ShouldUpdate()) { while (!JG_ShouldUpdate()) {
JI_Update(); JI_Update();
if (JI_KeyPressed(SDL_SCANCODE_UP)) { if (JI_KeyPressed(SDL_SCANCODE_UP)) {
@@ -113,6 +118,9 @@ int ModuleMenu::Go() {
} else { } else {
fletxa_avall_pulsada = false; fletxa_avall_pulsada = false;
} }
if (JI_KeyPressed(SDL_SCANCODE_SPACE)) {
opcio_triada = opcio_seleccionada;
}
} }
x_fletxa += x_velocitat; x_fletxa += x_velocitat;
@@ -123,21 +131,28 @@ int ModuleMenu::Go() {
x_velocitat = 1; x_velocitat = 1;
} }
JD8_Blit(fondo); JD8_Blit(fondo);
JD8_BlitCK(0, 50, opcions, 0, 50, 320, 38, 0);
JD8_BlitCK(25, 88, opcions, 25, 88, 135, 37, 0);
JD8_BlitCK(0, 125, opcions, 0, 125, 320, 38, 0);
JD8_BlitCK(0, 163, opcions, 0, 163, 320, 37, 0);
JD8_BlitCK(0, 0, opcions, 0, 0, 320, 50, 0);
JD8_BlitCK(10+x_fletxa, 60+opcio_seleccionada*37, gfx, 18, 5, 9, 10, 255); JD8_BlitCK(10+x_fletxa, 60+opcio_seleccionada*37, gfx, 18, 5, 9, 10, 255);
JD8_Flip(); JD8_Flip();
} }
JD8_BlitCKToSurface(10 + x_fletxa, 60 + opcio_seleccionada * 37, gfx, 18, 5, 9, 10, fondo, 255);
// FADE OUT // BLINDS OUT
JG_SetUpdateTicks(2); JG_SetUpdateTicks(8);
while (!JD8_FadeOutAsync() && !JG_Quitting()) { x = 0;
while (x < 32 && !JG_Quitting()) {
while (!JG_ShouldUpdate()) { JI_Update(); } 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(fondo);
JD8_FreeSurface(opcions); JD8_FreeSurface(opcions);
JD8_FreeSurface(gfx); JD8_FreeSurface(gfx);
@@ -148,11 +163,12 @@ int ModuleMenu::Go() {
if (JG_Quitting()) { if (JG_Quitting()) {
return ESTAT_EIXIR; return ESTAT_EIXIR;
} } else {
else { switch (opcio_triada) {
switch (this->info->estat_joc) { case OPCIO_TIMEATTACK: return ESTAT_LOGO; break;
case ESTAT_ICEKAS: return ESTAT_LOGO; break; case OPCIO_WORLDTOUR: return ESTAT_SELECT; break;
case ESTAT_LOGO: return ESTAT_MENU; break; case OPCIO_CLASSICMODE: return ESTAT_MENU; break;
case OPCIO_OPTIONS: return ESTAT_MENU; break;
} }
} }
return ESTAT_EIXIR; return ESTAT_EIXIR;

View File

@@ -88,6 +88,7 @@
<ClCompile Include="jsound.cpp" /> <ClCompile Include="jsound.cpp" />
<ClCompile Include="main.cpp" /> <ClCompile Include="main.cpp" />
<ClCompile Include="modulemenu.cpp" /> <ClCompile Include="modulemenu.cpp" />
<ClCompile Include="moduleselect.cpp" />
<ClCompile Include="modulestaticscreen.cpp" /> <ClCompile Include="modulestaticscreen.cpp" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@@ -98,6 +99,7 @@
<ClInclude Include="jinput.h" /> <ClInclude Include="jinput.h" />
<ClInclude Include="jsound.h" /> <ClInclude Include="jsound.h" />
<ClInclude Include="modulemenu.h" /> <ClInclude Include="modulemenu.h" />
<ClInclude Include="moduleselect.h" />
<ClInclude Include="modulestaticscreen.h" /> <ClInclude Include="modulestaticscreen.h" />
</ItemGroup> </ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />

View File

@@ -42,6 +42,9 @@
<ClCompile Include="modulemenu.cpp"> <ClCompile Include="modulemenu.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="moduleselect.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="info.h"> <ClInclude Include="info.h">
@@ -68,5 +71,8 @@
<ClInclude Include="modulemenu.h"> <ClInclude Include="modulemenu.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="moduleselect.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
</Project> </Project>