changed billboards position + added failsequence + bugs corrections

This commit is contained in:
Sylvain PILLOT 2022-03-23 21:35:29 +01:00
parent 7dfdd67588
commit 7c88c99cfd
6 changed files with 253 additions and 123 deletions

View File

@ -2,9 +2,48 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Release" />
<File name="src/src/drawstuff.cc" open="1" top="1" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/fixed.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2487" topLine="20" />
<Cursor1 position="5" 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="2421" topLine="36" />
</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">
<Cursor>
<Cursor1 position="332" 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">
<Cursor>
<Cursor1 position="251" topLine="0" />
</Cursor>
</File>
<File name="src/src/circuit.cc" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="16984" topLine="496" />
</Cursor>
<Folding>
<Collapse line="501" />
<Collapse line="517" />
<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="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="2487" topLine="18" />
</Cursor>
<Folding>
<Collapse line="9" />
@ -15,29 +54,9 @@
<Collapse line="126" />
</Folding>
</File>
<File name="src/src/camera.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/segment.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<Cursor>
<Cursor1 position="370" 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="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/main.cc" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="16109" topLine="579" />
</Cursor>
</File>
<File name="src/include/menus.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="328" topLine="0" />
<Cursor1 position="230" topLine="30" />
</Cursor>
</File>
<File name="src/include/circuit.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -45,65 +64,34 @@
<Cursor1 position="1291" topLine="57" />
</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="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="332" 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/drawstuff.h" open="0" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/clouds.cc" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="637" topLine="0" />
<Cursor1 position="203" topLine="0" />
</Cursor>
</File>
<File name="src/colors.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/main.cc" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="35" topLine="0" />
<Cursor1 position="15719" topLine="607" />
</Cursor>
</File>
<File name="CMakeLists.txt" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/camera.h" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2715" topLine="65" />
<Cursor1 position="221" topLine="0" />
</Cursor>
</File>
<File name="src/include/clouds.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/camera.cc" open="0" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="306" topLine="0" />
<Cursor1 position="370" topLine="0" />
</Cursor>
</File>
<File name="src/src/circuit.cc" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/menus.cc" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="16878" topLine="925" />
</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/fixed.h" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="778" topLine="0" />
</Cursor>
</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" />
<Cursor1 position="20917" topLine="638" />
</Cursor>
</File>
<File name="src/parameters.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -111,26 +99,24 @@
<Cursor1 position="559" topLine="0" />
</Cursor>
</File>
<File name="src/src/menus.cc" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/menus.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="16293" topLine="115" />
<Cursor1 position="390" topLine="0" />
</Cursor>
<Folding>
<Collapse line="39" />
<Collapse line="77" />
<Collapse line="103" />
<Collapse line="164" />
<Collapse line="200" />
<Collapse line="212" />
<Collapse line="337" />
<Collapse line="349" />
<Collapse line="391" />
<Collapse line="462" />
</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">
<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="230" topLine="30" />
<Cursor1 position="637" 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/colors.h" open="0" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="35" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>

View File

@ -1,5 +1,5 @@
//---
// fixed: 16:16 fixed-point arithmetic
// fixed: 48:16 fixed-point arithmetic
//---
#pragma once
#include <stdint.h>

View File

@ -37,7 +37,7 @@ class Segment
void Project3DFP( camera* c );
int8_t Environment = PLAINS;
int8_t Special = 0;
int8_t Special = -1;
bool CheckValidated = false;
int8_t Curve=0;

View File

