v0.25
|
@ -17,7 +17,6 @@ set(SOURCES
|
|||
src/src/drawstuff.cc
|
||||
src/src/clouds.cc
|
||||
src/src/cars.cc
|
||||
# ...
|
||||
)
|
||||
|
||||
set(ASSETS_cg
|
||||
|
@ -32,10 +31,15 @@ set(ASSETS_cg
|
|||
assets-cg/trees/tree1.png
|
||||
assets-cg/trees/tree2.png
|
||||
assets-cg/trees/tree3.png
|
||||
assets-cg/trees/tree4.png
|
||||
assets-cg/trees/tree5.png
|
||||
assets-cg/trees/tree6.png
|
||||
assets-cg/player/player.png
|
||||
assets-cg/clouds/sky1.png
|
||||
assets-cg/clouds/sky2.png
|
||||
assets-cg/clouds/sky3.png
|
||||
assets-cg/backgrnd/mountain.png
|
||||
assets-cg/backgrnd/treeline.png
|
||||
)
|
||||
|
||||
fxconv_declare_assets(${ASSETS_cg} WITH_METADATA)
|
||||
|
|
132
CppOutRun.layout
|
@ -2,58 +2,9 @@
|
|||
<CodeBlocks_layout_file>
|
||||
<FileVersion major="1" minor="0" />
|
||||
<ActiveTarget name="Release" />
|
||||
<File name="src/src/circuit.cc" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<File name="src/include/circuit.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="18164" topLine="562" />
|
||||
</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">
|
||||
<Cursor>
|
||||
<Cursor1 position="813" topLine="36" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="CMakeLists.txt" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="406" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/include/segment.h" open="1" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="574" topLine="11" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/main.cc" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="7332" topLine="258" />
|
||||
</Cursor>
|
||||
<Folding>
|
||||
<Collapse line="316" />
|
||||
<Collapse line="343" />
|
||||
</Folding>
|
||||
</File>
|
||||
<File name="src/src/cars.cc" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="274" topLine="14" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/colors.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="352" 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">
|
||||
<Cursor>
|
||||
<Cursor1 position="203" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/include/cars.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="243" 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" />
|
||||
<Cursor1 position="645" topLine="30" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/fixed.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
|
@ -61,19 +12,9 @@
|
|||
<Cursor1 position="778" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/include/drawstuff.h" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<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>
|
||||
<Cursor1 position="622" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/parameters.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="285" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/src/drawstuff.cc" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="2486" topLine="61" />
|
||||
<Cursor1 position="2642" topLine="49" />
|
||||
</Cursor>
|
||||
<Folding>
|
||||
<Collapse line="33" />
|
||||
|
@ -81,19 +22,74 @@
|
|||
<Collapse line="76" />
|
||||
</Folding>
|
||||
</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">
|
||||
<Cursor>
|
||||
<Cursor1 position="622" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/include/segment.h" open="0" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="574" topLine="11" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/main.cc" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="572" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/colors.h" open="0" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="352" 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/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="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="1019" topLine="11" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/src/segment.cc" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="203" 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">
|
||||
<Cursor>
|
||||
<Cursor1 position="370" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/src/segment.cc" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="593" topLine="28" />
|
||||
</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/circuit.cc" open="1" top="1" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="17732" topLine="12" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="CMakeLists.txt" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="411" topLine="3" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<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="394" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
<File name="src/include/cars.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||
<Cursor>
|
||||
<Cursor1 position="443" topLine="0" />
|
||||
</Cursor>
|
||||
</File>
|
||||
</CodeBlocks_layout_file>
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
*.png:
|
||||
type: bopti-image
|
||||
profile: p4
|
||||
name_regex: (.*)\.png \1
|
||||
|
After Width: | Height: | Size: 31 KiB |
After Width: | Height: | Size: 30 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 2.2 KiB |
After Width: | Height: | Size: 1.2 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 27 KiB |
|
@ -20,6 +20,7 @@ class Cars
|
|||
|
||||
int16_t X;
|
||||
int16_t Y;
|
||||
uint8_t S;
|
||||
|
||||
uint8_t Speed;
|
||||
uint8_t Type;
|
||||
|
|
|
@ -44,7 +44,10 @@ enum Decoration
|
|||
{
|
||||
PALMTREE = 0,
|
||||
DEADTREE = 1,
|
||||
OAKTREE = 2
|
||||
OAKTREE = 2,
|
||||
CACTUS = 3,
|
||||
BIGLEAF = 4,
|
||||
SMALLLEAF = 5
|
||||
};
|
||||
|
||||
void initData( void );
|
||||
|
@ -55,7 +58,7 @@ void createTraffic( void );
|
|||
void projectCircuitFP( void );
|
||||
void projectCircuitFP( uint16_t index );
|
||||
|
||||
void updateTraffic( void );
|
||||
void updateTraffic( float dt );
|
||||
|
||||
void printCircuit( void );
|
||||
void printCircuit( int i );
|
||||
|
@ -64,6 +67,8 @@ void drawCircuitSegment( uint16_t index );
|
|||
void drawDecoration( uint16_t index );
|
||||
void drawTraffic( uint16_t index );
|
||||
void drawClouds( int offset );
|
||||
void drawFarBackground( int offset );
|
||||
void drawNearBackground( int offset );
|
||||
|
||||
void freeDecoration( void );
|
||||
void prepareDecoration( void );
|
||||
|
|
160
src/main.cc
|
@ -25,9 +25,11 @@
|
|||
|
||||
|
||||
extern bopti_image_t car1, car2, car3, car4, car5, car6, car7, car8;
|
||||
extern bopti_image_t tree1, tree2, tree3;
|
||||
extern bopti_image_t tree1, tree2, tree3, tree4, tree5, tree6;
|
||||
extern bopti_image_t player;
|
||||
extern bopti_image_t sky1, sky2, sky3;
|
||||
extern bopti_image_t mountain;
|
||||
extern bopti_image_t treeline;
|
||||
|
||||
|
||||
std::vector<Segment*> circuit;
|
||||
|
@ -49,6 +51,7 @@ bool ShowDebug3 = false;
|
|||
bool BDrawDeco = true;
|
||||
bool BDrawClds = true;
|
||||
bool BDrawCars = true;
|
||||
bool BDrawRoad = true;
|
||||
|
||||
|
||||
uint16_t currentcurve=0;
|
||||
|
@ -62,12 +65,17 @@ bool speedcontrol = false;
|
|||
|
||||
|
||||
uint8_t minYRoad = 224; // We will track the upper Y (in fact the minimum Y during the RoadDrawing to optimize the rendering of the Sky
|
||||
int8_t viewside = 0;
|
||||
|
||||
int deltaFarbackground = 0;
|
||||
int deltaNearbackground = 0;
|
||||
int lastindex=0;
|
||||
|
||||
|
||||
|
||||
static void get_inputs( float dt )
|
||||
static void get_inputs( float dt, int index )
|
||||
{
|
||||
int CC = circuit[index]->Curve;
|
||||
|
||||
|
||||
key_event_t ev;
|
||||
while((ev = pollevent()).type != KEYEV_NONE)
|
||||
{
|
||||
|
@ -75,8 +83,21 @@ static void get_inputs( float dt )
|
|||
}
|
||||
speedcontrol = false;
|
||||
|
||||
if(keydown(KEY_LEFT)) cam->decX(25.0);
|
||||
if(keydown(KEY_RIGHT)) cam->incX(25.0);
|
||||
viewside=0;
|
||||
|
||||
if(keydown(KEY_LEFT))
|
||||
{
|
||||
cam->decX(25.0);
|
||||
viewside=-1;
|
||||
if (CC<0) viewside=-2;
|
||||
}
|
||||
|
||||
if(keydown(KEY_RIGHT))
|
||||
{
|
||||
cam->incX(25.0);
|
||||
viewside=1;
|
||||
if (CC>0) viewside=+2;
|
||||
}
|
||||
|
||||
if(keydown(KEY_SHIFT))
|
||||
{
|
||||
|
@ -152,7 +173,7 @@ static void get_inputs( float dt )
|
|||
if(keydown(KEY_F1)) BDrawDeco = !BDrawDeco;
|
||||
if(keydown(KEY_F2)) BDrawClds = !BDrawClds;
|
||||
if(keydown(KEY_F3)) BDrawCars = !BDrawCars;
|
||||
//if(keydown(KEY_F4)) { }
|
||||
if(keydown(KEY_F4)) BDrawRoad = !BDrawRoad;
|
||||
|
||||
if(keydown(KEY_F5)) screenshot = true;
|
||||
if(keydown(KEY_F6)) record = !record;
|
||||
|
@ -169,6 +190,19 @@ static void get_inputs( float dt )
|
|||
else
|
||||
cam->decZ(speed*dt);
|
||||
}
|
||||
|
||||
|
||||
/* Adjust position of the background */
|
||||
if (lastindex!=index)
|
||||
{
|
||||
deltaFarbackground -= CC*speed*dt/250;
|
||||
deltaNearbackground -= CC*speed*dt/100;
|
||||
}
|
||||
lastindex = index;
|
||||
|
||||
/* adjust speed if we drive on the side of the road */
|
||||
if (fround(cam->cX)<-1*ROAD_WIDTH && speed>2.0) speed=2.0;
|
||||
if (fround(cam->cX)>ROAD_WIDTH && speed>2.0) speed=2.0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -182,8 +216,8 @@ int main(void)
|
|||
usb_open(interfaces, GINT_CALL_NULL);
|
||||
#endif
|
||||
|
||||
prof_t perf_create, perf_project, perf_render;
|
||||
uint32_t time_create=0, time_project=0, time_render=0;
|
||||
prof_t perf_update, perf_create, perf_project, perf_render;
|
||||
uint32_t time_update=0, time_create=0, time_project=0, time_render=0;
|
||||
prof_init();
|
||||
|
||||
int nbInterestingSegments = (MAX_RENDER_DISTANCE / SEGMENT_LENGTH); // the number of segments to be projected considering the rendering distance
|
||||
|
@ -215,20 +249,27 @@ int main(void)
|
|||
|
||||
while (!stop)
|
||||
{
|
||||
get_inputs( dt );
|
||||
dt = ((float) (time_render+time_project) / 1000.0);
|
||||
|
||||
perf_update = prof_make();
|
||||
prof_enter(perf_update);
|
||||
|
||||
get_inputs( dt, indexstart );
|
||||
dt = ((float) (time_update+time_render+time_project) / 1000.0);
|
||||
|
||||
//--------------
|
||||
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;
|
||||
indexend = indexstart+nbInterestingSegments+1;
|
||||
|
||||
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);
|
||||
|
||||
//--------------
|
||||
|
||||
perf_project = prof_make();
|
||||
|
@ -237,15 +278,18 @@ int main(void)
|
|||
|
||||
if (BDrawCars)
|
||||
{
|
||||
updateTraffic();
|
||||
updateTraffic( dt );
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -270,9 +314,6 @@ int main(void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
prof_leave(perf_project);
|
||||
time_project = prof_time(perf_project);
|
||||
|
||||
|
@ -282,21 +323,25 @@ int main(void)
|
|||
prof_enter(perf_render);
|
||||
|
||||
|
||||
drawSkyOptimised( DAY_BLUE_SKY );
|
||||
drawSky( DAY_BLUE_SKY );
|
||||
|
||||
if (BDrawClds)
|
||||
{
|
||||
drawClouds( l % 396 );
|
||||
}
|
||||
|
||||
drawFarBackground( deltaFarbackground );
|
||||
drawNearBackground( deltaNearbackground );
|
||||
|
||||
cam->cY = fix( 300 ) + interpolatePositionY(fround(cam->cZ));
|
||||
cam->cY = fix( 300 ) + interpolatePositionY(fround(cam->cZ) + SEGMENT_LENGTH );
|
||||
|
||||
for( int k=indexend-1; k>=indexstart; k--)
|
||||
{
|
||||
currentcurve = circuit[k]->CumulatedCurve;
|
||||
drawCircuitSegment( k );
|
||||
if (BDrawDeco) drawDecoration( k );
|
||||
|
||||
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
|
||||
|
@ -305,12 +350,52 @@ int main(void)
|
|||
drawTraffic( indexCar );
|
||||
}
|
||||
|
||||
//circuit[k]->CarList.clear();
|
||||
circuit[k]->CarList.clear();
|
||||
}
|
||||
|
||||
dsubimage( SCREEN_CX-36, SCREEN_HEIGHT-48, &player, 257,1,72,46, DIMAGE_NONE);
|
||||
|
||||
#if 1
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
//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 );
|
||||
|
||||
//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
|
||||
|
@ -320,7 +405,7 @@ int main(void)
|
|||
dprint( 331, 210, C_WHITE, "RecVid" ); // Key F6
|
||||
#endif // 1
|
||||
|
||||
#if 1
|
||||
#if 0
|
||||
if (ShowDebug1)
|
||||
{
|
||||
Segment* currentSeg = circuit[indexstart];
|
||||
|
@ -350,30 +435,32 @@ int main(void)
|
|||
}
|
||||
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( 100, 1+10*k, C_BLACK, "Cr[%d]=%d-(%.2f,%.0lf,%d,%d)-(%d,%d,%d)", k, traffic[k]->DScale, traffic[k]->wX, traffic[k]->wZ, traffic[k]->Speed, traffic[k]->Type, traffic[k]->segnum, traffic[k]->X, traffic[k]->Y );
|
||||
else dprint( 100, 1+10*k, C_RED, "Cr[%d]=%d-(%.2f,%.0lf,%d,%d)-(%d,%d,%d)", k, traffic[k]->DScale, traffic[k]->wX, traffic[k]->wZ, traffic[k]->Speed, traffic[k]->Type, traffic[k]->segnum, traffic[k]->X, traffic[k]->Y );
|
||||
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 );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -394,14 +481,14 @@ int main(void)
|
|||
}
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
for( int k=indexend-1; k>=indexstart; k--)
|
||||
{
|
||||
circuit[k]->CarList.clear();
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
dupdate();
|
||||
//r61524_display(gint_vram, 0, DHEIGHT, R61524_DMA_WAIT);
|
||||
|
@ -409,6 +496,7 @@ int main(void)
|
|||
|
||||
prof_leave(perf_render);
|
||||
time_render = prof_time(perf_render);
|
||||
|
||||
#if IS_FXLIB==1
|
||||
if (screenshot && usb_is_open())
|
||||
{
|
||||
|
|
|
@ -14,12 +14,18 @@
|
|||
#define ASPECT_RATIO 1.767
|
||||
#define DISTANCE_SCREEN 0.83444
|
||||
|
||||
|
||||
#define MAX_RENDER_DISTANCE 3000
|
||||
|
||||
|
||||
#define NB_CLOUDS_SKY 10
|
||||
#define NB_CARS_TRAFFIC 10
|
||||
#define NB_CARS_TRAFFIC 100
|
||||
|
||||
#define MAX_SUBIMAGES_TREES 12
|
||||
#define NB_TREES_TYPES 6
|
||||
|
||||
#define MAX_SUBIMAGES_CARS 12
|
||||
#define NB_CARS_TYPES 8
|
||||
|
||||
#define std ustl
|
||||
|
||||
|
|
|
@ -33,14 +33,11 @@ Cars::Cars( float x, double z, uint8_t s, uint8_t t )
|
|||
|
||||
void Cars::Project3DFP( camera* c, uint16_t index )
|
||||
{
|
||||
fixed_t DX = (fix(wX*ROAD_WIDTH) - c->cX);
|
||||
fixed_t DY = (interpolatePositionY( wZ ) - c->cY);
|
||||
fixed_t DX = fix(wX*ROAD_WIDTH) - c->cX;
|
||||
fixed_t DY = interpolatePositionY(wZ) - c->cY;
|
||||
|
||||
fixed_t divDZ = fdiv( fix(1), (fixdouble(wZ) - c->cZ));
|
||||
fixed_t RW = fix(ROAD_WIDTH);
|
||||
|
||||
fixed_t divAR = fdiv(fix(1), fixdouble(ASPECT_RATIO));
|
||||
|
||||
fixed_t Scale = fmul(fixdouble(DISTANCE_SCREEN), divDZ);
|
||||
|
||||
fixed_t tempx = fmul(fmul(DX,Scale), divAR);
|
||||
|
@ -49,8 +46,8 @@ void Cars::Project3DFP( camera* c, uint16_t index )
|
|||
fixed_t sX=fmul(fix(SCREEN_CX), (fix(1)+tempx));
|
||||
fixed_t sY=fmul(fix(SCREEN_CY), (fix(1)-tempy));
|
||||
|
||||
X=fround(sX) + circuit[ index ]->CumulatedCurve;
|
||||
Y=fround(sY);
|
||||
X = fround(sX) + circuit[ index ]->CumulatedCurve;
|
||||
Y = fround(sY);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -26,11 +26,13 @@ extern bool ShowDebug1;
|
|||
|
||||
|
||||
extern bopti_image_t car1, car2, car3, car4, car5, car6, car7, car8;
|
||||
extern bopti_image_t tree1, tree2, tree3;
|
||||
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;
|
||||
|
||||
bopti_image_t *scaledTrees[3][25] = { 0 };
|
||||
bopti_image_t *scaledCars[3][25] = { 0 };
|
||||
bopti_image_t *scaledTrees[NB_TREES_TYPES][MAX_SUBIMAGES_TREES] = { 0 };
|
||||
bopti_image_t *scaledCars[NB_CARS_TYPES][MAX_SUBIMAGES_CARS] = { 0 };
|
||||
|
||||
|
||||
size_t image_size_profile(int profile, int width, int height)
|
||||
|
@ -126,15 +128,12 @@ bopti_image_t *resize(bopti_image_t const *src, int w, int h)
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void initData( void )
|
||||
{
|
||||
cam = new camera();
|
||||
cam->cX = fixdouble(0.0f);
|
||||
cam->cY = fixdouble(300.0f);
|
||||
cam->cZ = fixdouble(260.0f);
|
||||
cam->cZ = fixdouble(0.0f);
|
||||
}
|
||||
|
||||
|
||||
|
@ -147,6 +146,8 @@ void createCircuit( void )
|
|||
}
|
||||
*/
|
||||
|
||||
addStraightLine( L_VERYSHORT, PLAINS );
|
||||
addStraightLine( L_VERYSHORT, DESERT );
|
||||
addStraightLine( L_VERYSHORT, PLAINS );
|
||||
addStraightLine( L_VERYSHORT, DESERT );
|
||||
addCurve( L_SHORT, C_HARD, LEFT_CURVE, DESERT );
|
||||
|
@ -194,9 +195,11 @@ void createTraffic( void )
|
|||
for( int k = 0; k < NB_CARS_TRAFFIC; k++)
|
||||
{
|
||||
int8_t X = rand() % 4;
|
||||
double Z = (double) (rand() % 4000);
|
||||
uint8_t S = rand() % 4;
|
||||
uint8_t T = rand() % 3;
|
||||
//double Z = (double) (rand() % 4000);
|
||||
//int8_t X = 0;
|
||||
double Z = (k+1)*SEGMENT_LENGTH;
|
||||
uint8_t S = 4 + (rand() % 2);
|
||||
uint8_t T = rand() % 8;
|
||||
|
||||
Cars* car;
|
||||
|
||||
|
@ -217,10 +220,11 @@ void addStraightLine( Length l, int8_t biome )
|
|||
double lastZ=0;
|
||||
int16_t lastY=0;
|
||||
|
||||
if (circuit.size()!=0)
|
||||
uint16_t lastIndex = circuit.size();
|
||||
if (lastIndex!=0)
|
||||
{
|
||||
lastY=circuit[circuit.size()-1]->wY;
|
||||
lastZ=circuit[circuit.size()-1]->wZ;
|
||||
lastY=circuit[lastIndex-1]->wY;
|
||||
lastZ=circuit[lastIndex-1]->wZ+SEGMENT_LENGTH;
|
||||
}
|
||||
|
||||
srand( rtc_ticks() );
|
||||
|
@ -231,10 +235,10 @@ void addStraightLine( Length l, int8_t biome )
|
|||
int deco = rand() % 4;
|
||||
Segment *seg;
|
||||
|
||||
if (deco==0) seg=new Segment( 0, lastY, lastZ + (i+1)*SEGMENT_LENGTH, 0, -1, -1 );
|
||||
else if (deco==1) seg=new Segment( 0, lastY, lastZ + (i+1)*SEGMENT_LENGTH, 0, -1, DEADTREE );
|
||||
else if (deco==2) seg=new Segment( 0, lastY, lastZ + (i+1)*SEGMENT_LENGTH, 0, PALMTREE, -1 );
|
||||
else if (deco==3) seg=new Segment( 0, lastY, lastZ + (i+1)*SEGMENT_LENGTH, 0, PALMTREE, DEADTREE );
|
||||
if (deco==0) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, SMALLLEAF, -1 );
|
||||
else if (deco==1) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, -1, DEADTREE );
|
||||
else if (deco==2) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, PALMTREE, -1 );
|
||||
else if (deco==3) seg=new Segment( 0, lastY, lastZ + i*SEGMENT_LENGTH, 0, CACTUS, BIGLEAF );
|
||||
|
||||
if (seg!=nullptr)
|
||||
{
|
||||
|
@ -249,11 +253,13 @@ void addCurve( Length l, CurveStrength s, CurveType t, int8_t biome )
|
|||
double lastZ=0;
|
||||
int16_t lastY=0;
|
||||
|
||||
if (circuit.size()!=0)
|
||||
uint16_t lastIndex = circuit.size();
|
||||
if (lastIndex!=0)
|
||||
{
|
||||
lastY=circuit[circuit.size()-1]->wY;
|
||||
lastZ=circuit[circuit.size()-1]->wZ;
|
||||
lastY=circuit[lastIndex-1]->wY;
|
||||
lastZ=circuit[lastIndex-1]->wZ+SEGMENT_LENGTH;
|
||||
}
|
||||
|
||||
srand( rtc_ticks() );
|
||||
|
||||
for( int i=0; i<l; i++)
|
||||
|
@ -263,10 +269,10 @@ void addCurve( Length l, CurveStrength s, CurveType t, int8_t biome )
|
|||
|
||||
Segment *seg;
|
||||
|
||||
if (deco==0) seg=new Segment( 0, lastY, lastZ+(i+1)*SEGMENT_LENGTH, s*t, -1, -1 );
|
||||
else if (deco==1) seg=new Segment( 0, lastY, lastZ+(i+1)*SEGMENT_LENGTH, s*t, -1, OAKTREE );
|
||||
else if (deco==2) seg=new Segment( 0, lastY, lastZ+(i+1)*SEGMENT_LENGTH, s*t, DEADTREE, -1 );
|
||||
else if (deco==3) seg=new Segment( 0, lastY, lastZ+(i+1)*SEGMENT_LENGTH, s*t, DEADTREE, OAKTREE );
|
||||
if (deco==0) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, -1, -1 );
|
||||
else if (deco==1) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, -1, OAKTREE );
|
||||
else if (deco==2) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, DEADTREE, -1 );
|
||||
else if (deco==3) seg=new Segment( 0, lastY, lastZ+i*SEGMENT_LENGTH, s*t, DEADTREE, OAKTREE );
|
||||
|
||||
if (seg!=nullptr)
|
||||
{
|
||||
|
@ -282,11 +288,13 @@ void addHill( Length l, HillSize s, HillType t, int8_t biome )
|
|||
double lastZ=0;
|
||||
int16_t lastY=0;
|
||||
|
||||
if (circuit.size()!=0)
|
||||
uint16_t lastIndex = circuit.size();
|
||||
if (lastIndex!=0)
|
||||
{
|
||||
lastY=circuit[circuit.size()-1]->wY;
|
||||
lastZ=circuit[circuit.size()-1]->wZ;
|
||||
lastY=circuit[lastIndex-1]->wY;
|
||||
lastZ=circuit[lastIndex-1]->wZ+SEGMENT_LENGTH;
|
||||
}
|
||||
|
||||
srand( rtc_ticks() );
|
||||
|
||||
for( int i=0; i<l; i++)
|
||||
|
@ -295,10 +303,10 @@ void addHill( Length l, HillSize s, HillType t, int8_t biome )
|
|||
int deco = rand() % 4;
|
||||
Segment *seg;
|
||||
|
||||
if (deco==0) seg=new Segment( 0, lastY+(i+1)*t*s, lastZ+(i+1)*SEGMENT_LENGTH, 0, -1, -1 );
|
||||
else if (deco==1) seg=new Segment( 0, lastY+(i+1)*t*s, lastZ+(i+1)*SEGMENT_LENGTH, 0, -1, PALMTREE );
|
||||
else if (deco==2) seg=new Segment( 0, lastY+(i+1)*t*s, lastZ+(i+1)*SEGMENT_LENGTH, 0, OAKTREE, -1 );
|
||||
else if (deco==3) seg=new Segment( 0, lastY+(i+1)*t*s, lastZ+(i+1)*SEGMENT_LENGTH, 0, OAKTREE, PALMTREE );
|
||||
if (deco==0) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, -1, -1 );
|
||||
else if (deco==1) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, -1, PALMTREE );
|
||||
else if (deco==2) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, OAKTREE, -1 );
|
||||
else if (deco==3) seg=new Segment( 0, lastY+i*t*s, lastZ+i*SEGMENT_LENGTH, 0, OAKTREE, PALMTREE );
|
||||
|
||||
if (seg!=nullptr)
|
||||
{
|
||||
|
@ -353,6 +361,26 @@ void drawCircuitSegment( uint16_t index )
|
|||
|
||||
if (Y1==Y2) return;
|
||||
|
||||
/*
|
||||
if (index==0)
|
||||
{
|
||||
drawPolygon( 0, X2-W2/16-W2+currentcurve, Y2, 0, X1-W1/16-W1+currentcurve, Y1, DARK_GREEN_GRASS );
|
||||
|
||||
drawPolygon( X2-W2+currentcurve, X2+W2+currentcurve, Y2, X1-W1+currentcurve, X1+W1+currentcurve, Y1, C_RED );
|
||||
|
||||
drawPolygon( X2-W2/16-W2+currentcurve, X2-W2+currentcurve, Y2, X1-W1/16-W1+currentcurve, X1-W1+currentcurve, Y1, WHITE_STRIPE );
|
||||
drawPolygon( X2-W2/50+currentcurve, X2+W2/50+currentcurve, Y2, X1-W1/50+currentcurve, X1+W1/50+currentcurve, Y1, WHITE_STRIPE );
|
||||
drawPolygon( X2-W2/50-W2/2+currentcurve, X2+W2/50-W2/2+currentcurve, Y2, X1-W1/50-W1/2+currentcurve, X1+W1/50-W1/2+currentcurve, Y1, WHITE_STRIPE );
|
||||
drawPolygon( X2-W2/50+currentcurve, X2+W2/50+currentcurve, Y2, X1-W1/50+currentcurve, X1+W1/50+currentcurve, Y1, WHITE_STRIPE );
|
||||
drawPolygon( X2-W2/50+W2/2+currentcurve, X2+W2/50+W2/2+currentcurve, Y2, X1-W1/50+W1/2+currentcurve, X1+W1/50+W1/2+currentcurve, Y1, WHITE_STRIPE );
|
||||
drawPolygon( X2+W2+currentcurve, X2+W2+W2/16+currentcurve, Y2, X1+W1+currentcurve, X1+W1+W1/16+currentcurve, Y1, WHITE_STRIPE );
|
||||
|
||||
drawPolygon( X2+W2/16+W2+currentcurve, 396, Y2, X1+W1/16+W1+currentcurve, 396, Y1, DARK_GREEN_GRASS );
|
||||
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
if (circuit[index]->environment == PLAINS)
|
||||
{
|
||||
if (index%2==0)
|
||||
|
@ -457,7 +485,7 @@ fixed_t interpolatePositionY( double currentZ )
|
|||
|
||||
uint16_t findIndex( double currentZ )
|
||||
{
|
||||
return (int) (currentZ / SEGMENT_LENGTH);
|
||||
return (uint16_t) (currentZ / SEGMENT_LENGTH);
|
||||
}
|
||||
|
||||
|
||||
|
@ -465,16 +493,19 @@ void prepareDecoration( void )
|
|||
{
|
||||
bopti_image_t const *src;
|
||||
|
||||
for( int k=0; k<3; k++)
|
||||
for( int k=0; k<NB_TREES_TYPES; k++)
|
||||
{
|
||||
float scale=1.0f;
|
||||
for( int i=0; i<25; i++)
|
||||
for( int i=0; i<MAX_SUBIMAGES_TREES; i++)
|
||||
{
|
||||
scale=2.0f/((float) (i+1));
|
||||
|
||||
if(k==0) src = &tree1;
|
||||
else if(k==1) src = &tree2;
|
||||
else if(k==2) src = &tree3;
|
||||
else if(k==3) src = &tree4;
|
||||
else if(k==4) src = &tree5;
|
||||
else src = &tree6;
|
||||
|
||||
int width = (int) ((float) src->width * scale);
|
||||
int height = (int) ((float) src->height * scale);
|
||||
|
@ -487,27 +518,25 @@ void prepareTraffic( void )
|
|||
{
|
||||
bopti_image_t const *src;
|
||||
|
||||
for( int k=0; k<3; k++)
|
||||
for( int k=0; k<NB_CARS_TYPES; k++)
|
||||
{
|
||||
float scale=1.0f;
|
||||
for( int i=0; i<25; i++)
|
||||
for( int i=0; i<MAX_SUBIMAGES_CARS; i++)
|
||||
{
|
||||
//scale=1.0f/((float) (i+1));
|
||||
if(k==0) src = &car1;
|
||||
else if(k==1) src = &car2;
|
||||
else if(k==2) src = &car3;
|
||||
/*
|
||||
else if(k==3) src = &car4;
|
||||
else if(k==4) src = &car5;
|
||||
else if(k==5) src = &car6;
|
||||
else if(k==6) src = &car7;
|
||||
else if(k==7) src = &car8;
|
||||
*/
|
||||
else if(k==3) src = &car4;
|
||||
else if(k==4) src = &car5;
|
||||
else if(k==5) src = &car6;
|
||||
else if(k==6) src = &car7;
|
||||
else src = &car8;
|
||||
|
||||
int width = (int) ((float) src->width * scale);
|
||||
int height = (int) ((float) src->height * scale);
|
||||
scaledCars[k][i] = resize(src, width, height);
|
||||
scale*=0.85;
|
||||
scale*=0.82;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -515,16 +544,16 @@ void prepareTraffic( void )
|
|||
|
||||
void freeDecoration( void )
|
||||
{
|
||||
for( int k=0; k<3; k++)
|
||||
for( int i=0; i<25; i++)
|
||||
for( int k=0; k<NB_TREES_TYPES; k++)
|
||||
for( int i=0; i<MAX_SUBIMAGES_TREES; i++)
|
||||
free(scaledTrees[k][i]);
|
||||
}
|
||||
|
||||
|
||||
void freeTraffic( void )
|
||||
{
|
||||
for( int k=0; k<3; k++)
|
||||
for( int i=0; i<25; i++)
|
||||
for( int k=0; k<NB_CARS_TYPES; k++)
|
||||
for( int i=0; i<MAX_SUBIMAGES_CARS; i++)
|
||||
free(scaledTrees[k][i]);
|
||||
}
|
||||
|
||||
|
@ -536,7 +565,7 @@ void drawDecoration( uint16_t index )
|
|||
int distance = fround(fdiv( (fixdouble(circuit[index]->wZ) - cam->cZ), fix(SEGMENT_LENGTH) )) - 1;
|
||||
|
||||
if (distance<0) distance = 0;
|
||||
else if (distance>24) distance = 24;
|
||||
else if (distance>(MAX_SUBIMAGES_TREES-1)) distance = (MAX_SUBIMAGES_TREES-1);
|
||||
|
||||
circuit[index]->DScale = distance;
|
||||
|
||||
|
@ -566,12 +595,10 @@ void drawDecoration( uint16_t index )
|
|||
}
|
||||
|
||||
|
||||
void updateTraffic( void )
|
||||
void updateTraffic( float dt )
|
||||
{
|
||||
for(int k=0; k<traffic.size(); k++)
|
||||
{
|
||||
//traffic[k]->wX += traffic[k]->Speed*dt;
|
||||
}
|
||||
traffic[k]->wZ += traffic[k]->Speed*dt;
|
||||
}
|
||||
|
||||
|
||||
|
@ -579,25 +606,16 @@ void drawTraffic( uint16_t index )
|
|||
{
|
||||
bopti_image_t *image;
|
||||
|
||||
int distance = fround(fdiv( (fixdouble(traffic[index]->wZ) - cam->cZ), fix(2*SEGMENT_LENGTH) ));
|
||||
int distance = fround(fdiv( (fixdouble(traffic[index]->wZ) - cam->cZ), fix(SEGMENT_LENGTH/2) ))-2;
|
||||
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;
|
||||
|
||||
if (distance<0) distance = 0;
|
||||
else if (distance>24) distance = 24;
|
||||
|
||||
traffic[index]->DScale = distance;
|
||||
|
||||
image = scaledCars[traffic[index]->Type][distance];
|
||||
|
||||
/*
|
||||
int X = circuit[segnumber]->X + circuit[segnumber]->CumulatedCurve + traffic[index]->wX*circuit[segnumber]->W - image->width/2;
|
||||
int Y = circuit[segnumber]->Y - image->height;
|
||||
|
||||
traffic[index]->X = X;
|
||||
traffic[index]->Y = Y;
|
||||
*/
|
||||
int X = traffic[index]->X - image->width/2;
|
||||
int Y = traffic[index]->Y - image->height;
|
||||
|
||||
|
@ -613,7 +631,7 @@ void drawClouds( int offset )
|
|||
{
|
||||
if (nuages[k]->Type==0) cloud=&sky1;
|
||||
else if (nuages[k]->Type==1) cloud=&sky2;
|
||||
else if (nuages[k]->Type==2) cloud=&sky3;
|
||||
else cloud=&sky3;
|
||||
|
||||
nuages[k]->X--;
|
||||
|
||||
|
@ -624,3 +642,40 @@ void drawClouds( int offset )
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
void drawFarBackground( int offset )
|
||||
{
|
||||
int X = offset;
|
||||
int DX = mountain.width;
|
||||
|
||||
while (X>0)
|
||||
{
|
||||
X-=DX;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (X>-1*DX) dimage(X, 60, &mountain);
|
||||
X+=DX;
|
||||
}
|
||||
while(X<SCREEN_WIDTH+DX);
|
||||
}
|
||||
|
||||
|
||||
void drawNearBackground( int offset )
|
||||
{
|
||||
int X = offset;
|
||||
int DX = treeline.width;
|
||||
|
||||
while (X>0)
|
||||
{
|
||||
X-=DX;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
if (X>-1*DX) dimage(X, 95, &treeline);
|
||||
X+=DX;
|
||||
}
|
||||
while(X<SCREEN_WIDTH+DX);
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ void drawSky( void )
|
|||
|
||||
void drawSky( uint16_t color )
|
||||
{
|
||||
dclear( color );
|
||||
dma_memset(gint_vram, (color << 16) | color, 396 * 80 * 2);
|
||||
};
|
||||
|
||||
void drawSkyOptimised( uint16_t color )
|
||||
|
|
|
@ -11,7 +11,7 @@ Segment::Segment( uint16_t n_seg )
|
|||
{
|
||||
wX = 0;
|
||||
wY = 0;
|
||||
wZ = (double) (400.0 + (double) (n_seg * SEGMENT_LENGTH));
|
||||
wZ = (double) (n_seg * SEGMENT_LENGTH);
|
||||
}
|
||||
|
||||
|
||||
|
|