From a421c6186f870c6e0518d5bfd8dcdfb1d9c7eb53 Mon Sep 17 00:00:00 2001 From: Slyvtt Date: Tue, 31 May 2022 21:25:52 +0200 Subject: [PATCH] WIP : improved HUD & sliding in curves --- CppOutRun.layout | 148 +++++++++++++++++++++++------------------------ src/main.cc | 44 +++++++++++--- 2 files changed, 109 insertions(+), 83 deletions(-) diff --git a/CppOutRun.layout b/CppOutRun.layout index fe9c033..4114f50 100644 --- a/CppOutRun.layout +++ b/CppOutRun.layout @@ -2,24 +2,34 @@ + + + + + + + + + + + + + + + - + - - - - - - + @@ -49,26 +59,14 @@ - + - + - + - - - - - - - - - - - - - + @@ -76,9 +74,39 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -94,6 +122,11 @@ + + + + + @@ -102,55 +135,17 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + @@ -162,9 +157,14 @@ - + - + + + + + + diff --git a/src/main.cc b/src/main.cc index 1eeef8d..fce7e02 100644 --- a/src/main.cc +++ b/src/main.cc @@ -200,6 +200,7 @@ void initEverything( void ) float timepressed = 0.0f; +float timeunpressed = 0.0f; int directionPressed = 0; bool CarIsSliding = false; uint16_t framesmoke = 0; @@ -247,6 +248,8 @@ static void get_inputs( float dt, int index ) if (directionPressed!=-1) directionPressed=-1, timepressed = 0.0f; else if (directionPressed==-1 && CC<0) timepressed += dt; + timeunpressed = 0.0f; + viewside=-1; if (CC<0) viewside=-2; // We are in a curve and turning if (CC>0) viewside=0; @@ -259,6 +262,8 @@ static void get_inputs( float dt, int index ) if (directionPressed!=1) directionPressed=1, timepressed = 0.0f; else if (directionPressed==1 && CC>0) timepressed += dt; + timeunpressed = 0.0f; + viewside=1; if (CC>0) viewside=+2; if (CC<0) viewside=0; @@ -266,6 +271,7 @@ static void get_inputs( float dt, int index ) else if (!keydown(KEY_RIGHT) && !keydown(KEY_F6) && !keydown(KEY_LEFT) && !keydown(KEY_F5)) { directionPressed=0, timepressed = 0.0f; + timeunpressed += dt; } if(keydown(KEY_SHIFT) || keydown(KEY_XOT) || keydown(KEY_F1)) // Accelerates @@ -357,20 +363,39 @@ static void get_inputs( float dt, int index ) if (timepressed>=300.0f) // was 500.0f { CarIsSliding = true; - cam->decX( CC*dt*speed/50 ); + cam->decX( CC*dt*speed/30.0f ); // was 50.0f speed = speed * 0.975; framesmoke++; } - else + else if (timeunpressed>=200.0f) { CarIsSliding = false; - framesmoke=0; + framesmoke = 0; } } -static void get_minimum_inputs( void ) +static void get_inputs_start( 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_7)) screenshot = true; + if(keydown(KEY_8)) record = !record; +#endif // IS_FXLIB +} + + +static void get_inputs_finish_fail( void ) { key_event_t ev; while((ev = pollevent()).type != KEYEV_NONE) @@ -389,7 +414,6 @@ static void get_minimum_inputs( void ) } - int main(void) { __printf_enable_fp(); @@ -693,7 +717,9 @@ int main(void) prof_enter(perf_update); 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 + else if (initiateStart) get_inputs_start(); // If we are in the start sequence, not need to check for restart we can just have minimum inputs + else if (finishSequence || failSequence) get_inputs_finish_fail(); + //former position @@ -1077,11 +1103,11 @@ int main(void) dprint_opt(390,3, C_RGB(0,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.3D", score ); dprint_opt(388,1, C_RGB(255,255,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.3D", score ); // the ';' char corresponds to "s" - dprint_opt(390,23, C_RGB(0,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.3D", stage ); - dprint_opt(388,21, C_RGB(255,255,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.3D", stage ); // the ';' char corresponds to "s" + dprint_opt(390,23, C_RGB(0,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.3D/%d", stage, jalons.size() ); + dprint_opt(388,21, C_RGB(255,255,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.3D/%d", stage, jalons.size() ); // the ';' char corresponds to "s" - if (multilap) + //if (multilap) { dsubimage( 135, 25, &speedhud, 28, 143, 27, 13, DIMAGE_NONE); // Lap logo