WIP : improved menu navigation + development of sliding in curves

master
Sylvain PILLOT 5 months ago
parent a664af3a64
commit ee5d6402d6
  1. 5
      CMakeLists.txt
  2. 166
      CppOutRun.layout
  3. 16
      MyLogFile.log
  4. BIN
      assets-cg/player/smoke1.png
  5. BIN
      assets-cg/player/smoke2.png
  6. BIN
      assets-cg/player/smoke3.png
  7. BIN
      assets-cg/screens/mainscrbright.png
  8. BIN
      assets-cg/screens/mainscreen.png
  9. 2
      capture
  10. 1
      correct
  11. 2
      send
  12. 1
      src/include/circuit.h
  13. 13
      src/include/segment.h
  14. 140
      src/main.cc
  15. 2
      src/parameters.h
  16. 40
      src/src/circuit.cc
  17. 4
      src/src/menus.cc

@ -66,6 +66,10 @@ set(ASSETS_cg
assets-cg/decos/common/cc_void.png
assets-cg/player/player.png
assets-cg/player/smoke1.png
assets-cg/player/smoke2.png
assets-cg/player/smoke3.png
assets-cg/clouds/sky1.png
assets-cg/clouds/sky2.png
assets-cg/clouds/sky3.png
@ -100,6 +104,7 @@ set(ASSETS_cg
assets-cg/hud/speedhud.png
assets-cg/screens/mainscreen.png
assets-cg/screens/mainscrbright.png
assets-cg/miniscreen/africa1.png
assets-cg/miniscreen/desert1.png

@ -2,108 +2,104 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Release" />
<File name="src/src/circuit.cc" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/clouds.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="31927" topLine="269" />
<Cursor1 position="306" topLine="0" />
</Cursor>
<Folding>
<Collapse line="68" />
<Collapse line="102" />
<Collapse line="154" />
<Collapse line="192" />
<Collapse line="229" />
<Collapse line="274" />
<Collapse line="292" />
<Collapse line="381" />
<Collapse line="554" />
<Collapse line="602" />
<Collapse line="612" />
<Collapse line="661" />
<Collapse line="711" />
<Collapse line="762" />
<Collapse line="835" />
<Collapse line="872" />
<Collapse line="1148" />
<Collapse line="1155" />
<Collapse line="1165" />
<Collapse line="1175" />
</Folding>
</File>
<File name="src/include/utils.h" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="TODO.txt" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="107" topLine="0" />
<Cursor1 position="251" topLine="0" />
</Cursor>
</File>
<File name="src/include/drawstuff.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/fixed.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="655" topLine="0" />
<Cursor1 position="5" topLine="0" />
</Cursor>
</File>
<File name="src/src/saves.cc" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/segment.cc" open="0" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<Cursor>
<Cursor1 position="294" topLine="2" />
<Cursor1 position="410" topLine="29" />
</Cursor>
</File>
<File name="src/include/menus.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/circuit.cc" open="1" top="1" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="505" topLine="0" />
<Cursor1 position="21782" topLine="81" />
</Cursor>
<Folding>
<Collapse line="67" />
<Collapse line="69" />
<Collapse line="103" />
<Collapse line="155" />
<Collapse line="193" />
<Collapse line="230" />
<Collapse line="275" />
<Collapse line="293" />
<Collapse line="382" />
<Collapse line="606" />
<Collapse line="747" />
<Collapse line="798" />
<Collapse line="833" />
<Collapse line="871" />
<Collapse line="908" />
<Collapse line="1184" />
<Collapse line="1191" />
<Collapse line="1201" />
<Collapse line="1211" />
</Folding>
</File>
<File name="src/include/segment.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/segment.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="783" topLine="3" />
<Cursor1 position="335" topLine="15" />
</Cursor>
</File>
<File name="src/src/cars.cc" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/clock.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1019" topLine="8" />
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="src/include/saves.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/utils.h" open="0" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="319" topLine="0" />
<Cursor1 position="107" topLine="0" />
</Cursor>
</File>
<File name="src/src/camera.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/cars.cc" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="370" topLine="0" />
<Cursor1 position="1019" topLine="8" />
</Cursor>
</File>
<File name="src/include/cars.h" open="0" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="CMakeLists.txt" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="412" topLine="1" />
<Cursor1 position="2812" topLine="78" />
</Cursor>
</File>
<File name="src/include/camera.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/saves.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="221" topLine="0" />
<Cursor1 position="294" topLine="2" />
</Cursor>
</File>
<File name="src/colors.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/saves.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="35" topLine="0" />
<Cursor1 position="319" topLine="0" />
</Cursor>
</File>
<File name="src/main.cc" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="-2" zoom_2="0">
<File name="src/include/drawstuff.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="43460" topLine="306" />
<Cursor1 position="655" topLine="0" />
</Cursor>
<Folding>
<Collapse line="141" />
<Collapse line="203" />
<Collapse line="211" />
<Collapse line="219" />
</Folding>
</File>
<File name="src/clock.cc" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/cars.h" open="0" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5691" topLine="162" />
<Cursor1 position="412" topLine="0" />
</Cursor>
</File>
<File name="src/include/clouds.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/main.cc" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="-2" zoom_2="0">
<Cursor>
<Cursor1 position="306" topLine="0" />
<Cursor1 position="43265" topLine="1107" />
</Cursor>
<Folding>
<Collapse line="144" />
</Folding>
</File>
<File name="src/src/drawstuff.cc" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
@ -118,61 +114,61 @@
<Collapse line="131" />
</Folding>
</File>
<File name="src/src/utils.cc" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/clock.cc" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="30" topLine="0" />
<Cursor1 position="5691" topLine="162" />
</Cursor>
</File>
<File name="src/src/segment.cc" open="0" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<File name="src/src/camera.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="410" topLine="29" />
<Cursor1 position="370" topLine="0" />
</Cursor>
</File>
<File name="CMakeLists.txt" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/parameters.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="302" topLine="0" />
<Cursor1 position="505" topLine="0" />
</Cursor>
</File>
<File name="src/src/clouds.cc" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/colors.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="203" topLine="0" />
<Cursor1 position="35" topLine="0" />
</Cursor>
</File>
<File name="src/clock.h" open="1" top="1" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/menus.cc" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
<Cursor1 position="1654" topLine="69" />
</Cursor>
<Folding>
<Collapse line="116" />
<Collapse line="551" />
<Collapse line="666" />
<Collapse line="709" />
<Collapse line="872" />
</Folding>
</File>
<File name="src/parameters.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/utils.cc" open="0" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="505" topLine="0" />
<Cursor1 position="30" topLine="0" />
</Cursor>
</File>
<File name="src/include/circuit.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/camera.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1093" topLine="47" />
<Cursor1 position="221" topLine="0" />
</Cursor>
</File>
<File name="src/src/menus.cc" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/circuit.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="46095" topLine="898" />
<Cursor1 position="933" topLine="0" />
</Cursor>
<Folding>
<Collapse line="116" />
<Collapse line="551" />
<Collapse line="666" />
<Collapse line="709" />
<Collapse line="872" />
</Folding>
</File>
<File name="TODO.txt" open="0" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/clouds.cc" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="251" topLine="0" />
<Cursor1 position="203" topLine="0" />
</Cursor>
</File>
<File name="src/fixed.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/menus.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="5" topLine="0" />
<Cursor1 position="505" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>

@ -0,0 +1,16 @@
Jalons 0 --> Lap = 0 : Type = 0 ; Position = 9600
Jalons 1 --> Lap = 0 : Type = 1 ; Position = 344100
Jalons 2 --> Lap = 0 : Type = 1 ; Position = 618600
Jalons 3 --> Lap = 0 : Type = 1 ; Position = 698100
Jalons 4 --> Lap = 0 : Type = 2 ; Position = 972600
Jalons 0 --> Lap = 0 : Type = 0 ; Position = 9600
Jalons 1 --> Lap = 0 : Type = 2 ; Position = 254100
Jalons 2 --> Lap = 1 : Type = 0 ; Position = 9600
Jalons 3 --> Lap = 1 : Type = 2 ; Position = 254100
Jalons 4 --> Lap = 2 : Type = 0 ; Position = 9600
Jalons 5 --> Lap = 2 : Type = 2 ; Position = 254100
Jalons 0 --> Lap = 0 : Type = 0 ; Position = 9600
Jalons 1 --> Lap = 0 : Type = 1 ; Position = 254100
Jalons 2 --> Lap = 0 : Type = 1 ; Position = 423600
Jalons 3 --> Lap = 0 : Type = 1 ; Position = 540600
Jalons 4 --> Lap = 0 : Type = 2 ; Position = 935100

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 138 KiB

After

Width:  |  Height:  |  Size: 97 KiB

@ -1 +1 @@
fxlink -iw
fxlink -iw --quiet --fxlink-log=MyLogFile.log

@ -0,0 +1 @@
fxsdk build-cg VERBOSE=1

@ -1 +1 @@
fxlink -sw *.g3a
fxlink -sw -u *.g3a

@ -62,6 +62,7 @@ enum Decoration
void initData( void );
void createCircuit( int circuitNumber );
void putBillBoards( void );
void createMilestones( uint8_t nblap );
void createClouds( void );
void createTraffic( uint16_t maxSegment );

@ -25,6 +25,19 @@ enum Specialty
FINISH = 2
};
class MileStone
{
public:
MileStone( ) {type = -1; wZ = 0.0; lap = 0; };
MileStone( uint8_t t, double Z, uint8_t l ) {type = t; wZ = Z; lap = l; };
~MileStone( ) { };
uint8_t type;
double wZ;
uint8_t lap;
} ;
class Segment
{
public:

@ -36,10 +36,10 @@
#define DEBUGXXX 0
#define OVERCLCK_ACTIVABLE 1
char version[5] = {'V','1','.','0','7'};
char version[5] = {'V','1','.','0','8'};
extern bopti_image_t player;
extern bopti_image_t player, smoke1, smoke2, smoke3;
extern font_t speedfont, startseq, plate, autofont;
extern bopti_image_t speedhud;
extern bopti_image_t flag, bigflag;
@ -49,6 +49,8 @@ int CurrentCircuitBiome = PLAINS;
std::vector<Segment*> circuit;
std::vector<Clouds*> nuages;
std::vector<Cars*> traffic;
std::vector<MileStone*> jalons;
int MAX_SEGMENT=0;
camera *cam;
@ -191,6 +193,11 @@ void initEverything( void )
}
float timepressed = 0.0f;
int directionPressed = 0;
bool CarIsSliding = false;
uint16_t framesmoke = 0;
static void get_inputs( float dt, int index )
{
CC = circuit[index]->Curve;
@ -213,36 +220,47 @@ static void get_inputs( float dt, int index )
{
viewside=-1;
if (CurrentCircuitBiome==FINLAND) cam->decX( CC*dt*speed/50 ); // very hard to turn in Finland with snow
else if (CurrentCircuitBiome==AFRICA) cam->decX( CC*dt*speed/75 ); // hard in Africa with dirt
else cam->decX( CC*dt*speed/100 ); // more easy on normal roads
if (CurrentCircuitBiome==FINLAND) cam->decX( CC*dt*speed/50); // 50 ); // very hard to turn in Finland with snow
else if (CurrentCircuitBiome==AFRICA) cam->decX( CC*dt*speed/70); //75 ); // hard in Africa with dirt
else cam->decX( CC*dt*speed/85); // 100 ); // more easy on normal roads
}
else if (CC>0)
{
viewside=+1;
if (CurrentCircuitBiome==FINLAND) cam->decX( CC*dt*speed/50 ); // very hard to turn in Finland with snow
else if (CurrentCircuitBiome==AFRICA) cam->decX( CC*dt*speed/75 ); // hard in Africa with dirt
else cam->decX( CC*dt*speed/100 ); // more easy on normal roads
if (CurrentCircuitBiome==FINLAND) cam->decX( CC*dt*speed/50); // 50 ); // very hard to turn in Finland with snow
else if (CurrentCircuitBiome==AFRICA) cam->decX( CC*dt*speed/70); //75 ); // hard in Africa with dirt
else cam->decX( CC*dt*speed/85); // 100 ); // more easy on normal roads
}
if(keydown(KEY_LEFT) || keydown(KEY_F5))
{
cam->decX(5.0*speed*direction);
/// This is to implement sliding and speed loss
if (directionPressed!=-1) directionPressed=-1, timepressed = 0.0f;
else if (directionPressed==-1 && CC<0) timepressed += dt;
viewside=-1;
if (CC<0) viewside=-2; // We are in a curve and turning
if (CC>0) viewside=0;
}
if(keydown(KEY_RIGHT) || keydown(KEY_F6))
else if(keydown(KEY_RIGHT) || keydown(KEY_F6))
{
cam->incX(5.0*speed*direction);
/// This is to implement sliding and speed loss
if (directionPressed!=1) directionPressed=1, timepressed = 0.0f;
else if (directionPressed==1 && CC>0) timepressed += dt;
viewside=1;
if (CC>0) viewside=+2;
if (CC<0) viewside=0;
}
else if (!keydown(KEY_RIGHT) && !keydown(KEY_F6) && !keydown(KEY_LEFT) && !keydown(KEY_F5))
{
directionPressed=0, timepressed = 0.0f;
}
if(keydown(KEY_SHIFT) || keydown(KEY_XOT) || keydown(KEY_F1)) // Accelerates
{
@ -284,7 +302,7 @@ static void get_inputs( float dt, int index )
speedcontrol = true;
}
if(keydown(KEY_EXIT)) drawPauseQuit();
if(keydown(KEY_EXIT) || keydown(KEY_SHIFT)) drawPauseQuit();
if(keydown(KEY_OPTN)) drawOptions();
@ -328,6 +346,21 @@ static void get_inputs( float dt, int index )
cam->cX=fix(0.0*ROAD_WIDTH); //set the car in the center of the road (was formerly 0.75)
}
/// This part controls the sliding of player's car, if we keep pressed the keys to turn too long, the car starts sliding, smoke will appear and speed is decreasing
if (timepressed>=300.0f) // was 500.0f
{
CarIsSliding = true;
cam->decX( CC*dt*speed/50 );
speed = speed * 0.975;
framesmoke++;
}
else
{
CarIsSliding = false;
framesmoke=0;
}
}
@ -467,13 +500,6 @@ int main(void)
do
{
/*
_uram_stats = kmalloc_get_gint_stats(_uram);
sprintf( texttosend, "[Begining of loop] Memory Status - Used: %d - Free: %d - Peak Used: %d", _uram_stats->used_memory, _uram_stats->free_memory, _uram_stats->peak_used_memory);
usb_fxlink_text(texttosend, 0);
*/
// Try to restart from very begining
initEverything();
@ -554,8 +580,6 @@ int main(void)
if (!exitToOS)
{
//stage = selectedCircuit;
if (selectedCircuit==0) CurrentCircuitBiome = PLAINS, multilap = false, currentLap = 1, numlap = 1;
else if (selectedCircuit==1) CurrentCircuitBiome = DESERT, multilap = false, currentLap = 1, numlap = 1;
else if (selectedCircuit==2) CurrentCircuitBiome = USA, multilap = false, currentLap = 1, numlap = 1;
@ -576,18 +600,18 @@ int main(void)
prof_enter(perf_create);
initData( ); // Positioning of the Camera
createCircuit( selectedCircuit ); // Creates the circuit
MAX_SEGMENT = circuit.size();
//uint32_t maxDistance = (MAX_SEGMENT-nbInterestingSegments-5)*SEGMENT_LENGTH;
double maxDistance = (double) ((MAX_SEGMENT-1)*SEGMENT_LENGTH);
putBillBoards();
createMilestones( numlap );
createClouds(); // Creates the Sky and Clouds
if (mode==0)
@ -601,15 +625,6 @@ int main(void)
else if (CarsNumb==3) NB_CARS_TRAFFIC=300;
else NB_CARS_TRAFFIC=100;
}
/* else if (selectedCircuit==4) // except for Africa which is very heavy so we need more memory
{
if (CarsNumb==0) NB_CARS_TRAFFIC=50;
else if (CarsNumb==1) NB_CARS_TRAFFIC=75;
else if (CarsNumb==2) NB_CARS_TRAFFIC=100;
else if (CarsNumb==3) NB_CARS_TRAFFIC=150;
else NB_CARS_TRAFFIC=75;
}
*/
else // while circular needs much less
{
if (CarsNumb==0) NB_CARS_TRAFFIC=25;
@ -625,15 +640,6 @@ int main(void)
prepareDecoration( CurrentCircuitBiome ); // Prepares the multiple variations of Decoration (image scaling)
#if DEBUGXXX==1
_uram_stats = kmalloc_get_gint_stats(_uram);
extram_stats = kmalloc_get_gint_stats(&extended_ram);
sprintf( texttosend, "[_U RAM] Memory Status - Used: %d - Free: %d - Peak Used: %d", _uram_stats->used_memory, _uram_stats->free_memory, _uram_stats->peak_used_memory);
if (usb_is_open()) usb_fxlink_text(texttosend, 0);
sprintf( texttosend, "[EXT RAM] Memory Status - Used: %d - Free: %d - Peak Used: %d", extram_stats->used_memory, extram_stats->free_memory, extram_stats->peak_used_memory);
if (usb_is_open()) usb_fxlink_text(texttosend, 0);
#endif // DEBUGXXX
prof_leave(perf_create);
time_create = prof_time(perf_create);
@ -698,14 +704,11 @@ int main(void)
//--------------
if (fround(cam->cZ)<=0) cam->cZ=fixdouble(0.0);
//if (fround(cam->cZ)>=maxDistance) cam->cZ=fixdouble(maxDistance);
indexstart = fround(cam->cZ) / SEGMENT_LENGTH;
if (indexstart<0) indexstart=0;
indexend = indexstart+nbInterestingSegments+1;
//if (indexstart>MAX_SEGMENT-nbInterestingSegments-2) indexstart=MAX_SEGMENT-nbInterestingSegments-2;
prof_leave(perf_update);
time_update = prof_time(perf_update);
@ -727,11 +730,8 @@ int main(void)
uint16_t CarSegment = traffic[k]->wZ / SEGMENT_LENGTH;
if (CarSegment>=indexstart && CarSegment<indexend)
{
//traffic[k]->visible = true;
circuit[CarSegment]->CarList.push_back(k);
}
//else
//traffic[k]->visible = false;
}
float roadpart = f2float(cam->cX)/(float) ROAD_WIDTH;
@ -820,21 +820,6 @@ int main(void)
unsigned int k = circuit[u]->CarList[v];
/*
if (traffic[k]->Turn == -1)
{
traffic[k]->wX -= 0.10;
if (traffic[k]->wX==-0.75 || traffic[k]->wX==-0.25 || traffic[k]->wX==0.25) traffic[k]->Turn = 0;
}
else if (traffic[k]->Turn == 1)
{
traffic[k]->wX += 0.10;
if (traffic[k]->wX==-0.25 || traffic[k]->wX==0.25 || traffic[k]->wX==0.75) traffic[k]->Turn = 0;
}
*/
traffic[k]->wX += (float) traffic[k]->Turn * 0.05f;
if (traffic[k]->wX>=-0.775 && traffic[k]->wX<=-0.725) traffic[k]->wX = -0.75, traffic[k]->Turn = 0;
else if (traffic[k]->wX>=-0.275 && traffic[k]->wX<=-0.225) traffic[k]->wX = -0.25, traffic[k]->Turn = 0;
@ -852,7 +837,6 @@ int main(void)
{
projectCircuitFP( k ); // We project the current segment
//if (k!= indexend && circuit[k]->Y < minYRoad) // This is a trick to save precious time while drawing the Sky
if (circuit[k]->Y <= minYRoad) minYRoad = circuit[k]->Y;
circuit[k]->CumulatedCurve = cumulCurve; // This is the curve accumulated when we are drawing curves
@ -934,15 +918,6 @@ int main(void)
score += 5000;
circuit[indexstart]->CheckValidated = true;
#if DEBUGXXX==1
if (usb_is_open())
{
//sprintf( texttosend, "CKPT : Chrono %D - %D", elapsed_time/1000000, start_time/1000000 );
sprintf( texttosend, "CKPT : Chrono %D - Reste %D - Extra %D --> Total %D", elapsed_time/1000000, (start_time-circuit[indexstart]->Extratime+handicap)/1000000, (circuit[indexstart]->Extratime-handicap)/1000000, start_time/1000000 );
usb_fxlink_text(texttosend, 0);
}
#endif
}
else if (circuit[indexstart]->Special == FINISH && circuit[indexstart]->CheckValidated == false && circuit[indexstart]->CheckLap!=currentLap)
{
@ -1048,6 +1023,13 @@ int main(void)
else if (viewside==1) dprint_opt( 193, 203, C_WHITE, C_BLACK, DTEXT_CENTER, DTEXT_CENTER, "%c%c%c", PlayerName[0], PlayerName[1], PlayerName[2] );
else if (viewside==2) dprint_opt( 189, 203, C_WHITE, C_BLACK, DTEXT_CENTER, DTEXT_CENTER, "%c%c%c", PlayerName[0], PlayerName[1], PlayerName[2] );
if (CarIsSliding)
{
if (framesmoke>=0 && framesmoke<10) dimage(SCREEN_CX-smoke1.width/2, SCREEN_HEIGHT-smoke1.height, &smoke1 );
else if (framesmoke>=10 && framesmoke<20) dimage(SCREEN_CX-smoke2.width/2, SCREEN_HEIGHT-smoke2.height, &smoke2 );
else if (framesmoke>=30 && framesmoke<30) dimage(SCREEN_CX-smoke3.width/2, SCREEN_HEIGHT-smoke3.height, &smoke3 );
else framesmoke=0;
}
if (direction==+1) score += speed*dt/10;
@ -1118,27 +1100,14 @@ int main(void)
if (mode==1 && !skipranking)
{
#if DEBUGXXX==1
if (usb_is_open()) usb_fxlink_text("save perf", 0);
#endif
bool donerank = false;
int k=0;
while (!donerank && k<5)
{
#if DEBUGXXX==1
if (usb_is_open()) usb_fxlink_text("in the loop", 0);
#endif
if (FinalTime<=HallOfFame[selectedCircuit][k].bestTime)
{
#if DEBUGXXX==1
if (usb_is_open()) usb_fxlink_text("found", 0);
#endif
for( int l=4; l>k; l--)
{
HallOfFame[selectedCircuit][l].playerName[0] = HallOfFame[selectedCircuit][l-1].playerName[0];
@ -1347,6 +1316,9 @@ int main(void)
for(unsigned int i=0; i<circuit.size(); i++ ) delete circuit[i]; // Not to forget to delete each elements
circuit.clear();
for(unsigned int i=0; i<jalons.size(); i++ ) delete jalons[i]; // Not to forget to delete each elements
jalons.clear();
for(unsigned int i=0; i<nuages.size(); i++ ) delete nuages[i]; // Not to forget to delete each elements
nuages.clear();

@ -28,7 +28,7 @@
#define std ustl
#define IS_FXLIB 0
#define IS_FXLIB 1
#endif // PARAMETERS_H

@ -25,6 +25,7 @@ extern uint16_t NB_CARS_TRAFFIC;
extern std::vector<Segment*> circuit;
extern std::vector<Clouds*> nuages;
extern std::vector<Cars*> traffic;
extern std::vector<MileStone*> jalons;
extern camera *cam;
extern uint16_t currentcurve;
@ -549,6 +550,41 @@ void putBillBoards( void )
}
void outputMilestones( void )
{
char texttosend[1024];
if (usb_is_open())
{
for(int k = 0; k< jalons.size(); k++)
{
sprintf( texttosend, "Jalons %d --> Lap = %d : Type = %d ; Position = %.0f \n", k, jalons[k]->lap, jalons[k]->type, jalons[k]->wZ );
usb_fxlink_text(texttosend, 0);
}
}
}
void createMilestones( uint8_t nblap )
{
for( unsigned int l=0; l<nblap;l++)
{
for (unsigned int k = 0; k<circuit.size(); k++ )
{
if (circuit[k]->Special != -1)
{
MileStone *mile=new MileStone( );
mile->type = circuit[k]->Special;
mile->wZ = (double) ((double) k * (double) SEGMENT_LENGTH);
mile->lap = l ;
jalons.push_back(mile);
}
}
}
#if DEBUGXXX==1
outputMilestones();
#endif // DEBUGXXX
}
void createClouds( void )
@ -579,8 +615,8 @@ void createTraffic( uint16_t maxSegment )
uint8_t S;
// if Difficulty = easy, all cars are at the same speed 175km/h)
if (DiffLevel==0) S=3.5;
else S = 2 + (rand() % 3); // else speed is random and then overtaking can happen
if (DiffLevel==0) S=4.0;
else S = 3.5 + (rand() % 2); // else speed is random and then overtaking can happen
uint8_t T = rand() % 8;

@ -19,7 +19,7 @@ extern uint8_t NB_CARS_TRAFFIC;
extern bool isOCPossible;
extern bool isOCActivated;
extern bopti_image_t mainscreen;
extern bopti_image_t mainscreen, mainscrbright;
extern bopti_image_t africa1, desert1, finland1, plains1, usa1;
extern bopti_image_t flag, linear, circular;
extern font_t autofont, autofontsmall, speedfont;
@ -79,7 +79,7 @@ void drawStartTitle( void )
{
dclear( C_BLACK );
dsubimage( 0, 32, &mainscreen, 0, 32, 396, 160, DIMAGE_NONE);
dsubimage( 0, 32, &mainscrbright, 0, 32, 396, 160, DIMAGE_NONE);
dfont(&autofont);

Loading…
Cancel
Save