@ -416,11 +416,11 @@ int main(void)
do
{
/*
_uram_stats = kmalloc_get_gint_stats(_uram);
sprintf( texttosend, "[Begining of loop] Memory Status - Used: %d - Free: %d - Peak Used: %d", _uram_stats->used_memory, _uram_stats->free_memory, _uram_stats->peak_used_memory);
usb_fxlink_text(texttosend, 0);
*/
/*
_uram_stats = kmalloc_get_gint_stats(_uram);
sprintf( texttosend, "[Begining of loop] Memory Status - Used: %d - Free: %d - Peak Used: %d", _uram_stats->used_memory, _uram_stats->free_memory, _uram_stats->peak_used_memory);
usb_fxlink_text(texttosend, 0);
*/
// Try to restart from very begining
initEverything();
@ -489,22 +489,22 @@ int main(void)
perf_create = prof_make();
prof_enter(perf_create);
initData( ); // Positioning of the Camera
initData( ); // Positioning of the Camera
createCircuit( selectedCircuit ); // Creates the circuit
createCircuit( selectedCircuit ); // Creates the circuit
MAX_SEGMENT = circuit.size();
uint32_t maxDistance = (MAX_SEGMENT-nbInterestingSegments-5)*SEGMENT_LENGTH;
MAX_SEGMENT = circuit.size();
uint32_t maxDistance = (MAX_SEGMENT-nbInterestingSegments-5)*SEGMENT_LENGTH;
putBillBoards();
putBillBoards();
createClouds(); // Creates the Sky and Clouds
createClouds(); // Creates the Sky and Clouds
createTraffic( MAX_SEGMENT ); // Creates the cars
createTraffic( MAX_SEGMENT ); // Creates the cars
prepareDecoration( CurrentCircuitBiome ); // Prepares the multiple variations of Decoration (image scaling)
prepareDecoration( CurrentCircuitBiome ); // Prepares the multiple variations of Decoration (image scaling)
prepareTraffic(); // Prepares the multiple variations of Cars (image scaling)
prepareTraffic(); // Prepares the multiple variations of Cars (image scaling)
@ -583,6 +583,7 @@ int main(void)
perf_project = prof_make();
prof_enter(perf_project);
minYRoad = SCREEN_HEIGHT;
if (BDrawCars)
{
@ -599,14 +600,10 @@ int main(void)
//else
//traffic[k]->visible = false;
}
}
minYRoad = SCREEN_HEIGHT;
float roadpart = f2float(cam->cX)/(float) ROAD_WIDTH;
float roadpart = f2float(cam->cX)/(float) ROAD_WIDTH;
// Update car positions : car with higher speed change line not to collide with player
if (BDrawCars)
// Update car positions : car with higher speed change line not to collide with player
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];
@ -618,8 +615,6 @@ int main(void)
}
}
if (BDrawCars)
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];
@ -629,15 +624,16 @@ int main(void)
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 (k!= indexend && circuit[k]->Y < minYRoad) // This is a trick to save precious time while drawing the Sky
minYRoad = circuit[k]->Y;
//if (k!= indexend && circuit[k]->Y < minYRoad) // This is a trick to save precious time while drawing the Sky
if (circuit[k]->Y <= minYRoad) minYRoad = circuit[k]->Y;
circuit[k]->CumulatedCurve = cumulCurve; // This is the curve accumulated when we are drawing curves
cumulCurve += circuit[k]->Curve;
@ -660,8 +656,10 @@ int main(void)
prof_enter(perf_render);
if (BDrawBack) drawSkyOptimised( DAY_BLUE_SKY );
else drawSkyFull( DAY_BLUE_SKY );
//if (BDrawBack) drawSkyOptimised( DAY_BLUE_SKY );
//else drawSkyFull( DAY_BLUE_SKY );
drawSkyOptimised( DAY_BLUE_SKY );
if (BDrawClds)
@ -697,11 +695,30 @@ int main(void)
if (BDrawCars) circuit[k]->CarList.clear();
}
if (circuit[indexstart]->Special == CHECKPOINT && circuit[indexstart]->CheckValidated == false)
{
start_time+=60000000;
circuit[indexstart]->CheckValidated = true;
}
else if (circuit[indexstart]->Special == FINISH && circuit[indexstart]->CheckValidated == false)
{
start_time+=60000000;
circuit[indexstart]->CheckValidated = true;
}
else if (circuit[indexstart]->Special == START && circuit[indexstart]->CheckValidated == false)
{
start_time=99000000;
circuit[indexstart]->CheckValidated = true;
}
// Draw a message when time is over
if (start_time<=0)
{
failSequence=true;
}
int mod_base=20;
int mod_comp=10;
@ -778,6 +795,22 @@ int main(void)
else dsubimage( 48, 25, &speedhud, 0, 104, 76, 13, DIMAGE_NONE);
if (failSequence)
{
dimage( 198-bigflag.width/2, 112-bigflag.height/2, &bigflag );
dfont(&startseq);
dprint_opt(200,108, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, "YOU" );
dprint_opt(198,112, C_RGB(255,0,255), C_NONE, DTEXT_CENTER, DTEXT_BOTTOM, "YOU" );
dprint_opt(200,108, C_RGB(0,0,0), C_NONE, DTEXT_CENTER, DTEXT_TOP, "LOOSE" );
dprint_opt(198,112, C_RGB(255,0,255), C_NONE, DTEXT_CENTER, DTEXT_TOP, "LOOSE" );
}
if (initiateStart) // We are in the start sequence with the countdown
{
dfont(&startseq);
@ -808,7 +841,7 @@ int main(void)
}
else if (startRemaining<4 && startRemaining>-4)
{
dimage( 198-bigflag.width/2, 112-bigflag.height/2, &bigflag );
dimage( 198-bigflag.width/2, 112-bigflag.height/2, &bigflag );
}
else if (startRemaining<-4)
{
@ -884,6 +917,12 @@ int main(void)
l++;
}
/*
_uram_stats = kmalloc_get_gint_stats(_uram);
sprintf( texttosend, "Memory Status - Used: %d - Free: %d - Peak Used: %d", _uram_stats->used_memory, _uram_stats->free_memory, _uram_stats->peak_used_memory);
usb_fxlink_text(texttosend, 0);
*/
// Free all memory
freeTraffic();

