fps counter / improved collisions & sliding in curves

This commit is contained in:
Sylvain PILLOT 2022-03-19 23:29:36 +01:00
parent 49a55bc86f
commit 52c96249c0
12 changed files with 283 additions and 164 deletions

View File

@ -72,6 +72,7 @@ set(ASSETS_cg
assets-cg/backgrnd/canyon.png
assets-cg/backgrnd/rockline.png
assets-cg/backgrnd/snowmount.png
assets-cg/backgrnd/treelinesnow.png
assets-cg/backgrnd/kilimandjaro.png
assets-cg/billboard/leftturn.png

View File

@ -2,40 +2,23 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Release" />
<File name="src/fixed.h" open="0" top="0" tabpos="2" 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="0" zoom_2="0">
<Cursor>
<Cursor1 position="778" topLine="0" />
</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">
<Cursor>
<Cursor1 position="221" topLine="0" />
</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">
<Cursor>
<Cursor1 position="1019" topLine="8" />
</Cursor>
</File>
<File name="src/src/menus.cc" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1477" topLine="72" />
<Cursor1 position="25" topLine="123" />
</Cursor>
<Folding>
<Collapse line="316" />
<Collapse line="175" />
<Collapse line="181" />
<Collapse line="187" />
<Collapse line="193" />
</Folding>
</File>
<File name="src/colors.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="678" topLine="0" />
</Cursor>
</File>
<File name="src/parameters.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="399" topLine="0" />
<Cursor1 position="339" topLine="0" />
</Cursor>
</File>
<File name="src/src/drawstuff.cc" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/drawstuff.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2516" topLine="0" />
</Cursor>
@ -45,44 +28,60 @@
<Collapse line="76" />
</Folding>
</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="CMakeLists.txt" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/fixed.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1699" topLine="35" />
<Cursor1 position="778" topLine="0" />
</Cursor>
</File>
<File name="src/include/drawstuff.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/menus.cc" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="622" topLine="0" />
<Cursor1 position="14167" topLine="333" />
</Cursor>
<Folding>
<Collapse line="32" />
<Collapse line="96" />
<Collapse line="330" />
</Folding>
</File>
<File name="src/src/circuit.cc" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="28190" topLine="721" />
</Cursor>
<Folding>
<Collapse line="433" />
<Collapse line="501" />
<Collapse line="517" />
<Collapse line="588" />
<Collapse line="633" />
<Collapse line="1092" />
<Collapse line="1099" />
<Collapse line="1109" />
<Collapse line="1119" />
</Folding>
</File>
<File name="src/include/segment.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="210" topLine="0" />
</Cursor>
</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/include/circuit.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1291" topLine="57" />
</Cursor>
</File>
<File name="src/include/menus.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="251" topLine="0" />
</Cursor>
</File>
<File name="src/include/cars.h" open="0" top="0" tabpos="4" 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="332" 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">
<Cursor>
<Cursor1 position="306" topLine="0" />
</Cursor>
</File>
<File name="src/include/circuit.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1395" topLine="48" />
<Cursor1 position="221" 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">
@ -90,36 +89,44 @@
<Cursor1 position="370" topLine="0" />
</Cursor>
</File>
<File name="src/main.cc" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/cars.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="13233" topLine="418" />
<Cursor1 position="332" topLine="0" />
</Cursor>
<Folding>
<Collapse line="275" />
</Folding>
</File>
<File name="src/include/menus.h" open="0" top="0" tabpos="10" 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="251" topLine="0" />
</Cursor>
</File>
<File name="src/src/circuit.cc" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/drawstuff.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="959" topLine="0" />
<Cursor1 position="622" topLine="0" />
</Cursor>
</File>
<File name="CMakeLists.txt" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2715" topLine="65" />
</Cursor>
<Folding>
<Collapse line="433" />
<Collapse line="501" />
<Collapse line="517" />
<Collapse line="543" />
<Collapse line="588" />
<Collapse line="634" />
<Collapse line="1097" />
</Folding>
</File>
<File name="src/src/segment.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<Cursor>
<Cursor1 position="230" topLine="30" />
</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">
<Cursor>
<Cursor1 position="203" topLine="0" />
</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">
<Cursor>
<Cursor1 position="1019" topLine="8" />
</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">
<Cursor>
<Cursor1 position="306" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -63,7 +63,7 @@ void initData( void );
void createCircuit( int circuitNumber );
void putBillBoards( void );
void createClouds( void );
void createTraffic( void );
void createTraffic( uint16_t maxSegment );
void projectCircuitFP( void );
void projectCircuitFP( uint16_t index );
@ -76,7 +76,7 @@ void printCircuit( int i );
void drawCircuitSegment( uint16_t index );
void drawDecoration( uint16_t index );
void drawTraffic( uint16_t index );
void drawClouds( int offset );
void drawClouds( void );
void drawFarBackground( int offset, int currentbiome );
void drawNearBackground( int offset, int currentbiome );

View File

@ -38,6 +38,7 @@ class Segment
int8_t Environment = PLAINS;
int8_t Special = 0;
bool CheckValidated = false;
int8_t Curve=0;
int8_t Slope=0;

View File

@ -1,5 +1,6 @@
#include <gint/display.h>
#include <gint/drivers/r61524.h>
#include <gint/rtc.h>
#include <gint/keyboard.h>
#include <gint/gint.h>
@ -25,21 +26,12 @@
#include "include/menus.h"
//extern bopti_image_t car1, car2, car3, car4, car5, car6, car7, car8;
//extern bopti_image_t tree1, tree2, tree3, tree4, tree5, tree6;
//extern bopti_image_t leftturn, rightturn, uphill, downhill;
//extern bopti_image_t checkpoint, startlights, stoplights, waitlights;
extern bopti_image_t player;
//extern bopti_image_t sky1, sky2, sky3;
//extern bopti_image_t mountain, treeline;
//extern bopti_image_t mainscreen;
extern font_t speedfont;
extern bopti_image_t speedhud;
int CurrentCircuitBiome = PLAINS;
std::vector<Segment*> circuit;
std::vector<Clouds*> nuages;
std::vector<Cars*> traffic;
@ -64,6 +56,7 @@ bool BDrawRoad = true;
uint16_t currentcurve=0;
uint8_t shiftcolor=0;
float speed = 0.0;
float maxspeedforward = 5.0;
float maxspeedbackward = 2.0;
@ -98,17 +91,29 @@ static void get_inputs( float dt, int index )
if (CC<0)
{
viewside=-1;
cam->decX( CC*dt*speed/100 );
//cam->decX( CC*dt*speed/100 );
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
}
else if (CC>0)
{
viewside=+1;
cam->decX( CC*dt*speed/100 );
//cam->decX( CC*dt*speed/100 );
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(keydown(KEY_LEFT))
{
cam->decX(25.0);
//cam->decX(25.0);
cam->decX(5.0*speed*direction);
viewside=-1;
if (CC<0) viewside=-2; // We are in a curve and turning
if (CC>0) viewside=0;
@ -116,13 +121,15 @@ static void get_inputs( float dt, int index )
if(keydown(KEY_RIGHT))
{
cam->incX(25.0);
//cam->incX(25.0);
cam->incX(5.0*speed*direction);
viewside=1;
if (CC>0) viewside=+2;
if (CC<0) viewside=0;
}
if(keydown(KEY_SHIFT))
if(keydown(KEY_SHIFT)) // Accelerates
{
if (direction==-1 && speed > 0)
{
@ -142,7 +149,7 @@ static void get_inputs( float dt, int index )
speedcontrol = true;
}
if(keydown(KEY_ALPHA))
if(keydown(KEY_ALPHA)) // breaks or rear if speed <0
{
if (direction==1 && speed > 0)
{
@ -202,7 +209,7 @@ static void get_inputs( float dt, int index )
if (speedcontrol==false)
{
speed-=0.3;
speed-=0.1;
if (speed<0) speed=0;
if (direction==1)
@ -227,12 +234,12 @@ static void get_inputs( float dt, int index )
if (fround(cam->cX)<-1.35*ROAD_WIDTH && speed>0.0)
{
speed=0.0;
cam->cX=fix(-0.75*ROAD_WIDTH);
cam->cX=fix(-0.0*ROAD_WIDTH); //set the car in the center of the road (was formerly -0.75)
}
if (fround(cam->cX)>1.35*ROAD_WIDTH && speed>0.0)
{
speed=0.0;
cam->cX=fix(0.75*ROAD_WIDTH);
cam->cX=fix(0.0*ROAD_WIDTH); //set the car in the center of the road (was formerly 0.75)
}
}
@ -248,7 +255,7 @@ int main(void)
#endif
srand( rtc_ticks() );
prof_init();
@ -264,7 +271,7 @@ int main(void)
int32_t start_time = 99000000;
uint32_t score=99999;
uint8_t stage=0;
uint8_t selectedCircuit=0;
int8_t selectedCircuit=0;
uint32_t time_update=0, time_create=0, time_project=0, time_render=0;
@ -327,10 +334,14 @@ int main(void)
initData( ); // Positioning of the Camera
createCircuit( selectedCircuit ); // Creates the circuit
MAX_SEGMENT = circuit.size();
uint32_t maxDistance = (MAX_SEGMENT-nbInterestingSegments-5)*SEGMENT_LENGTH;
putBillBoards();
createClouds(); // Creates the Sky and Clouds
createTraffic(); // Creates the cars
createTraffic( MAX_SEGMENT ); // Creates the cars
prepareDecoration( CurrentCircuitBiome ); // Prepares the multiple variations of Decoration (image scaling)
prepareTraffic(); // Prepares the multiple variations of Cars (image scaling)
@ -338,14 +349,14 @@ int main(void)
time_create = prof_time(perf_create);
//--------------
MAX_SEGMENT = circuit.size();
int indexstart = 0;
int indexend = 0;
uint32_t maxDistance = (MAX_SEGMENT-nbInterestingSegments-5)*SEGMENT_LENGTH;
uint32_t dt=0;
float dt=0;
uint16_t l=0;
uint32_t remaining_time;
@ -387,7 +398,7 @@ int main(void)
{
updateTraffic( dt, maxDistance );
for (int k=0; k<traffic.size(); k++) // Need to project 1 more segment than actual drawing
for (unsigned int k=0; k<traffic.size(); k++) // Need to project 1 more segment than actual drawing
{
uint16_t CarSegment = traffic[k]->wZ / SEGMENT_LENGTH;
if (CarSegment>=indexstart && CarSegment<indexend)
@ -406,7 +417,7 @@ int main(void)
// Update car positions : car with higher speed change line not to collide with player
if (BDrawCars)
for( int l=0; l<circuit[indexstart]->CarList.size(); l++ ) // For all cars inside that road segment
for(unsigned int l=0; l<circuit[indexstart]->CarList.size(); l++ ) // For all cars inside that road segment
{
uint8_t indexCar = circuit[indexstart]->CarList[l];
@ -419,11 +430,11 @@ int main(void)
if (BDrawCars)
for( int l=0; l<circuit[indexstart+1]->CarList.size(); l++ ) // For all cars inside that road segment
for( unsigned int l=0; l<circuit[indexstart+1]->CarList.size(); l++ ) // For all cars inside that road segment
{
uint8_t indexCar = circuit[indexstart+1]->CarList[l];
if (traffic[indexCar]->wX>(roadpart-0.15f) && traffic[indexCar]->wX<(roadpart+0.15f) && traffic[indexCar]->Speed<speed)
if (traffic[indexCar]->wX>(roadpart-0.20f) && traffic[indexCar]->wX<(roadpart+0.20f) && traffic[indexCar]->Speed<speed)
{
speed = 2.0;
}
@ -442,7 +453,7 @@ int main(void)
cumulCurve += circuit[k]->Curve;
if (BDrawCars)
for( int l=0; l<circuit[k]->CarList.size(); l++ ) // For all cars inside that road segment
for( unsigned int l=0; l<circuit[k]->CarList.size(); l++ ) // For all cars inside that road segment
{
uint8_t indexCar = circuit[k]->CarList[l];
traffic[indexCar]->Project3DFP( cam, k );
@ -462,7 +473,7 @@ int main(void)
drawSky( DAY_BLUE_SKY );
if (BDrawClds)
drawClouds( l % 396 );
drawClouds( );
drawFarBackground( deltaFarbackground, CurrentCircuitBiome );
drawNearBackground( deltaNearbackground, CurrentCircuitBiome );
@ -480,7 +491,7 @@ int main(void)
drawDecoration( k );
if (BDrawCars)
for( int l=0; l<circuit[k]->CarList.size(); l++ ) // For all cars inside that road segment
for( unsigned int l=0; l<circuit[k]->CarList.size(); l++ ) // For all cars inside that road segment
{
uint8_t indexCar = circuit[k]->CarList[l];
drawTraffic( indexCar );
@ -489,6 +500,11 @@ int main(void)
circuit[k]->CarList.clear();
}
if (circuit[indexstart]->Special == CHECKPOINT && circuit[indexstart]->CheckValidated == false)
{
start_time+=60000000;
circuit[indexstart]->CheckValidated = true;
}
int mod_base=20;
int mod_comp=10;
@ -532,6 +548,7 @@ int main(void)
dsubimage( 245, 5, &speedhud, 37, 117, 38, 13, DIMAGE_NONE); // speed logo
dsubimage( 245, 25, &speedhud, 37, 130, 38, 13, DIMAGE_NONE); // timer logo
dsubimage( 5, 205, &speedhud, 0, 143, 27, 13, DIMAGE_NONE); // fps logo
dfont(&speedfont);
if (drawspeed==0.0)
@ -567,6 +584,13 @@ int main(void)
//dupdate();
//dprint( 3, 202, C_BLACK, "%.0f", dt );
//dprint( 1, 200, C_WHITE, "%.0f", dt );
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"
dprint_opt(40,200, C_RGB(255,255,0), C_NONE, DTEXT_LEFT, DTEXT_TOP, "%.0f <", (float) (1000.0f/dt) );
r61524_display(gint_vram, 0, DHEIGHT, R61524_DMA_WAIT);

View File

@ -19,7 +19,7 @@
#define NB_CLOUDS_SKY 10
#define NB_CARS_TRAFFIC 100
#define NB_CARS_TRAFFIC 200
#define MAX_SUBIMAGES_TREES 12
#define NB_TREES_TYPES 15

View File

@ -32,7 +32,7 @@ extern bopti_image_t cc_void, us_bigleaf, us_smallleaf, cc_bigleaf, cc_smallleaf
extern bopti_image_t sky1, sky2, sky3;
extern bopti_image_t mountain, canyon, snowmount, kilimandjaro;
extern bopti_image_t treeline, rockline;
extern bopti_image_t treeline, rockline, treelinesnow;
extern bopti_image_t leftturn, rightturn, uphill, downhill;
extern bopti_image_t checkpoint, startlights, stoplights, waitlights;
@ -514,17 +514,15 @@ void createClouds( void )
}
void createTraffic( void )
void createTraffic( uint16_t maxSegment )
{
srand( rtc_ticks() );
for( int k = 0; k < NB_CARS_TRAFFIC; k++)
{
int8_t X = rand() % 4;
//double Z = (double) (rand() % 4000);
double Z = (double) (SEGMENT_LENGTH * (rand() % (maxSegment-5)) + 10.0);
//int8_t X = 0;
double Z = (k+1)*SEGMENT_LENGTH;
uint8_t S = 4 + (rand() % 2);
//double Z = (k+1)*SEGMENT_LENGTH;
uint8_t S = 2 + (rand() % 3);
uint8_t T = rand() % 8;
Cars* car;
@ -540,6 +538,17 @@ void createTraffic( void )
}
}
inline int getRandom( int8_t biome )
{
//Needed to generate integer between -1 and +6;
int a = (rand() % 15)-8;
if (a<0) a=-1; // we clamp a to above -1;
return a;
}
void addCheckPoint( int8_t biome )
{
double lastZ=0;
@ -690,22 +699,20 @@ void addStraightLine( Length l, int8_t biome )
lastZ=circuit[lastIndex-1]->wZ+SEGMENT_LENGTH;
}
srand( rtc_ticks() );
for( int i=0; i<l; i++)
{
//Segment *s=new Segment( i );
int deco = rand() % 8;
Segment *seg;
Segment *seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, getRandom( biome ), getRandom( biome ) );
if (deco==0) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, TREE1, -1 );
else if (deco==1) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, -1, TREE2 );
else if (deco==2) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, TREE3, LEAF1 );
else if (deco==3) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, LEAF2, TREE1 );
else if (deco==4) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, TREE4, TREE2 );
else if (deco==5) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, ROCKS, -1 );
else if (deco==6) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, TREE2, TREE1 );
else if (deco==7) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, TREE3, TREE4 );
// int deco = rand() % 8;
// Segment *seg;
// if (deco==0) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, TREE1, -1 );
// else if (deco==1) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, -1, TREE2 );
// else if (deco==2) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, TREE3, LEAF1 );
// else if (deco==3) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, LEAF2, TREE1 );
// else if (deco==4) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, TREE4, TREE2 );
// else if (deco==5) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, ROCKS, -1 );
// else if (deco==6) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, TREE2, TREE1 );
// else if (deco==7) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, TREE3, TREE4 );
if (seg!=nullptr)
{
@ -727,23 +734,22 @@ void addCurve( Length l, CurveStrength s, CurveType t, int8_t biome )
lastZ=circuit[lastIndex-1]->wZ+SEGMENT_LENGTH;
}
srand( rtc_ticks() );
for( int i=0; i<l; i++)
{
//Segment *s=new Segment( i );
int deco = rand() % 8;
Segment *seg;
if (deco==0) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, -1, -1 );
else if (deco==1) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, -1, TREE1 );
else if (deco==2) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, TREE2, ROCKS );
else if (deco==3) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, TREE3, LEAF1 );
else if (deco==4) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, -1, -1 );
else if (deco==5) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, TREE3, -1 );
else if (deco==6) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, TREE4, LEAF1 );
else if (deco==7) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, -1, LEAF2 );
Segment *seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, getRandom( biome ), getRandom( biome ) );
// int deco = rand() % 8;
// if (deco==0) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, -1, -1 );
// else if (deco==1) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, -1, TREE1 );
// else if (deco==2) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, TREE2, ROCKS );
// else if (deco==3) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, TREE3, LEAF1 );
// else if (deco==4) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, -1, -1 );
// else if (deco==5) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, TREE3, -1 );
// else if (deco==6) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, TREE4, LEAF1 );
// else if (deco==7) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, 0, -1, LEAF2 );
if (seg!=nullptr)
{
@ -766,22 +772,21 @@ void addHill( Length l, HillSize s, HillType t, int8_t biome )
lastZ=circuit[lastIndex-1]->wZ+SEGMENT_LENGTH;
}
srand( rtc_ticks() );
for( int i=0; i<l; i++)
{
//Segment *s=new Segment( i );
int deco = rand() % 8;
Segment *seg;
if (deco==0) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, -1, ROCKS );
else if (deco==1) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, -1, TREE2 );
else if (deco==2) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, TREE3, -1 );
else if (deco==3) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, TREE1, LEAF2 );
else if (deco==4) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, ROCKS, LEAF1 );
else if (deco==5) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, TREE1, -1 );
else if (deco==6) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, TREE3, TREE1 );
else if (deco==7) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, TREE2, TREE4 );
Segment *seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, getRandom( biome ), getRandom( biome ) );
// int deco = rand() % 8;
// Segment *seg;
// if (deco==0) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, -1, ROCKS );
// else if (deco==1) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, -1, TREE2 );
// else if (deco==2) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, TREE3, -1 );
// else if (deco==3) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, TREE1, LEAF2 );
// else if (deco==4) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, ROCKS, LEAF1 );
// else if (deco==5) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, TREE1, -1 );
// else if (deco==6) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, TREE3, TREE1 );
// else if (deco==7) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, s*t, TREE2, TREE4 );
if (seg!=nullptr)
{
@ -804,22 +809,21 @@ void addCurvyHill( Length l, HillSize s, HillType t, CurveStrength cs, CurveType
lastZ=circuit[lastIndex-1]->wZ+SEGMENT_LENGTH;
}
srand( rtc_ticks() );
for( int i=0; i<l; i++)
{
//Segment *s=new Segment( i );
int deco = rand() % 8;
Segment *seg;
Segment *seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, getRandom( biome ), getRandom( biome ) );
if (deco==0) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, -1, -1 );
else if (deco==1) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, -1, TREE1 );
else if (deco==2) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, TREE2, -1 );
else if (deco==3) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, TREE3, LEAF2 );
else if (deco==4) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, ROCKS, LEAF2 );
else if (deco==5) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, TREE1, TREE2 );
else if (deco==6) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, TREE3, LEAF2 );
else if (deco==7) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, -1, TREE4 );
// int deco = rand() % 8;
// Segment *seg;
// if (deco==0) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, -1, -1 );
// else if (deco==1) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, -1, TREE1 );
// else if (deco==2) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, TREE2, -1 );
// else if (deco==3) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, TREE3, LEAF2 );
// else if (deco==4) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, ROCKS, LEAF2 );
// else if (deco==5) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, TREE1, TREE2 );
// else if (deco==6) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, TREE3, LEAF2 );
// else if (deco==7) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, cs*ct, s*t, -1, TREE4 );
if (seg!=nullptr)
@ -1269,15 +1273,17 @@ void drawTraffic( uint16_t index )
int X = traffic[index]->X - image->width/2;
int Y = traffic[index]->Y - image->height;
dimage( X, Y, image );
//dimage( X, Y, image );
if (distance!=0) dimage( X, Y, image );
}
void drawClouds( int offset )
void drawClouds( void )
{
bopti_image_t *cloud;
for( int k =0; k<nuages.size(); k++ )
for( unsigned int k =0; k<nuages.size(); k++ )
{
if (nuages[k]->Type==0) cloud=&sky1;
else if (nuages[k]->Type==1) cloud=&sky2;
@ -1302,6 +1308,7 @@ void drawFarBackground( int offset, int currentbiome )
else if (currentbiome==USA) image=&canyon;
else if (currentbiome==FINLAND) image=&snowmount;
else if (currentbiome==AFRICA) image=&kilimandjaro;
else image=&mountain;
int X = offset;
int DX = image->width;
@ -1327,9 +1334,9 @@ void drawNearBackground( int offset, int currentbiome )
if (currentbiome==PLAINS) image=&treeline;
else if (currentbiome==DESERT) image=&rockline;
else if (currentbiome==USA) image=&rockline;
else if (currentbiome==FINLAND) image=&cc_void;
else if (currentbiome==FINLAND) image=&treelinesnow;
else if (currentbiome==AFRICA) image=&cc_void;
else image=&treeline;
int X = offset;
int DX = image->width;

View File

@ -1,6 +1,10 @@
#include "../include/menus.h"
#include <gint/display.h>
#include <gint/keyboard.h>
#include "../parameters.h"
#include <gint/usb.h>
#include <gint/usb-ff-bulk.h>
extern bopti_image_t mainscreen;
@ -8,6 +12,9 @@ extern bopti_image_t africa1, desert1, finland1, plains1, usa1;
extern bopti_image_t flag, linear, circular;
extern font_t autofont, autofontsmall;
extern bool record;
extern bool screenshot;
bool doneTitle = false;
@ -15,7 +22,7 @@ bool doneMainMenu = false;
uint8_t MainMenuSelection=0;
bool doneMenuCircuit = false;
uint8_t CircuitSelection=0;
int8_t CircuitSelection=0;
bool doneMenuCredit = false;
@ -44,6 +51,19 @@ void drawStartTitle( void )
pulse++;
getInputStartTitle();
#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
}
}
@ -55,12 +75,18 @@ void getInputStartTitle( void )
while(1)
{
key_event_t ev = getkey_opt(opt, &timeout);
if(ev.type == KEYEV_NONE) return -1;
if(ev.type == KEYEV_NONE) return;
int key = ev.key;
if (key==KEY_EXE)
doneTitle = true;
#if IS_FXLIB==1
if(keydown(KEY_F5)) screenshot = true;
if(keydown(KEY_F6)) record = !record;
#endif // IS_FXLIB
}
}
@ -110,6 +136,19 @@ int drawMainMenu( void )
pulse++;
getInputMainMenu();
#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
}
return MainMenuSelection;
@ -123,7 +162,7 @@ void getInputMainMenu( void )
while(1)
{
key_event_t ev = getkey_opt(opt, &timeout);
if(ev.type == KEYEV_NONE) return -1;
if(ev.type == KEYEV_NONE) return;
int key = ev.key;
@ -141,6 +180,10 @@ void getInputMainMenu( void )
if (MainMenuSelection==4) MainMenuSelection=0;
else MainMenuSelection++;
}
#if IS_FXLIB==1
if(keydown(KEY_F5)) screenshot = true;
if(keydown(KEY_F6)) record = !record;
#endif // IS_FXLIB
}
}
@ -277,6 +320,19 @@ int drawMenuCircuitSelect( void )
pulse++;
getInputCircuitSelect();
#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
if (CircuitSelection==-1) return -1;
}
@ -291,7 +347,7 @@ void getInputCircuitSelect( void )
while(1)
{
key_event_t ev = getkey_opt(opt, &timeout);
if(ev.type == KEYEV_NONE) return -1;
if(ev.type == KEYEV_NONE) return;
int key = ev.key;
@ -313,6 +369,11 @@ void getInputCircuitSelect( void )
if (CircuitSelection==9) CircuitSelection=0;
else CircuitSelection++;
}
#if IS_FXLIB==1
if(keydown(KEY_F5)) screenshot = true;
if(keydown(KEY_F6)) record = !record;
#endif // IS_FXLIB
}
}
@ -370,6 +431,19 @@ void drawCredit( void )
dupdate();
#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
pulse++;
offset--;
getInputCredit();
@ -386,12 +460,17 @@ void getInputCredit( void )
while(1)
{
key_event_t ev = getkey_opt(opt, &timeout);
if(ev.type == KEYEV_NONE) return -1;
if(ev.type == KEYEV_NONE) return;
int key = ev.key;
if (key==KEY_EXE)
doneMenuCredit = true;
#if IS_FXLIB==1
if(keydown(KEY_F5)) screenshot = true;
if(keydown(KEY_F6)) record = !record;
#endif // IS_FXLIB
}
}