first interactions with road cars
This commit is contained in:
parent
08f8d69c05
commit
ff166b9151
|
@ -46,6 +46,9 @@ set(ASSETS_cg
|
|||
assets-cg/billboard/uphill.png
|
||||
assets-cg/billboard/downhill.png
|
||||
assets-cg/billboard/checkpoint.png
|
||||
assets-cg/billboard/startlights.png
|
||||
assets-cg/billboard/stoplights.png
|
||||
assets-cg/billboard/waitlights.png
|
||||
assets-cg/fonts/speedfont.png
|
||||
assets-cg/fonts/auto15.png
|
||||
assets-cg/fonts/auto20.png
|
||||
|
|
|
@ -20,16 +20,16 @@ class Cars
|
|||
|
||||
int16_t X;
|
||||
int16_t Y;
|
||||
uint8_t S;
|
||||
//uint8_t S;
|
||||
|
||||
uint8_t Speed;
|
||||
uint8_t Type;
|
||||
|
||||
uint8_t DScale;
|
||||
//uint8_t DScale;
|
||||
|
||||
// for debugging only
|
||||
bool visible;
|
||||
uint16_t segnum;
|
||||
//bool visible;
|
||||
//uint16_t segnum;
|
||||
};
|
||||
|
||||
#endif // CARS_H
|
||||
|
|
|
@ -3,11 +3,11 @@
|
|||
|
||||
enum Length
|
||||
{
|
||||
L_VERYSHORT = 50,
|
||||
L_SHORT = 100,
|
||||
L_MEDIUM = 200,
|
||||
L_LONG = 400,
|
||||
L_VERYLONG = 1000
|
||||
L_VERYSHORT = 25,
|
||||
L_SHORT = 50,
|
||||
L_MEDIUM = 100,
|
||||
L_LONG = 200,
|
||||
L_VERYLONG = 400
|
||||
};
|
||||
|
||||
enum HillSize
|
||||
|
@ -52,7 +52,10 @@ enum Decoration
|
|||
RIGHTTURN = 7,
|
||||
UPHILL = 8,
|
||||
DOWNHILL = 9,
|
||||
CHECK = 10
|
||||
CHECK = 10,
|
||||
STARTLIGHT = 11,
|
||||
STOPLIGHT = 12,
|
||||
WAITLIGHT = 13
|
||||
};
|
||||
|
||||
void initData( void );
|
||||
|
@ -64,7 +67,7 @@ void createTraffic( void );
|
|||
void projectCircuitFP( void );
|
||||
void projectCircuitFP( uint16_t index );
|
||||
|
||||
void updateTraffic( float dt );
|
||||
void updateTraffic( float dt, uint32_t maxdistance );
|
||||
|
||||
void printCircuit( void );
|
||||
void printCircuit( int i );
|
||||
|
@ -83,6 +86,8 @@ void freeTraffic( void );
|
|||
void prepareTraffic( void );
|
||||
|
||||
void addCheckPoint( int8_t biome );
|
||||
void addStartLine( int8_t biome );
|
||||
void addFinishLine( int8_t biome );
|
||||
void addStraightLine( Length l, int8_t biome );
|
||||
void addCurve( Length l, CurveStrength s, CurveType t, int8_t biome );
|
||||
void addHill( Length l, HillSize s, HillType t, int8_t biome );
|
||||
|
|
|
@ -53,7 +53,7 @@ class Segment
|
|||
// Decorations on the Road (Left and Right)
|
||||
int8_t LDeco=-1;
|
||||
int8_t RDeco=-1;
|
||||
int8_t DScale=0;
|
||||
//int8_t DScale=0;
|
||||
|
||||
std::vector <uint8_t> CarList;
|
||||
};
|
||||
|
|
535
src/main.cc
535
src/main.cc
|
@ -27,7 +27,8 @@
|
|||
|
||||
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, checkpoint;
|
||||
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;
|
||||
|
@ -102,7 +103,6 @@ static void get_inputs( float dt, int index )
|
|||
cam->decX( CC*dt*speed/100 );
|
||||
}
|
||||
|
||||
|
||||
if(keydown(KEY_LEFT))
|
||||
{
|
||||
cam->decX(25.0);
|
||||
|
@ -138,6 +138,7 @@ static void get_inputs( float dt, int index )
|
|||
|
||||
speedcontrol = true;
|
||||
}
|
||||
|
||||
if(keydown(KEY_ALPHA))
|
||||
{
|
||||
if (direction==1 && speed > 0)
|
||||
|
@ -158,10 +159,6 @@ static void get_inputs( float dt, int index )
|
|||
speedcontrol = true;
|
||||
}
|
||||
|
||||
//if(keydown(KEY_7)) cam->incY(10.0);
|
||||
//if(keydown(KEY_1)) cam->decY(10.0);
|
||||
//if(keydown(KEY_MENU)) gint_osmenu();
|
||||
|
||||
if(keydown(KEY_EXIT)) stop = true;
|
||||
|
||||
#if IS_FXLIB==1
|
||||
|
@ -286,15 +283,15 @@ int main(void)
|
|||
perf_create = prof_make();
|
||||
prof_enter(perf_create);
|
||||
|
||||
initData( ); // Positioning of the Camera
|
||||
createCircuit(); // Creates the circuit
|
||||
initData( ); // Positioning of the Camera
|
||||
createCircuit(); // Creates the circuit
|
||||
|
||||
putBillBoards();
|
||||
putBillBoards();
|
||||
|
||||
createClouds(); // Creates the Sky and Clouds
|
||||
createTraffic(); // Creates the cas
|
||||
prepareDecoration(); // Prepares the multiple variations of Decoration (image scaling)
|
||||
prepareTraffic(); // Prepares the multiple variations of Cars (image scaling)
|
||||
createClouds(); // Creates the Sky and Clouds
|
||||
createTraffic(); // Creates the cas
|
||||
prepareDecoration(); // Prepares the multiple variations of Decoration (image scaling)
|
||||
prepareTraffic(); // Prepares the multiple variations of Cars (image scaling)
|
||||
|
||||
prof_leave(perf_create);
|
||||
time_create = prof_time(perf_create);
|
||||
|
@ -305,7 +302,7 @@ int main(void)
|
|||
int indexstart = 0;
|
||||
int indexend = 0;
|
||||
|
||||
uint32_t maxDistance = (MAX_SEGMENT-nbInterestingSegments-1)*SEGMENT_LENGTH;
|
||||
uint32_t maxDistance = (MAX_SEGMENT-nbInterestingSegments-5)*SEGMENT_LENGTH;
|
||||
|
||||
uint32_t dt=0;
|
||||
uint16_t l=0;
|
||||
|
@ -317,23 +314,23 @@ int main(void)
|
|||
perf_update = prof_make();
|
||||
prof_enter(perf_update);
|
||||
|
||||
get_inputs( dt, indexstart );
|
||||
get_inputs( dt, indexstart );
|
||||
|
||||
dt = ((float) (time_update+time_render+time_project) / 1000.0);
|
||||
dt = ((float) (time_update+time_render+time_project) / 1000.0);
|
||||
|
||||
start_time -= (time_update+time_render+time_project);
|
||||
if (start_time<0) start_time=0;
|
||||
remaining_time = ((float) (start_time) / 1000000.0);
|
||||
start_time -= (time_update+time_render+time_project);
|
||||
if (start_time<0) start_time=0;
|
||||
remaining_time = ((float) (start_time) / 1000000.0);
|
||||
|
||||
//--------------
|
||||
if (fround(cam->cZ)<=0) cam->cZ=fixdouble(0.0);
|
||||
if (fround(cam->cZ)>=maxDistance) cam->cZ=fixdouble(maxDistance);
|
||||
//--------------
|
||||
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;
|
||||
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;
|
||||
indexend = indexstart+nbInterestingSegments+1;
|
||||
if (indexstart>MAX_SEGMENT-nbInterestingSegments-2) indexstart=MAX_SEGMENT-nbInterestingSegments-2;
|
||||
|
||||
|
||||
prof_leave(perf_update);
|
||||
|
@ -345,43 +342,75 @@ int main(void)
|
|||
prof_enter(perf_project);
|
||||
|
||||
|
||||
if (BDrawCars)
|
||||
{
|
||||
updateTraffic( dt );
|
||||
if (BDrawCars)
|
||||
{
|
||||
updateTraffic( dt, maxDistance );
|
||||
|
||||
for (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)
|
||||
{
|
||||
traffic[k]->visible = true;
|
||||
circuit[CarSegment]->CarList.push_back(k);
|
||||
}
|
||||
else
|
||||
traffic[k]->visible = false;
|
||||
}
|
||||
}
|
||||
for (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)
|
||||
{
|
||||
//traffic[k]->visible = true;
|
||||
circuit[CarSegment]->CarList.push_back(k);
|
||||
}
|
||||
//else
|
||||
//traffic[k]->visible = false;
|
||||
}
|
||||
}
|
||||
|
||||
minYRoad = SCREEN_HEIGHT;
|
||||
minYRoad = SCREEN_HEIGHT;
|
||||
|
||||
float roadpart = f2float(cam->cX)/(float) ROAD_WIDTH;
|
||||
|
||||
// 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
|
||||
{
|
||||
uint8_t indexCar = circuit[indexstart]->CarList[l];
|
||||
|
||||
if (traffic[indexCar]->wX>(roadpart-0.25f) && traffic[indexCar]->wX<(roadpart+0.25f) && traffic[indexCar]->Speed>speed)
|
||||
{
|
||||
if (traffic[indexCar]->wX>-0.25) traffic[indexCar]->wX-=0.5; // if we are on one of the most right lanes, we overtake by the left
|
||||
else traffic[indexCar]->wX=-0.25; // else we change to the lane on the right
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (BDrawCars)
|
||||
for( 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)
|
||||
{
|
||||
speed = 2.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint16_t cumulCurve=0;
|
||||
for (int k=indexstart; k<=indexend; k++) // Need to project 1 more segment than actual drawing
|
||||
{
|
||||
projectCircuitFP( k ); // We project the current segment
|
||||
|
||||
if (circuit[k]->Y < minYRoad) // This is a trick to save precious time while drawing the Sky
|
||||
minYRoad = circuit[k]->Y;
|
||||
|
||||
circuit[k]->CumulatedCurve = cumulCurve; // This is the curve accumulated when we are drawing curves
|
||||
cumulCurve += circuit[k]->Curve;
|
||||
|
||||
if (BDrawCars)
|
||||
for( 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 );
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t cumulCurve=0;
|
||||
for (int k=indexstart; k<=indexend; k++) // Need to project 1 more segment than actual drawing
|
||||
{
|
||||
projectCircuitFP( k ); // We project the current segment
|
||||
|
||||
if (circuit[k]->Y < minYRoad) // This is a trick to save precious time while drawing the Sky
|
||||
minYRoad = circuit[k]->Y;
|
||||
|
||||
circuit[k]->CumulatedCurve = cumulCurve; // This is the curve accumulated when we are drawing curves
|
||||
cumulCurve += circuit[k]->Curve;
|
||||
|
||||
if (BDrawCars)
|
||||
for( 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 );
|
||||
}
|
||||
}
|
||||
|
||||
prof_leave(perf_project);
|
||||
time_project = prof_time(perf_project);
|
||||
|
@ -392,221 +421,221 @@ int main(void)
|
|||
prof_enter(perf_render);
|
||||
|
||||
|
||||
drawSky( DAY_BLUE_SKY );
|
||||
drawSky( DAY_BLUE_SKY );
|
||||
|
||||
if (BDrawClds)
|
||||
drawClouds( l % 396 );
|
||||
|
||||
drawFarBackground( deltaFarbackground );
|
||||
drawNearBackground( deltaNearbackground );
|
||||
|
||||
cam->cY = fix( 300+2*CS ) + interpolatePositionY(fround(cam->cZ) );
|
||||
|
||||
for( int k=indexend-1; k>=indexstart; k--)
|
||||
{
|
||||
currentcurve = circuit[k]->CumulatedCurve;
|
||||
|
||||
if (BDrawRoad)
|
||||
drawCircuitSegment( k );
|
||||
|
||||
if (BDrawDeco)
|
||||
drawDecoration( k );
|
||||
|
||||
if (BDrawCars)
|
||||
for( 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 );
|
||||
}
|
||||
|
||||
circuit[k]->CarList.clear();
|
||||
}
|
||||
|
||||
|
||||
int mod_base=20;
|
||||
int mod_comp=10;
|
||||
|
||||
|
||||
if (abs(speed)<1.0) mod_base = 30, mod_comp = 15;
|
||||
else if (abs(speed)<2.0) mod_base = 20, mod_comp = 10;
|
||||
else if (abs(speed)<3.0) mod_base = 16, mod_comp = 8;
|
||||
else if (abs(speed)<4.0) mod_base = 12, mod_comp = 6;
|
||||
else if (abs(speed)<5.0) mod_base = 8, mod_comp = 4;
|
||||
else mod_base = 4, mod_comp = 2;
|
||||
|
||||
|
||||
if ((speed==0) || (l%mod_base<=mod_comp)) // the small rick to have the speed impression on wheels and to have the correct view of the car during turns
|
||||
{
|
||||
if (viewside==-2) dsubimage( SCREEN_CX-40, SCREEN_HEIGHT-46, &player, 99,1,80,46, DIMAGE_NONE);
|
||||
else if (viewside==-1) dsubimage( SCREEN_CX-37, SCREEN_HEIGHT-46, &player, 181,1,74,46, DIMAGE_NONE);
|
||||
else if (viewside==0) dsubimage( SCREEN_CX-36, SCREEN_HEIGHT-46, &player, 257,1,72,46, DIMAGE_NONE);
|
||||
else if (viewside==1) dsubimage( SCREEN_CX-37, SCREEN_HEIGHT-46, &player, 331,1,74,46, DIMAGE_NONE);
|
||||
else if (viewside==2) dsubimage( SCREEN_CX-40, SCREEN_HEIGHT-46, &player, 407,1,80,46, DIMAGE_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (viewside==-2) dsubimage( SCREEN_CX-40, SCREEN_HEIGHT-46, &player, 99,49,80,46, DIMAGE_NONE);
|
||||
else if (viewside==-1) dsubimage( SCREEN_CX-37, SCREEN_HEIGHT-46, &player, 181,49,74,46, DIMAGE_NONE);
|
||||
else if (viewside==0) dsubimage( SCREEN_CX-36, SCREEN_HEIGHT-46, &player, 257,49,72,46, DIMAGE_NONE);
|
||||
else if (viewside==1) dsubimage( SCREEN_CX-37, SCREEN_HEIGHT-46, &player, 331,49,74,46, DIMAGE_NONE);
|
||||
else if (viewside==2) dsubimage( SCREEN_CX-40, SCREEN_HEIGHT-46, &player, 407,49,80,46, DIMAGE_NONE);
|
||||
}
|
||||
|
||||
|
||||
score = fround(cam->cZ)/100;
|
||||
|
||||
|
||||
//dprint( 1, 1, C_BLACK, "Crt=%.3D ms", time_create );
|
||||
|
||||
//dprint( 1, 15, C_RED, "Prj=%.3D ms", time_project );
|
||||
//dprint( 1, 30, C_RED, "Rdr=%.3D ms", time_render );
|
||||
//dprint( 1, 45, C_RED, "Upd=%.3D ms", time_update );
|
||||
|
||||
//dprint( 1, 1, C_BLACK, "Dt=%.3D ms", dt );
|
||||
|
||||
|
||||
float drawspeed = (float) (speed*5.0f);
|
||||
|
||||
|
||||
dsubimage( 5, 5, &speedhud, 0, 117, 37, 13, DIMAGE_NONE); // speed logo
|
||||
dsubimage( 135, 5, &speedhud, 0, 130, 37, 13, DIMAGE_NONE); // timer logo
|
||||
|
||||
dsubimage( 245, 5, &speedhud, 37, 117, 38, 13, DIMAGE_NONE); // speed logo
|
||||
dsubimage( 245, 25, &speedhud, 37, 130, 38, 13, DIMAGE_NONE); // timer logo
|
||||
|
||||
|
||||
dfont(&speedfont);
|
||||
if (drawspeed==0.0)
|
||||
{
|
||||
dprint_opt(122,3, C_RGB(0,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "0 :", drawspeed );
|
||||
dprint_opt(120,1, C_RGB(255,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "0 :", drawspeed );
|
||||
}
|
||||
else
|
||||
{
|
||||
dprint_opt(122,3, C_RGB(0,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.1f :", drawspeed );
|
||||
dprint_opt(120,1, C_RGB(255,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.1f :", drawspeed ); //the ':' char corresponds to "Km/h"
|
||||
}
|
||||
|
||||
dprint_opt(233,3, C_RGB(0,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.3D ;", remaining_time );
|
||||
dprint_opt(230,1, C_RGB(255,255,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.3D ;", remaining_time ); // the ';' char corresponds to "s"
|
||||
|
||||
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"
|
||||
|
||||
|
||||
if (drawspeed==0.0) dsubimage( 48, 25, &speedhud, 0, 0, 76, 13, DIMAGE_NONE);
|
||||
else if (drawspeed<3.30) dsubimage( 48, 25, &speedhud, 0, 13, 76, 13, DIMAGE_NONE);
|
||||
else if (drawspeed<6.70) dsubimage( 48, 25, &speedhud, 0, 26, 76, 13, DIMAGE_NONE);
|
||||
else if (drawspeed<10.0) dsubimage( 48, 25, &speedhud, 0, 39, 76, 13, DIMAGE_NONE);
|
||||
else if (drawspeed<13.3) dsubimage( 48, 25, &speedhud, 0, 52, 76, 13, DIMAGE_NONE);
|
||||
else if (drawspeed<16.7) dsubimage( 48, 25, &speedhud, 0, 65, 76, 13, DIMAGE_NONE);
|
||||
else if (drawspeed<20.0) dsubimage( 48, 25, &speedhud, 0, 78, 76, 13, DIMAGE_NONE);
|
||||
else if (drawspeed<23.3) dsubimage( 48, 25, &speedhud, 0, 91, 76, 13, DIMAGE_NONE);
|
||||
else dsubimage( 48, 25, &speedhud, 0, 104, 76, 13, DIMAGE_NONE);
|
||||
|
||||
//dprint( 1, 1, C_BLACK, "FPS=%.3D ms", 1000/dt );
|
||||
|
||||
/*
|
||||
#if 0
|
||||
dprint( 1, 210, C_WHITE, "Decs: %c", BDrawDeco==true?'Y':'N' ); // Key F1
|
||||
dprint( 67, 210, C_WHITE, "Clds: %c", BDrawClds==true?'Y':'N' ); // Key F2
|
||||
dprint( 133, 210, C_WHITE, "Cars: %c", BDrawCars==true?'Y':'N' ); // Key F3
|
||||
|
||||
dprint( 199, 210, C_WHITE, "DtR: %.1f", ((float) (time_render) / 1000.0) ); // Key F4
|
||||
dprint( 265, 210, C_WHITE, "ScrSht" ); // Key F5
|
||||
dprint( 331, 210, C_WHITE, "RecVid" ); // Key F6
|
||||
#endif // 1
|
||||
|
||||
#if 0
|
||||
if (ShowDebug1)
|
||||
{
|
||||
Segment* currentSeg = circuit[indexstart];
|
||||
|
||||
dprint( 1, 1, C_RED, "Crt=%.3D ms", time_create );
|
||||
dprint( 1, 15, C_RED, "Prj=%.3D ms", time_project );
|
||||
dprint( 1, 29, C_RED, "Rdr=%.3D ms", time_render );
|
||||
|
||||
dprint( 1, 55, C_WHITE, "It=%d", l);
|
||||
dprint( 1, 69, C_GREEN, "St=%d ", indexstart );
|
||||
dprint( 1, 83, C_GREEN, "En=%d", indexend );
|
||||
dprint( 1, 97, C_RED, "Sz= %d", circuit.size() );
|
||||
|
||||
dprint( 100, 55, C_WHITE, "SzSgmt=%d bytes", sizeof(Segment) );
|
||||
dprint( 100, 69, C_WHITE, ">XYZc=(%d,%d,%.0lf,%d)", circuit[indexstart]->wX, circuit[indexstart]->wY, circuit[indexstart]->wZ, circuit[indexstart]->Curve );
|
||||
dprint( 100, 83, C_WHITE, ">XYZc=(%d,%d,%.0lf,%d)", circuit[indexend]->wX, circuit[indexend]->wY, circuit[indexend]->wZ, circuit[indexstart]->Curve );
|
||||
dprint( 100, 97, C_WHITE, "C[i]Adr= %p", ¤tSeg),
|
||||
|
||||
dprint( 320, 1, C_WHITE, "CamX=%d", fround( cam->cX ) );
|
||||
dprint( 320, 15, C_WHITE, "CamY=%d", fround( cam->cY ) );
|
||||
dprint( 320, 29, C_WHITE, "CamZ=%d", fround( cam->cZ ) );
|
||||
|
||||
dprint( 320, 55, C_WHITE, "Dir=%d", direction );
|
||||
dprint( 320, 69, C_WHITE, "Spd=%.1f", speed );
|
||||
dprint( 320, 83, C_WHITE, "Dz =%.1f", speed*dt );
|
||||
dprint( 320, 97, C_WHITE, "dt =%.3D ms", dt );
|
||||
}
|
||||
if (ShowDebug2)
|
||||
{
|
||||
#if 0
|
||||
dprint( 1, 1, C_RED, "Crt=%.3D ms", time_create );
|
||||
dprint( 1, 15, C_RED, "Prj=%.3D ms", time_project );
|
||||
dprint( 1, 29, C_RED, "Rdr=%.3D ms", time_render );
|
||||
dprint( 1, 50, C_BLACK, "ISt_Z=%.1lf", circuit[indexstart]->wZ);
|
||||
dprint( 1, 65, C_BLACK, "IEd_Z=%.1lf", circuit[indexend]->wZ);
|
||||
if (BDrawClds)
|
||||
drawClouds( l % 396 );
|
||||
|
||||
drawFarBackground( deltaFarbackground );
|
||||
drawNearBackground( deltaNearbackground );
|
||||
|
||||
cam->cY = fix( 300+2*CS ) + interpolatePositionY(fround(cam->cZ) );
|
||||
|
||||
for( int k=indexend-1; k>=indexstart; k--)
|
||||
{
|
||||
dprint( 100, 1+10*k-indexstart, C_WHITE, "S[%d]=%d", k, circuit[k]->DScale );
|
||||
currentcurve = circuit[k]->CumulatedCurve;
|
||||
|
||||
if (BDrawRoad)
|
||||
drawCircuitSegment( k );
|
||||
|
||||
if (BDrawDeco)
|
||||
drawDecoration( k );
|
||||
|
||||
if (BDrawCars)
|
||||
for( 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 );
|
||||
}
|
||||
|
||||
circuit[k]->CarList.clear();
|
||||
}
|
||||
|
||||
|
||||
int mod_base=20;
|
||||
int mod_comp=10;
|
||||
|
||||
for( int k=0; k<nuages.size(); k++)
|
||||
|
||||
if (abs(speed)<1.0) mod_base = 30, mod_comp = 15;
|
||||
else if (abs(speed)<2.0) mod_base = 20, mod_comp = 10;
|
||||
else if (abs(speed)<3.0) mod_base = 16, mod_comp = 8;
|
||||
else if (abs(speed)<4.0) mod_base = 12, mod_comp = 6;
|
||||
else if (abs(speed)<5.0) mod_base = 8, mod_comp = 4;
|
||||
else mod_base = 4, mod_comp = 2;
|
||||
|
||||
|
||||
if ((speed==0) || (l%mod_base<=mod_comp)) // the small rick to have the speed impression on wheels and to have the correct view of the car during turns
|
||||
{
|
||||
dprint( 250, 1+10*k, C_WHITE, "Cl[%d]=(%d,%d,%d)", k, nuages[k]->X, nuages[k]->Y, nuages[k]->type );
|
||||
if (viewside==-2) dsubimage( SCREEN_CX-40, SCREEN_HEIGHT-46, &player, 99,1,80,46, DIMAGE_NONE);
|
||||
else if (viewside==-1) dsubimage( SCREEN_CX-37, SCREEN_HEIGHT-46, &player, 181,1,74,46, DIMAGE_NONE);
|
||||
else if (viewside==0) dsubimage( SCREEN_CX-36, SCREEN_HEIGHT-46, &player, 257,1,72,46, DIMAGE_NONE);
|
||||
else if (viewside==1) dsubimage( SCREEN_CX-37, SCREEN_HEIGHT-46, &player, 331,1,74,46, DIMAGE_NONE);
|
||||
else if (viewside==2) dsubimage( SCREEN_CX-40, SCREEN_HEIGHT-46, &player, 407,1,80,46, DIMAGE_NONE);
|
||||
}
|
||||
#endif // 0
|
||||
|
||||
for( int k=0; k<traffic.size(); k++)
|
||||
else
|
||||
{
|
||||
if (traffic[k]->visible == true) dprint( 1, 1+10*k, C_GREEN, "Car %d Sc=%d wZ=%.0lf / Seg=%d X=%d Y=%d", k, traffic[k]->DScale, traffic[k]->wZ, traffic[k]->segnum, traffic[k]->X, traffic[k]->Y, traffic[k]->S );
|
||||
else dprint( 1, 1+10*k, C_RED, "Car %d Sc=%d wZ=%.0lf / Seg=%d X=%d Y=%d", k, traffic[k]->DScale, traffic[k]->wZ, traffic[k]->segnum, traffic[k]->X, traffic[k]->Y, traffic[k]->S );
|
||||
if (viewside==-2) dsubimage( SCREEN_CX-40, SCREEN_HEIGHT-46, &player, 99,49,80,46, DIMAGE_NONE);
|
||||
else if (viewside==-1) dsubimage( SCREEN_CX-37, SCREEN_HEIGHT-46, &player, 181,49,74,46, DIMAGE_NONE);
|
||||
else if (viewside==0) dsubimage( SCREEN_CX-36, SCREEN_HEIGHT-46, &player, 257,49,72,46, DIMAGE_NONE);
|
||||
else if (viewside==1) dsubimage( SCREEN_CX-37, SCREEN_HEIGHT-46, &player, 331,49,74,46, DIMAGE_NONE);
|
||||
else if (viewside==2) dsubimage( SCREEN_CX-40, SCREEN_HEIGHT-46, &player, 407,49,80,46, DIMAGE_NONE);
|
||||
}
|
||||
|
||||
}
|
||||
if (ShowDebug3)
|
||||
{
|
||||
dprint( 1, 1, C_BLACK, "S");
|
||||
for( int k=0; k<=indexend-indexstart; k++)
|
||||
|
||||
score = fround(cam->cZ)/100;
|
||||
|
||||
|
||||
//dprint( 1, 1, C_BLACK, "Crt=%.3D ms", time_create );
|
||||
|
||||
//dprint( 1, 15, C_RED, "Prj=%.3D ms", time_project );
|
||||
//dprint( 1, 30, C_RED, "Rdr=%.3D ms", time_render );
|
||||
//dprint( 1, 45, C_RED, "Upd=%.3D ms", time_update );
|
||||
|
||||
//dprint( 1, 1, C_BLACK, "Dt=%.3D ms", dt );
|
||||
|
||||
|
||||
float drawspeed = (float) (speed*5.0f);
|
||||
|
||||
|
||||
dsubimage( 5, 5, &speedhud, 0, 117, 37, 13, DIMAGE_NONE); // speed logo
|
||||
dsubimage( 135, 5, &speedhud, 0, 130, 37, 13, DIMAGE_NONE); // timer logo
|
||||
|
||||
dsubimage( 245, 5, &speedhud, 37, 117, 38, 13, DIMAGE_NONE); // speed logo
|
||||
dsubimage( 245, 25, &speedhud, 37, 130, 38, 13, DIMAGE_NONE); // timer logo
|
||||
|
||||
|
||||
dfont(&speedfont);
|
||||
if (drawspeed==0.0)
|
||||
{
|
||||
int nbCars=circuit[indexstart+k]->CarList.size();
|
||||
dprint( 25+k*25, 1, C_BLACK, "%d", indexstart+k );
|
||||
dprint( 25+k*25, 11, C_RED, "%d", nbCars );
|
||||
|
||||
for( int l=0; l<nbCars; l++ ) // For all cars inside that road segment
|
||||
{
|
||||
dprint( 1, 33+10*l, C_BLACK, "C" );
|
||||
dprint( 25+k*25, 33+10*l, C_BLACK, "%d", circuit[indexstart+k]->CarList[l]);
|
||||
}
|
||||
dprint_opt(122,3, C_RGB(0,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "0 :", drawspeed );
|
||||
dprint_opt(120,1, C_RGB(255,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "0 :", drawspeed );
|
||||
}
|
||||
else
|
||||
{
|
||||
dprint_opt(122,3, C_RGB(0,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.1f :", drawspeed );
|
||||
dprint_opt(120,1, C_RGB(255,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.1f :", drawspeed ); //the ':' char corresponds to "Km/h"
|
||||
}
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
/*
|
||||
for( int k=indexend-1; k>=indexstart; k--)
|
||||
{
|
||||
circuit[k]->CarList.clear();
|
||||
}
|
||||
*/
|
||||
dprint_opt(233,3, C_RGB(0,0,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.3D ;", remaining_time );
|
||||
dprint_opt(230,1, C_RGB(255,255,0), C_NONE, DTEXT_RIGHT, DTEXT_TOP, "%.3D ;", remaining_time ); // the ';' char corresponds to "s"
|
||||
|
||||
//dupdate();
|
||||
r61524_display(gint_vram, 0, DHEIGHT, R61524_DMA_WAIT);
|
||||
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"
|
||||
|
||||
|
||||
if (drawspeed==0.0) dsubimage( 48, 25, &speedhud, 0, 0, 76, 13, DIMAGE_NONE);
|
||||
else if (drawspeed<3.30) dsubimage( 48, 25, &speedhud, 0, 13, 76, 13, DIMAGE_NONE);
|
||||
else if (drawspeed<6.70) dsubimage( 48, 25, &speedhud, 0, 26, 76, 13, DIMAGE_NONE);
|
||||
else if (drawspeed<10.0) dsubimage( 48, 25, &speedhud, 0, 39, 76, 13, DIMAGE_NONE);
|
||||
else if (drawspeed<13.3) dsubimage( 48, 25, &speedhud, 0, 52, 76, 13, DIMAGE_NONE);
|
||||
else if (drawspeed<16.7) dsubimage( 48, 25, &speedhud, 0, 65, 76, 13, DIMAGE_NONE);
|
||||
else if (drawspeed<20.0) dsubimage( 48, 25, &speedhud, 0, 78, 76, 13, DIMAGE_NONE);
|
||||
else if (drawspeed<23.3) dsubimage( 48, 25, &speedhud, 0, 91, 76, 13, DIMAGE_NONE);
|
||||
else dsubimage( 48, 25, &speedhud, 0, 104, 76, 13, DIMAGE_NONE);
|
||||
|
||||
//dprint( 1, 1, C_BLACK, "FPS=%.3D ms", 1000/dt );
|
||||
|
||||
/*
|
||||
#if 0
|
||||
dprint( 1, 210, C_WHITE, "Decs: %c", BDrawDeco==true?'Y':'N' ); // Key F1
|
||||
dprint( 67, 210, C_WHITE, "Clds: %c", BDrawClds==true?'Y':'N' ); // Key F2
|
||||
dprint( 133, 210, C_WHITE, "Cars: %c", BDrawCars==true?'Y':'N' ); // Key F3
|
||||
|
||||
dprint( 199, 210, C_WHITE, "DtR: %.1f", ((float) (time_render) / 1000.0) ); // Key F4
|
||||
dprint( 265, 210, C_WHITE, "ScrSht" ); // Key F5
|
||||
dprint( 331, 210, C_WHITE, "RecVid" ); // Key F6
|
||||
#endif // 1
|
||||
|
||||
#if 0
|
||||
if (ShowDebug1)
|
||||
{
|
||||
Segment* currentSeg = circuit[indexstart];
|
||||
|
||||
dprint( 1, 1, C_RED, "Crt=%.3D ms", time_create );
|
||||
dprint( 1, 15, C_RED, "Prj=%.3D ms", time_project );
|
||||
dprint( 1, 29, C_RED, "Rdr=%.3D ms", time_render );
|
||||
|
||||
dprint( 1, 55, C_WHITE, "It=%d", l);
|
||||
dprint( 1, 69, C_GREEN, "St=%d ", indexstart );
|
||||
dprint( 1, 83, C_GREEN, "En=%d", indexend );
|
||||
dprint( 1, 97, C_RED, "Sz= %d", circuit.size() );
|
||||
|
||||
dprint( 100, 55, C_WHITE, "SzSgmt=%d bytes", sizeof(Segment) );
|
||||
dprint( 100, 69, C_WHITE, ">XYZc=(%d,%d,%.0lf,%d)", circuit[indexstart]->wX, circuit[indexstart]->wY, circuit[indexstart]->wZ, circuit[indexstart]->Curve );
|
||||
dprint( 100, 83, C_WHITE, ">XYZc=(%d,%d,%.0lf,%d)", circuit[indexend]->wX, circuit[indexend]->wY, circuit[indexend]->wZ, circuit[indexstart]->Curve );
|
||||
dprint( 100, 97, C_WHITE, "C[i]Adr= %p", ¤tSeg),
|
||||
|
||||
dprint( 320, 1, C_WHITE, "CamX=%d", fround( cam->cX ) );
|
||||
dprint( 320, 15, C_WHITE, "CamY=%d", fround( cam->cY ) );
|
||||
dprint( 320, 29, C_WHITE, "CamZ=%d", fround( cam->cZ ) );
|
||||
|
||||
dprint( 320, 55, C_WHITE, "Dir=%d", direction );
|
||||
dprint( 320, 69, C_WHITE, "Spd=%.1f", speed );
|
||||
dprint( 320, 83, C_WHITE, "Dz =%.1f", speed*dt );
|
||||
dprint( 320, 97, C_WHITE, "dt =%.3D ms", dt );
|
||||
}
|
||||
if (ShowDebug2)
|
||||
{
|
||||
#if 0
|
||||
dprint( 1, 1, C_RED, "Crt=%.3D ms", time_create );
|
||||
dprint( 1, 15, C_RED, "Prj=%.3D ms", time_project );
|
||||
dprint( 1, 29, C_RED, "Rdr=%.3D ms", time_render );
|
||||
dprint( 1, 50, C_BLACK, "ISt_Z=%.1lf", circuit[indexstart]->wZ);
|
||||
dprint( 1, 65, C_BLACK, "IEd_Z=%.1lf", circuit[indexend]->wZ);
|
||||
|
||||
|
||||
|
||||
for( int k=indexend-1; k>=indexstart; k--)
|
||||
{
|
||||
dprint( 100, 1+10*k-indexstart, C_WHITE, "S[%d]=%d", k, circuit[k]->DScale );
|
||||
}
|
||||
|
||||
|
||||
|
||||
for( int k=0; k<nuages.size(); k++)
|
||||
{
|
||||
dprint( 250, 1+10*k, C_WHITE, "Cl[%d]=(%d,%d,%d)", k, nuages[k]->X, nuages[k]->Y, nuages[k]->type );
|
||||
}
|
||||
#endif // 0
|
||||
|
||||
for( int k=0; k<traffic.size(); k++)
|
||||
{
|
||||
if (traffic[k]->visible == true) dprint( 1, 1+10*k, C_GREEN, "Car %d Sc=%d wZ=%.0lf / Seg=%d X=%d Y=%d", k, traffic[k]->DScale, traffic[k]->wZ, traffic[k]->segnum, traffic[k]->X, traffic[k]->Y, traffic[k]->S );
|
||||
else dprint( 1, 1+10*k, C_RED, "Car %d Sc=%d wZ=%.0lf / Seg=%d X=%d Y=%d", k, traffic[k]->DScale, traffic[k]->wZ, traffic[k]->segnum, traffic[k]->X, traffic[k]->Y, traffic[k]->S );
|
||||
}
|
||||
|
||||
}
|
||||
if (ShowDebug3)
|
||||
{
|
||||
dprint( 1, 1, C_BLACK, "S");
|
||||
for( int k=0; k<=indexend-indexstart; k++)
|
||||
{
|
||||
int nbCars=circuit[indexstart+k]->CarList.size();
|
||||
dprint( 25+k*25, 1, C_BLACK, "%d", indexstart+k );
|
||||
dprint( 25+k*25, 11, C_RED, "%d", nbCars );
|
||||
|
||||
for( int l=0; l<nbCars; l++ ) // For all cars inside that road segment
|
||||
{
|
||||
dprint( 1, 33+10*l, C_BLACK, "C" );
|
||||
dprint( 25+k*25, 33+10*l, C_BLACK, "%d", circuit[indexstart+k]->CarList[l]);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
/*
|
||||
for( int k=indexend-1; k>=indexstart; k--)
|
||||
{
|
||||
circuit[k]->CarList.clear();
|
||||
}
|
||||
*/
|
||||
|
||||
//dupdate();
|
||||
r61524_display(gint_vram, 0, DHEIGHT, R61524_DMA_WAIT);
|
||||
|
||||
|
||||
prof_leave(perf_render);
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#define NB_CARS_TRAFFIC 100
|
||||
|
||||
#define MAX_SUBIMAGES_TREES 12
|
||||
#define NB_TREES_TYPES 11
|
||||
#define NB_TREES_TYPES 14
|
||||
|
||||
#define MAX_SUBIMAGES_CARS 12
|
||||
#define NB_CARS_TYPES 8
|
||||
|
|
|
@ -30,7 +30,8 @@ extern bopti_image_t tree1, tree2, tree3, tree4, tree5, tree6;
|
|||
extern bopti_image_t sky1, sky2, sky3;
|
||||
extern bopti_image_t mountain;
|
||||
extern bopti_image_t treeline;
|
||||
extern bopti_image_t leftturn, rightturn, uphill, downhill, checkpoint;
|
||||
extern bopti_image_t leftturn, rightturn, uphill, downhill;
|
||||
extern bopti_image_t checkpoint, startlights, stoplights, waitlights;
|
||||
|
||||
|
||||
bopti_image_t *scaledTrees[NB_TREES_TYPES][MAX_SUBIMAGES_TREES] = { 0 };
|
||||
|
@ -141,13 +142,7 @@ void initData( void )
|
|||
|
||||
void createCircuit( void )
|
||||
{
|
||||
/* for( int i=0; i<MAX_SEGMENT; i++)
|
||||
{
|
||||
Segment *seg=new Segment( i );
|
||||
if (seg!=nullptr) circuit.push_back( seg );
|
||||
}
|
||||
*/
|
||||
|
||||
addStartLine( PLAINS );
|
||||
addStraightLine( L_VERYSHORT, PLAINS );
|
||||
addCurvyHill( L_MEDIUM, H_BIG, UP_HILL, C_HARD, LEFT_CURVE, DESERT );
|
||||
addStraightLine( L_VERYSHORT, DESERT );
|
||||
|
@ -155,27 +150,18 @@ void createCircuit( void )
|
|||
addCheckPoint( PLAINS );
|
||||
addStraightLine( L_VERYSHORT, PLAINS );
|
||||
addCheckPoint( DESERT );
|
||||
//addStraightLine( L_VERYSHORT, PLAINS );
|
||||
//addStraightLine( L_VERYSHORT, DESERT );
|
||||
addCurve( L_SHORT, C_HARD, LEFT_CURVE, DESERT );
|
||||
addCurve( L_SHORT, C_HARD, RIGHT_CURVE, DESERT );
|
||||
addStraightLine( L_LONG, DESERT );
|
||||
addHill( L_MEDIUM, H_BIG, UP_HILL, DESERT );
|
||||
addHill( L_MEDIUM, H_BIG, DOWN_HILL, PLAINS );
|
||||
//addCurve( L_SHORT, C_HARD, RIGHT_CURVE, PLAINS );
|
||||
addStraightLine( L_VERYLONG, PLAINS );
|
||||
addCurve( L_SHORT, C_HARD, LEFT_CURVE, PLAINS );
|
||||
addStraightLine( L_VERYLONG, DESERT );
|
||||
addCurve( L_SHORT, C_EASY, LEFT_CURVE, DESERT );
|
||||
//addHill( L_MEDIUM, H_BIG, UP_HILL, DESERT );
|
||||
//addHill( L_MEDIUM, H_BIG, DOWN_HILL, DESERT );
|
||||
//addCurve( L_SHORT, C_HARD, RIGHT_CURVE, PLAINS );
|
||||
//addStraightLine( L_VERYLONG, PLAINS );
|
||||
//addCurve( L_SHORT, C_HARD, LEFT_CURVE, PLAINS );
|
||||
//addHill( L_MEDIUM, H_BIG, UP_HILL, PLAINS );
|
||||
//addHill( L_MEDIUM, H_BIG, DOWN_HILL, PLAINS );
|
||||
//addCurve( L_SHORT, C_HARD, RIGHT_CURVE, DESERT );
|
||||
//addStraightLine( L_VERYLONG, DESERT );
|
||||
addCheckPoint( PLAINS );
|
||||
addFinishLine( DESERT );
|
||||
addStraightLine( L_VERYSHORT, PLAINS );
|
||||
};
|
||||
|
||||
void putBillBoards( void )
|
||||
|
@ -333,6 +319,99 @@ void addCheckPoint( int8_t biome )
|
|||
}
|
||||
|
||||
|
||||
void addStartLine( int8_t biome )
|
||||
{
|
||||
double lastZ=0;
|
||||
int16_t lastY=0;
|
||||
|
||||
uint16_t lastIndex = circuit.size();
|
||||
if (lastIndex!=0)
|
||||
{
|
||||
lastY=circuit[lastIndex-1]->wY;
|
||||
lastZ=circuit[lastIndex-1]->wZ+SEGMENT_LENGTH;
|
||||
}
|
||||
|
||||
for( int i=0; i<5; i++)
|
||||
{
|
||||
Segment *seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, -1, -1 );
|
||||
if (seg!=nullptr)
|
||||
{
|
||||
seg->Environment = biome;
|
||||
circuit.push_back( seg );
|
||||
}
|
||||
}
|
||||
|
||||
for( int i=5; i<10; i++)
|
||||
{
|
||||
Segment *seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, STARTLIGHT, STARTLIGHT );
|
||||
if (seg!=nullptr)
|
||||
{
|
||||
seg->Environment = biome;
|
||||
if (i==7) seg->Special = START;
|
||||
circuit.push_back( seg );
|
||||
}
|
||||
}
|
||||
|
||||
for( int i=10; i<15; i++)
|
||||
{
|
||||
Segment *seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, -1, -1 );
|
||||
if (seg!=nullptr)
|
||||
{
|
||||
seg->Environment = biome;
|
||||
circuit.push_back( seg );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void addFinishLine( int8_t biome )
|
||||
{
|
||||
double lastZ=0;
|
||||
int16_t lastY=0;
|
||||
|
||||
uint16_t lastIndex = circuit.size();
|
||||
if (lastIndex!=0)
|
||||
{
|
||||
lastY=circuit[lastIndex-1]->wY;
|
||||
lastZ=circuit[lastIndex-1]->wZ+SEGMENT_LENGTH;
|
||||
}
|
||||
|
||||
for( int i=0; i<5; i++)
|
||||
{
|
||||
Segment *seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, -1, -1 );
|
||||
if (seg!=nullptr)
|
||||
{
|
||||
seg->Environment = biome;
|
||||
circuit.push_back( seg );
|
||||
}
|
||||
}
|
||||
|
||||
for( int i=5; i<10; i++)
|
||||
{
|
||||
Segment *seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, STOPLIGHT, STOPLIGHT );
|
||||
if (seg!=nullptr)
|
||||
{
|
||||
seg->Environment = biome;
|
||||
if (i==7) seg->Special = FINISH;
|
||||
circuit.push_back( seg );
|
||||
}
|
||||
}
|
||||
|
||||
for( int i=10; i<15; i++)
|
||||
{
|
||||
Segment *seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, 0, -1, -1 );
|
||||
if (seg!=nullptr)
|
||||
{
|
||||
seg->Environment = biome;
|
||||
circuit.push_back( seg );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void addStraightLine( Length l, int8_t biome )
|
||||
{
|
||||
double lastZ=0;
|
||||
|
@ -662,8 +741,10 @@ void prepareDecoration( void )
|
|||
else if (k==7) src = &rightturn;
|
||||
else if (k==8) src = &uphill;
|
||||
else if (k==9) src = &downhill;
|
||||
else src = &checkpoint;
|
||||
|
||||
else if (k==10) src = &checkpoint;
|
||||
else if (k==11) src = &startlights;
|
||||
else if (k==12) src = &stoplights;
|
||||
else if (k==13) src = &waitlights;
|
||||
|
||||
int width = (int) ((float) src->width * scale);
|
||||
int height = (int) ((float) src->height * scale);
|
||||
|
@ -726,7 +807,7 @@ void drawDecoration( uint16_t index )
|
|||
if (distance<0) distance = 0;
|
||||
else if (distance>(MAX_SUBIMAGES_TREES-1)) distance = (MAX_SUBIMAGES_TREES-1);
|
||||
|
||||
circuit[index]->DScale = distance;
|
||||
//circuit[index]->DScale = distance;
|
||||
|
||||
int deco = circuit[index]->LDeco;
|
||||
|
||||
|
@ -754,10 +835,14 @@ void drawDecoration( uint16_t index )
|
|||
}
|
||||
|
||||
|
||||
void updateTraffic( float dt )
|
||||
void updateTraffic( float dt, uint32_t maxdistance )
|
||||
{
|
||||
for(int k=0; k<traffic.size(); k++)
|
||||
{
|
||||
traffic[k]->wZ += traffic[k]->Speed*dt;
|
||||
if (traffic[k]->wZ>maxdistance) traffic[k]->wZ-=maxdistance;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -769,9 +854,9 @@ void drawTraffic( uint16_t index )
|
|||
if (distance<0) distance = 0;
|
||||
else if (distance>(MAX_SUBIMAGES_CARS-1)) distance = (MAX_SUBIMAGES_CARS-1);
|
||||
|
||||
int segnumber = findIndex( traffic[index]->wZ );
|
||||
traffic[index]->segnum = segnumber;
|
||||
traffic[index]->DScale = distance;
|
||||
//int segnumber = findIndex( traffic[index]->wZ );
|
||||
//traffic[index]->segnum = segnumber;
|
||||
//traffic[index]->DScale = distance;
|
||||
|
||||
image = scaledCars[traffic[index]->Type][distance];
|
||||
|
||||
|
|
Loading…
Reference in New Issue