View File

@ -433,11 +433,12 @@ void createCircuit( int circuitNumber )
void putBillBoards( void )
{
for (unsigned int k = 0; k<circuit.size()-3; k++ )
for (unsigned int k = 0; k<circuit.size()-7; k++ )
{
int nextcurve = circuit[k+3]->Curve;
int nextcurve = circuit[k+7]->Curve;
int currentcurve = circuit[k]->Curve;
int nextslope = circuit[k+3]->Slope;
int nextslope = circuit[k+7]->Slope;
int currentslope = circuit[k]->Slope;
if (nextcurve==currentcurve && nextslope==currentslope)
@ -451,12 +452,37 @@ void putBillBoards( void )
{
circuit[k]->RDeco=UPHILL;
circuit[k]->LDeco=UPHILL;
circuit[k+1]->RDeco=UPHILL;
circuit[k+1]->LDeco=UPHILL;
circuit[k+2]->RDeco=UPHILL;
circuit[k+2]->LDeco=UPHILL;
circuit[k+4]->RDeco=UPHILL;
circuit[k+4]->LDeco=UPHILL;
circuit[k+6]->RDeco=UPHILL;
circuit[k+6]->LDeco=UPHILL;
}
else if (nextslope<0) //downhill
{
circuit[k]->RDeco=DOWNHILL;
circuit[k]->LDeco=DOWNHILL;
circuit[k+1]->RDeco=DOWNHILL;
circuit[k+1]->LDeco=DOWNHILL;
circuit[k+2]->RDeco=DOWNHILL;
circuit[k+2]->LDeco=DOWNHILL;
circuit[k+4]->RDeco=DOWNHILL;
circuit[k+4]->LDeco=DOWNHILL;
circuit[k+6]->RDeco=DOWNHILL;
circuit[k+6]->LDeco=DOWNHILL;
}
k+=7;
}
else if (nextcurve!=currentcurve && nextslope==currentslope)
{
@ -465,12 +491,37 @@ void putBillBoards( void )
{
circuit[k]->RDeco=LEFTTURN;
circuit[k]->LDeco=LEFTTURN;
circuit[k+1]->RDeco=LEFTTURN;
circuit[k+1]->LDeco=LEFTTURN;
circuit[k+2]->RDeco=LEFTTURN;
circuit[k+2]->LDeco=LEFTTURN;
circuit[k+4]->RDeco=LEFTTURN;
circuit[k+4]->LDeco=LEFTTURN;
circuit[k+6]->RDeco=LEFTTURN;
circuit[k+6]->LDeco=LEFTTURN;
}
else if (nextcurve>0) //downhill
{
circuit[k]->RDeco=RIGHTTURN;
circuit[k]->LDeco=RIGHTTURN;
circuit[k+1]->RDeco=RIGHTTURN;
circuit[k+1]->LDeco=RIGHTTURN;
circuit[k+2]->RDeco=RIGHTTURN;
circuit[k+2]->LDeco=RIGHTTURN;
circuit[k+4]->RDeco=RIGHTTURN;
circuit[k+4]->LDeco=RIGHTTURN;
circuit[k+6]->RDeco=RIGHTTURN;
circuit[k+6]->LDeco=RIGHTTURN;
}
k+=7;
}
else if (nextcurve!=currentcurve && nextslope!=currentslope)
{
@ -478,20 +529,74 @@ void putBillBoards( void )
if (nextcurve<0) //uphill
{
circuit[k]->RDeco=LEFTTURN;
if (nextslope>0) circuit[k]->LDeco=UPHILL;
else if (nextslope<0) circuit[k]->LDeco=DOWNHILL;
circuit[k+1]->RDeco=LEFTTURN;
circuit[k+2]->RDeco=LEFTTURN;
circuit[k+4]->RDeco=LEFTTURN;
circuit[k+6]->RDeco=LEFTTURN;
if (nextslope>0)
{
circuit[k]->LDeco=UPHILL;
circuit[k+1]->LDeco=UPHILL;
circuit[k+2]->LDeco=UPHILL;
circuit[k+4]->LDeco=UPHILL;
circuit[k+6]->LDeco=UPHILL;
}
else if (nextslope<0)
{
circuit[k]->LDeco=DOWNHILL;
circuit[k+1]->LDeco=DOWNHILL;
circuit[k+2]->LDeco=DOWNHILL;
circuit[k+4]->LDeco=DOWNHILL;
circuit[k+6]->LDeco=DOWNHILL;
}
k+=7;
}
else if (nextcurve>0) //downhill
{
circuit[k]->LDeco=RIGHTTURN;
if (nextslope>0) circuit[k]->RDeco=UPHILL;
else if (nextslope<0) circuit[k]->RDeco=DOWNHILL;
circuit[k+1]->LDeco=RIGHTTURN;
circuit[k+2]->LDeco=RIGHTTURN;
circuit[k+4]->LDeco=RIGHTTURN;
circuit[k+6]->LDeco=RIGHTTURN;
if (nextslope>0)
{
circuit[k]->RDeco=UPHILL;
circuit[k+1]->RDeco=UPHILL;
circuit[k+2]->RDeco=UPHILL;
circuit[k+4]->RDeco=UPHILL;
circuit[k+6]->RDeco=UPHILL;
}
else if (nextslope<0)
{
circuit[k]->RDeco=DOWNHILL;
circuit[k+1]->RDeco=DOWNHILL;
circuit[k+2]->RDeco=DOWNHILL;
circuit[k+4]->RDeco=DOWNHILL;
circuit[k+6]->RDeco=DOWNHILL;
}
k+=7;
}
}
if (nextcurve<0 && currentcurve!=nextcurve) circuit[k]->RDeco=LEFTTURN;
if (nextcurve>0 && currentcurve!=nextcurve) circuit[k]->LDeco=RIGHTTURN;
else if (nextcurve<0 && currentcurve!=nextcurve)
{
circuit[k]->RDeco=LEFTTURN;
circuit[k+1]->RDeco=LEFTTURN;
circuit[k+2]->RDeco=LEFTTURN;
circuit[k+4]->RDeco=LEFTTURN;
circuit[k+6]->RDeco=LEFTTURN;
k+=7;
}
else if (nextcurve>0 && currentcurve!=nextcurve)
{
circuit[k]->LDeco=RIGHTTURN;
circuit[k+1]->LDeco=RIGHTTURN;
circuit[k+2]->LDeco=RIGHTTURN;
circuit[k+4]->LDeco=RIGHTTURN;
circuit[k+6]->LDeco=RIGHTTURN;
k+=7;
}
}
}

View File

@ -114,7 +114,7 @@ void drawSky( uint16_t color )
void drawSkyOptimised( uint16_t color )
{
dma_memset(gint_vram, (color << 16) | color, 396 * (minYRoad+10) * 2);
dma_memset(gint_vram, (color << 16) | color, 396 * (minYRoad+2) * 2);
};
void drawSky( uint8_t R, uint8_t G, uint8_t B )