From b6e00a98f343628c4fa496c595f282faf1993905 Mon Sep 17 00:00:00 2001 From: Slyvtt Date: Mon, 7 Mar 2022 15:24:04 +0100 Subject: [PATCH] clouds and random decoration --- CMakeLists.txt | 4 ++ CppOutRun.cbp | 2 + CppOutRun.layout | 53 ++++++++------- assets-cg/clouds/fxconv-metadata.txt | 5 ++ assets-cg/clouds/sky1.png | Bin 0 -> 1470 bytes assets-cg/clouds/sky2.png | Bin 0 -> 770 bytes assets-cg/clouds/sky3.png | Bin 0 -> 668 bytes src/include/circuit.h | 2 + src/include/clouds.h | 27 ++++++++ src/main.cc | 22 +++++-- src/src/circuit.cc | 95 +++++++++++++++++++++++++-- src/src/clouds.cc | 20 ++++++ src/src/drawstuff.cc | 1 + 13 files changed, 196 insertions(+), 35 deletions(-) create mode 100644 assets-cg/clouds/fxconv-metadata.txt create mode 100755 assets-cg/clouds/sky1.png create mode 100755 assets-cg/clouds/sky2.png create mode 100755 assets-cg/clouds/sky3.png create mode 100644 src/include/clouds.h create mode 100644 src/src/clouds.cc diff --git a/CMakeLists.txt b/CMakeLists.txt index c4a6318..840f4d8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,6 +15,7 @@ set(SOURCES src/src/camera.cc src/src/circuit.cc src/src/drawstuff.cc + src/src/clouds.cc # ... ) @@ -31,6 +32,9 @@ set(ASSETS_cg assets-cg/trees/tree2.png assets-cg/trees/tree3.png assets-cg/player/player.png + assets-cg/clouds/sky1.png + assets-cg/clouds/sky2.png + assets-cg/clouds/sky3.png ) fxconv_declare_assets(${ASSETS_cg} WITH_METADATA) diff --git a/CppOutRun.cbp b/CppOutRun.cbp index 259bbe9..70e132b 100644 --- a/CppOutRun.cbp +++ b/CppOutRun.cbp @@ -31,12 +31,14 @@ + + diff --git a/CppOutRun.layout b/CppOutRun.layout index c7a55ba..ad57dc2 100644 --- a/CppOutRun.layout +++ b/CppOutRun.layout @@ -2,29 +2,14 @@ - + - + - + - - - - - - - - - - - - - - - - + @@ -32,9 +17,14 @@ - + - + + + + + + @@ -42,9 +32,19 @@ - + - + + + + + + + + + + + @@ -52,9 +52,14 @@ + + + + + - + diff --git a/assets-cg/clouds/fxconv-metadata.txt b/assets-cg/clouds/fxconv-metadata.txt new file mode 100644 index 0000000..7e05b58 --- /dev/null +++ b/assets-cg/clouds/fxconv-metadata.txt @@ -0,0 +1,5 @@ +*.png: + type: bopti-image + profile: p4 + name_regex: (.*)\.png \1 + diff --git a/assets-cg/clouds/sky1.png b/assets-cg/clouds/sky1.png new file mode 100755 index 0000000000000000000000000000000000000000..3228d27ce188c2802df41efd454d9284c51d0479 GIT binary patch literal 1470 zcmV;v1ws0WP)EX>4Tx04R}tkv&MmKpe$iQzfDm2Rn#3WT;LSL`4J_sbUcmC8V-bHzq|G7U$ubQ_Q5RiyxnPJ+*>%>!= zw!wLyILu12N_&ouk{0cf3aqg_*M)Bpeg24YJ`L;(K){{a7>y{D4^000SaNLh0L z01FcU01FcV0GgZ_00007bV*G`2j&9@3_CX>@2HM@dakSAh-}000A(NklN@Zt9O;Re5{WufQTyJawT;cQL4A7MLO9`Jd0t3KN zpF!Xzn2PvoEpC!I1CS7Z?V6u60cU{XYh5)f;3o_D{`CCq-QNPajqNUaTl^Gme2g($ zsVopHYGcf{u6k1Hy}K;cZQAuY*^T^Et~{{;$c^SbLU0>R{JY?H(Nhus>-FU=Nhq9A zN>%;RfJ-32C`awFYgwM#)pw<42`J(25cHA>#K-`&x>6v3wo5PNP*){TZ|Rvb{@?sSVHY#UWx%|bV;cuUxRE5A5*BUX8{JFlaj~=!EUB`s&y~`MtVUvFm|uhYzYa${6~67rUYr^d<#XR4_yJD`+ge9v-PiJ0paF0-YZBtvlrkdq_5tuu zA&3!w3IH)ch@A4q=Ro&&khL?Ga6;Y_QpXJJye&pw||_*4QB z)VV^=fi3*50SGa=4~~#@9sEX>4Tx04R}tkv&MmKpe$iQzfDm2Rn#3WT;LSL`4J_sbUcmC8V-bHzq|G7U$ubQ_Q5RiyxnPJ+*>%>!= zw!wLyILu12N_&ouk{0cf3aqg_*M)Bpeg24YJ`L;(K){{a7>y{D4^000SaNLh0L z01FcU01FcV0GgZ_00007bV*G`2j&9@3_CX>@2HM@dakSAh-}0002lNkl|Um}nJI8uL^G znAY5@5^}EMeyzq~aANmAa^u8LX{aUP+%rf(Lb}4nHs!=iRb|%^+sJ@)o9-n>V4@y> z$U^gysK@1ce&6|S9}tJM_7n;EX>4Tx04R}tkv&MmKpe$iQzfDm2Rn#3WT;LSL`4J_sbUcmC8V-bHzq|G7U$ubQ_Q5RiyxnPJ+*>%>!= zw!wLyILu12N_&ouk{0cf3aqg_*M)Bpeg24YJ`L;(K){{a7>y{D4^000SaNLh0L z01FcU01FcV0GgZ_00007bV*G`2j&9@3_CX>@2HM@dakSAh-}0001UNklYLAQSxf@#8->aSjd+MpDdSB*k!I0V$5a zPm@%URr?0U&2xb8>jzPB+1{TcN zz{r@85kN4wEyxTJWJ?#!*uY3I3W#wGu>hBa=l}qYxGo-0``*j|0000 CO%)pe literal 0 HcmV?d00001 diff --git a/src/include/circuit.h b/src/include/circuit.h index 4db76b2..752ac86 100644 --- a/src/include/circuit.h +++ b/src/include/circuit.h @@ -45,6 +45,7 @@ enum Decoration void initData( void ); void createCircuit( void ); +void createClouds( void ); void projectCircuitFP( void ); void projectCircuitFP( uint16_t index ); @@ -54,6 +55,7 @@ void printCircuit( int i ); void drawCircuitSegment( uint16_t index ); void drawDecoration( uint16_t index ); +void drawClouds( int offset ); void freeDecoration( void ); void prepareDecoration( void ); diff --git a/src/include/clouds.h b/src/include/clouds.h new file mode 100644 index 0000000..1f8158a --- /dev/null +++ b/src/include/clouds.h @@ -0,0 +1,27 @@ +#ifndef CLOUDS_H +#define CLOUDS_H + +#include + + +enum CloudType +{ + SMALLCLOUD = 0, + MEDIUMCLOUD = 1, + BIGCLOUD = 2 +}; + + +class Clouds +{ + public: + Clouds(); + Clouds( int16_t x, int16_t y, int8_t t ); + ~Clouds(); + + int16_t X; + int16_t Y; + int8_t type; +}; + +#endif // CLOUDS_H diff --git a/src/main.cc b/src/main.cc index 378afdc..09e3fa7 100644 --- a/src/main.cc +++ b/src/main.cc @@ -12,7 +12,6 @@ #include #include -#include #include "include/camera.h" @@ -20,18 +19,20 @@ #include "parameters.h" #include "include/circuit.h" #include "include/drawstuff.h" - +#include "include/clouds.h" extern bopti_image_t car1, car2, car3, car4, car5, car6, car7, car8; extern bopti_image_t tree1, tree2, tree3; extern bopti_image_t player; +extern bopti_image_t sky1, sky2, sky3; std::vector circuit; int MAX_SEGMENT=0; camera *cam; +std::vector nuages; bool stop = false; @@ -158,6 +159,7 @@ int main(void) prof_enter(perf_create); createCircuit(); + createClouds(); prepareDecoration(); prof_leave(perf_create); @@ -217,6 +219,7 @@ int main(void) prof_enter(perf_render); drawSky( ); + drawClouds( l % 396 ); cam->cY = fix( 300 ) + interpolatePositionY(fround(cam->cZ)); @@ -233,7 +236,7 @@ int main(void) { Segment* currentSeg = circuit[indexstart]; - dprint( 1, 1, C_RED, "Cra=%.3D ms", time_create ); + 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 ); @@ -258,7 +261,7 @@ int main(void) } if (ShowDebug2) { - dprint( 1, 1, C_RED, "Cra=%.3D ms", time_create ); + 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 ); @@ -266,12 +269,18 @@ int main(void) { dprint( 100, 1+10*k-indexstart, C_WHITE, "S[%d]=%d", k, circuit[k]->DScale ); } + + for( int k=0; kX, nuages[k]->Y, nuages[k]->type ); + } + } dsubimage( SCREEN_CX-36, SCREEN_HEIGHT-48, &player, 257,1,72,46, DIMAGE_NONE); - //dupdate(); - r61524_display(gint_vram, 0, DHEIGHT, R61524_DMA_WAIT); + dupdate(); + //r61524_display(gint_vram, 0, DHEIGHT, R61524_DMA_WAIT); prof_leave(perf_render); @@ -296,6 +305,7 @@ int main(void) circuit.clear(); + nuages.clear(); delete cam; freeDecoration(); diff --git a/src/src/circuit.cc b/src/src/circuit.cc index 8d34929..7a5fe64 100644 --- a/src/src/circuit.cc +++ b/src/src/circuit.cc @@ -1,13 +1,18 @@ #include "../include/circuit.h" #include "../include/segment.h" #include "../include/camera.h" +#include "../include/clouds.h" #include "../parameters.h" + #include +#include +#include #include "../include/drawstuff.h" extern std::vector circuit; +extern std::vector nuages; extern camera *cam; extern uint16_t currentcurve; extern uint8_t shiftcolor; @@ -17,6 +22,7 @@ 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 sky1, sky2, sky3; bopti_image_t *scaledTrees[3][25] = { 0 }; @@ -140,11 +146,48 @@ void createCircuit( void ) addStraightLine( L_VERYSHORT ); addCurve( L_SHORT, C_EASY, LEFT_CURVE ); addHill( L_MEDIUM, H_BIG, UP_HILL ); + addHill( L_MEDIUM, H_BIG, DOWN_HILL ); addCurve( L_SHORT, C_HARD, RIGHT_CURVE ); - addStraightLine( L_LONG ); + addStraightLine( L_VERYLONG ); + addCurve( L_SHORT, C_HARD, LEFT_CURVE ); + addStraightLine( L_VERYLONG ); + addCurve( L_SHORT, C_EASY, LEFT_CURVE ); + addHill( L_MEDIUM, H_BIG, UP_HILL ); + addHill( L_MEDIUM, H_BIG, DOWN_HILL ); + addCurve( L_SHORT, C_HARD, RIGHT_CURVE ); + addStraightLine( L_VERYLONG ); + addCurve( L_SHORT, C_HARD, LEFT_CURVE ); + addHill( L_MEDIUM, H_BIG, UP_HILL ); + addHill( L_MEDIUM, H_BIG, DOWN_HILL ); + addCurve( L_SHORT, C_HARD, RIGHT_CURVE ); + addStraightLine( L_VERYLONG ); + addCurve( L_SHORT, C_HARD, LEFT_CURVE ); + addStraightLine( L_VERYLONG ); + addCurve( L_SHORT, C_EASY, LEFT_CURVE ); + addHill( L_MEDIUM, H_BIG, UP_HILL ); + addHill( L_MEDIUM, H_BIG, DOWN_HILL ); + addCurve( L_SHORT, C_HARD, RIGHT_CURVE ); + addStraightLine( L_VERYLONG ); + addCurve( L_SHORT, C_HARD, LEFT_CURVE ); }; +void createClouds( void ) +{ + srand( rtc_ticks() ); + + for( int k = 0; k < 10; k++) + { + int X = (rand() % 1188) - 396; + int Y = rand() % 80; + int T = rand() % 3; + + Clouds* cl=new Clouds( X, Y, T ); + if (cl!=nullptr) nuages.push_back( cl ); + } +} + + void addStraightLine( Length l ) { double lastZ=0; @@ -156,10 +199,19 @@ void addStraightLine( Length l ) lastZ=circuit[circuit.size()-1]->wZ; } + srand( rtc_ticks() ); + for( int i=0; iwY; lastZ=circuit[circuit.size()-1]->wZ; } + srand( rtc_ticks() ); for( int i=0; iwY; lastZ=circuit[circuit.size()-1]->wZ; } + srand( rtc_ticks() ); for( int i=0; iwidth * scale); int height = (int) ((float) src->height * scale); scaledTrees[k][i] = resize(src, width, height); - scale*=0.85f; + //scale*=0.85f; } } } @@ -399,3 +469,18 @@ void drawDecoration( uint16_t index ) dimage( X, Y, image ); } } + + +void drawClouds( int offset ) +{ + bopti_image_t *cloud; + + for( int k =0; ktype==0) cloud=&sky1; + else if (nuages[k]->type==1) cloud=&sky2; + else if (nuages[k]->type==2) cloud=&sky3; + + dimage( nuages[k]->X-offset, nuages[k]->Y, cloud ); + } +} diff --git a/src/src/clouds.cc b/src/src/clouds.cc new file mode 100644 index 0000000..e05a1f4 --- /dev/null +++ b/src/src/clouds.cc @@ -0,0 +1,20 @@ +#include "../include/clouds.h" +#include "../parameters.h" + +Clouds::Clouds() +{ + //ctor +} + +Clouds::~Clouds() +{ + //dtor +} + +Clouds::Clouds( int16_t x, int16_t y, int8_t t ) +{ + + X = x; + Y = y; + type = t; +} diff --git a/src/src/drawstuff.cc b/src/src/drawstuff.cc index b553983..c934ba9 100644 --- a/src/src/drawstuff.cc +++ b/src/src/drawstuff.cc @@ -74,3 +74,4 @@ void drawSky( int ymin, int ymax ) for(int y=ymin; y<=ymax; y++ ) gint_dhline( 0, SCREEN_WIDTH, y, color ); }; +