added missing menus + created race start sequence

This commit is contained in:
Sylvain PILLOT 2022-03-22 22:55:45 +01:00
parent 71b969b8d0
commit 3fdedb0907
12 changed files with 259 additions and 12 deletions

View File

@ -88,8 +88,10 @@ set(ASSETS_cg
assets-cg/fonts/speedfont.png
assets-cg/fonts/auto15.png
assets-cg/fonts/auto20.png
assets-cg/fonts/startseq.png
assets-cg/menus/flag.png
assets-cg/menus/bigflag.png
assets-cg/hud/speedhud.png

View File

@ -20,4 +20,9 @@ auto20.png:
charset: print
grid.size: 14x20
startseq.png:
name: startseq
type: font
charset: print
grid.size: 70x93

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

BIN
assets-cg/menus/bigflag.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@ -18,4 +18,8 @@ void drawOptions( void );
void getInputOptions( void );
void drawPauseQuit( void );
void getInputPauseQuit( void );
#endif // MENUS_H

View File

@ -29,8 +29,9 @@
#include <stdio.h>
extern bopti_image_t player;
extern font_t speedfont;
extern font_t speedfont, startseq;
extern bopti_image_t speedhud;
extern bopti_image_t flag, bigflag;
int CurrentCircuitBiome = PLAINS;
@ -54,6 +55,7 @@ unsigned int DataIndex=0;
bool stop = false;
bool exitToOS = false;
bool record = false;
bool screenshot = false;
@ -69,7 +71,7 @@ bool BDrawFPS = false;
bool OptionMode = false;
bool PauseMode = false;
bool SkipTime = false;
uint16_t currentcurve=0;
uint8_t shiftcolor=0;
@ -259,7 +261,7 @@ static void get_inputs( float dt, int index )
speedcontrol = true;
}
if(keydown(KEY_EXIT)) stop = true;
if(keydown(KEY_EXIT)) drawPauseQuit();
if(keydown(KEY_OPTN)) drawOptions();
@ -336,6 +338,55 @@ static void get_inputs( float dt, int index )
}
static void get_minimum_inputs( void )
{
key_event_t ev;
while((ev = pollevent()).type != KEYEV_NONE)
{
}
if(keydown(KEY_EXIT)) drawPauseQuit();
if(keydown(KEY_OPTN)) drawOptions();
#if IS_FXLIB==1
if(keydown(KEY_XOT))
{
ShowDebug1 = false;
ShowDebug2 = false;
ShowDebug3 = false;
}
if(keydown(KEY_LOG))
{
ShowDebug1 = true;
ShowDebug2 = false;
ShowDebug3 = false;
}
if(keydown(KEY_LN))
{
ShowDebug1 = false;
ShowDebug2 = true;
ShowDebug3 = false;
}
if(keydown(KEY_SIN))
{
ShowDebug1 = false;
ShowDebug2 = false;
ShowDebug3 = true;
}
if(keydown(KEY_F1)) BDrawDeco = !BDrawDeco;
if(keydown(KEY_F2)) BDrawClds = !BDrawClds;
if(keydown(KEY_F3)) BDrawCars = !BDrawCars;
if(keydown(KEY_F4)) BDrawFPS = !BDrawFPS;
if(keydown(KEY_F5)) screenshot = true;
if(keydown(KEY_F6)) record = !record;
#endif // IS_FXLIB
}
int main(void)
@ -361,7 +412,7 @@ int main(void)
char texttosend[1024];
bool exitToOS = false;
exitToOS = false;
do
{
@ -474,6 +525,15 @@ int main(void)
DataIndex = 0;
bool initiateStart = true; // are we in the start sequence ?
int32_t startCount = 6000000;
int32_t startRemaining;
bool finishSequence = false; // Did we reached the end of the race ?
bool failSequence = false; // Did we run out of time ?
while (!stop)
{
@ -481,11 +541,26 @@ int main(void)
perf_update = prof_make();
prof_enter(perf_update);
get_inputs( dt, indexstart );
if (!initiateStart && !finishSequence && !failSequence) get_inputs( dt, indexstart ); // The racer is not started : no need to get inputs and we are not in fail or finish sequence
else get_minimum_inputs(); // the we can just have minimum inputs
dt = ((float) (time_update+time_render+time_project) / 1000.0);
if (!SkipTime)
{
dt = ((float) (time_update+time_render+time_project) / 1000.0);
}
else
{
dt = 0;
SkipTime=false;
}
start_time -= (time_update+time_render+time_project);
if (initiateStart)
{
startCount -= dt*1000;
startRemaining = ((float) (startCount) / 100000.0);
}
start_time -= dt*1000;
if (start_time<0) start_time=0;
remaining_time = ((float) (start_time) / 1000000.0);
@ -703,6 +778,46 @@ int main(void)
else dsubimage( 48, 25, &speedhud, 0, 104, 76, 13, DIMAGE_NONE);
if (initiateStart) // We are in the start sequence with the countdown
{
dfont(&startseq);
if (startRemaining<54 && startRemaining>46)
{
dprint_opt(200,114, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_CENTER, ">5<" );
dprint_opt(198,112, C_RGB(255,0,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, ">5<" );
}
else if (startRemaining<44 && startRemaining>36)
{
dprint_opt(200,114, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_CENTER, ">4<" );
dprint_opt(198,112, C_RGB(255,0,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, ">4<" );
}
else if (startRemaining<34 && startRemaining>26)
{
dprint_opt(200,114, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_CENTER, ">3<" );
dprint_opt(198,112, C_RGB(255,0,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, ">3<" );
}
else if (startRemaining<24 && startRemaining>16)
{
dprint_opt(200,114, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_CENTER, ">2<" );
dprint_opt(198,112, C_RGB(255,0,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, ">2<" );
}
else if (startRemaining<14 && startRemaining>6)
{
dprint_opt(200,114, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_CENTER, ">1<" );
dprint_opt(198,112, C_RGB(255,0,255), C_NONE, DTEXT_CENTER, DTEXT_CENTER, ">1<" );
}
else if (startRemaining<4 && startRemaining>-4)
{
dimage( 198-bigflag.width/2, 112-bigflag.height/2, &bigflag );
}
else if (startRemaining<-4)
{
start_time = 99000000;
initiateStart=false;
}
}
//dupdate();
//dprint( 3, 202, C_BLACK, "%.0f", dt );
@ -710,6 +825,7 @@ int main(void)
if (BDrawFPS)
{
dfont(&speedfont);
dsubimage( 5, 205, &speedhud, 0, 143, 27, 13, DIMAGE_NONE); // fps logo
dprint_opt(42,202, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "%.0f <", (float) (1000.0f/dt) ); // the '>' symbol corresponds to "fps"
@ -774,13 +890,13 @@ int main(void)
freeDecoration();
for(int i=0; i<circuit.size(); i++ ) delete circuit[i]; // Not to forget to delete each elements
for(unsigned int i=0; i<circuit.size(); i++ ) delete circuit[i]; // Not to forget to delete each elements
circuit.clear();
for(int i=0; i<nuages.size(); i++ ) delete nuages[i]; // Not to forget to delete each elements
for(unsigned int i=0; i<nuages.size(); i++ ) delete nuages[i]; // Not to forget to delete each elements
nuages.clear();
for(int i=0; i<traffic.size(); i++ ) delete traffic[i]; // Not to forget to delete each elements
for(unsigned int i=0; i<traffic.size(); i++ ) delete traffic[i]; // Not to forget to delete each elements
traffic.clear();
}

View File

@ -433,7 +433,7 @@ void createCircuit( int circuitNumber )
void putBillBoards( void )
{
for (int k = 0; k<circuit.size()-3; k++ )
for (unsigned int k = 0; k<circuit.size()-3; k++ )
{
int nextcurve = circuit[k+3]->Curve;
int currentcurve = circuit[k]->Curve;
@ -1247,7 +1247,7 @@ void drawDecoration( uint16_t index )
void updateTraffic( float dt, uint32_t maxdistance )
{
for(int k=0; k<traffic.size(); k++)
for(unsigned int k=0; k<traffic.size(); k++)
{
traffic[k]->wZ += traffic[k]->Speed*dt;
if (traffic[k]->wZ>maxdistance) traffic[k]->wZ-=maxdistance;

View File

@ -29,12 +29,20 @@ bool doneMenuCredit = false;
bool doneOptions = false;
uint8_t OptionsSelection=0;
bool donePauseQuit = false;
uint8_t PauseQuitSelection=0;
extern bool BDrawDeco;
extern bool BDrawClds;
extern bool BDrawCars;
extern bool BDrawFPS;
extern bool BDrawBack;
extern bool exitToOS;
extern bool stop;
extern bool SkipTime;
void drawStartTitle( void )
{
@ -592,6 +600,8 @@ void drawOptions( void )
#endif
}
SkipTime = true;
return;
}
@ -637,3 +647,113 @@ void getInputOptions( void )
void drawPauseQuit( void )
{
uint16_t pulse=0;
donePauseQuit = false;
PauseQuitSelection=0;
while (!donePauseQuit)
{
dclear(0x0000);
dimage( 0, 0, &mainscreen);
dfont(&autofont);
dprint_opt(102, 22, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "GAME PAUSED" );
dprint_opt(100, 20, C_RGB(255,0,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "GAME PAUSED" );
dprint_opt(102, 82, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "FINISH RACE" );
if (PauseQuitSelection!=0) dprint_opt(100, 80, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "FINISH RACE" );
else dprint_opt(100, 80, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "FINISH RACE" );
dprint_opt(102, 122, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "MAIN MENU" );
if (PauseQuitSelection!=1) dprint_opt(100, 120, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "MAIN MENU" );
else dprint_opt(100, 120, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "MAIN MENU" );
dprint_opt(102, 162, C_RGB(0,0,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO OS" );
if (PauseQuitSelection!=2) dprint_opt(100, 160, C_RGB(255,255,255), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO OS" );
else dprint_opt(100, 160, C_RGB(pulse%256,0,pulse%256), C_NONE, DTEXT_LEFT, DTEXT_TOP, "BACK TO OS" );
dimage( 10, 70+40*PauseQuitSelection, &flag );
// CODE HERE TO PRINT WELCOME MENU
dupdate();
pulse++;
getInputPauseQuit();
#if IS_FXLIB==1
if (screenshot && usb_is_open())
{
usb_fxlink_screenshot(false);
screenshot = false;
}
if(record && usb_is_open())
{
usb_fxlink_videocapture(false);
}
#endif
}
SkipTime = true;
return;
}
void getInputPauseQuit( void )
{
int opt = GETKEY_DEFAULT & ~GETKEY_REP_ARROWS;
int timeout = 1;
while(1)
{
key_event_t ev = getkey_opt(opt, &timeout);
if(ev.type == KEYEV_NONE) return;
int key = ev.key;
if (key==KEY_EXE)
{
if (PauseQuitSelection==0)
{
donePauseQuit=true;
}
else if (PauseQuitSelection==1)
{
stop=true;
donePauseQuit=true;
}
else if (PauseQuitSelection==2)
{
stop =true;
exitToOS=true;
donePauseQuit=true;
}
}
if (key==KEY_UP)
{
if (PauseQuitSelection==0) PauseQuitSelection=2;
else PauseQuitSelection--;
}
if (key==KEY_DOWN)
{
if (PauseQuitSelection==2) PauseQuitSelection=0;
else PauseQuitSelection++;
}
#if IS_FXLIB==1
if(keydown(KEY_F5)) screenshot = true;
if(keydown(KEY_F6)) record = !record;
#endif // IS_FXLIB
}
}