clouds and random decoration

dev
Sylvain PILLOT 7 months ago
parent 97933c64c0
commit b6e00a98f3
  1. 4
      CMakeLists.txt
  2. 2
      CppOutRun.cbp
  3. 41
      CppOutRun.layout
  4. 5
      assets-cg/clouds/fxconv-metadata.txt
  5. BIN
      assets-cg/clouds/sky1.png
  6. BIN
      assets-cg/clouds/sky2.png
  7. BIN
      assets-cg/clouds/sky3.png
  8. 2
      src/include/circuit.h
  9. 27
      src/include/clouds.h
  10. 22
      src/main.cc
  11. 95
      src/src/circuit.cc
  12. 20
      src/src/clouds.cc
  13. 1
      src/src/drawstuff.cc

@ -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)

@ -31,12 +31,14 @@
<Unit filename="src/fixed.h" />
<Unit filename="src/include/camera.h" />
<Unit filename="src/include/circuit.h" />
<Unit filename="src/include/clouds.h" />
<Unit filename="src/include/drawstuff.h" />
<Unit filename="src/include/segment.h" />
<Unit filename="src/main.cc" />
<Unit filename="src/parameters.h" />
<Unit filename="src/src/camera.cc" />
<Unit filename="src/src/circuit.cc" />
<Unit filename="src/src/clouds.cc" />
<Unit filename="src/src/drawstuff.cc" />
<Unit filename="src/src/segment.cc" />
<Extensions>

@ -2,49 +2,49 @@
<CodeBlocks_layout_file>
<FileVersion major="1" minor="0" />
<ActiveTarget name="Release" />
<File name="src/src/drawstuff.cc" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/include/circuit.h" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="953" topLine="0" />
<Cursor1 position="516" topLine="11" />
</Cursor>
</File>
<File name="src/fixed.h" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="CMakeLists.txt" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="778" topLine="0" />
<Cursor1 position="1219" 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">
<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="124" topLine="0" />
<Cursor1 position="189" topLine="0" />
</Cursor>
</File>
<File name="src/main.cc" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="1" zoom_2="0">
<Cursor>
<Cursor1 position="5347" topLine="41" />
<Cursor1 position="3302" topLine="245" />
</Cursor>
</File>
<File name="src/src/circuit.cc" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/segment.cc" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="2" zoom_2="0">
<Cursor>
<Cursor1 position="1889" topLine="75" />
<Cursor1 position="368" topLine="12" />
</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">
<File name="src/include/drawstuff.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="189" topLine="0" />
<Cursor1 position="354" topLine="0" />
</Cursor>
</File>
<File name="CMakeLists.txt" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/drawstuff.cc" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="1219" topLine="4" />
<Cursor1 position="953" topLine="0" />
</Cursor>
</File>
<File name="src/include/drawstuff.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="src/src/circuit.cc" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="354" topLine="0" />
<Cursor1 position="3642" topLine="127" />
</Cursor>
</File>
<File name="src/src/segment.cc" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="2" 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="158" topLine="0" />
<Cursor1 position="124" 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">
@ -52,9 +52,14 @@
<Cursor1 position="221" topLine="0" />
</Cursor>
</File>
<File name="src/fixed.h" open="1" 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="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="325" topLine="0" />
<Cursor1 position="765" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>

@ -0,0 +1,5 @@
*.png:
type: bopti-image
profile: p4
name_regex: (.*)\.png \1

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 770 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 668 B

@ -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 );

@ -0,0 +1,27 @@
#ifndef CLOUDS_H
#define CLOUDS_H
#include <stdint.h>
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

@ -12,7 +12,6 @@
#include <math.h>
#include <vector>
#include <array>
#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<Segment*> circuit;
int MAX_SEGMENT=0;
camera *cam;
std::vector<Clouds*> 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; 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 );
}
}
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();

@ -1,13 +1,18 @@
#include "../include/circuit.h"
#include "../include/segment.h"
#include "../include/camera.h"
#include "../include/clouds.h"
#include "../parameters.h"
#include <gint/display.h>
#include <gint/std/stdlib.h>
#include <gint/rtc.h>
#include "../include/drawstuff.h"
extern std::vector<Segment*> circuit;
extern std::vector<Clouds*> 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_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_LONG );
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; i<l; i++)
{
//Segment *s=new Segment( i );
Segment *seg=new Segment( 0, lastY, lastZ + (i+1)*SEGMENT_LENGTH, 0, PALMTREE, DEADTREE );
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 (seg!=nullptr) circuit.push_back( seg );
}
}
@ -174,11 +226,20 @@ void addCurve( Length l, CurveStrength s, CurveType t )
lastY=circuit[circuit.size()-1]->wY;
lastZ=circuit[circuit.size()-1]->wZ;
}
srand( rtc_ticks() );
for( int i=0; i<l; i++)
{
//Segment *s=new Segment( i );
Segment *seg=new Segment( 0, lastY, lastZ+(i+1)*SEGMENT_LENGTH, s*t, DEADTREE, OAKTREE );
int deco = rand() % 4;
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 (seg!=nullptr) circuit.push_back( seg );
}
}
@ -194,11 +255,19 @@ void addHill( Length l, HillSize s, HillType t )
lastY=circuit[circuit.size()-1]->wY;
lastZ=circuit[circuit.size()-1]->wZ;
}
srand( rtc_ticks() );
for( int i=0; i<l; i++)
{
//Segment *s=new Segment( i );
Segment *seg=new Segment( 0, lastY+(i+1)*t*s, lastZ+(i+1)*SEGMENT_LENGTH, 0, OAKTREE, PALMTREE );
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 (seg!=nullptr) circuit.push_back( seg );
}
}
@ -343,6 +412,7 @@ void prepareDecoration( void )
float scale=1.0f;
for( int i=0; i<25; i++)
{
scale=2.0f/((float) (i+1));
if(k==0) src = &tree1;
else if(k==1) src = &tree2;
else if(k==2) src = &tree3;
@ -350,7 +420,7 @@ void prepareDecoration( void )
int width = (int) ((float) src->width * 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; k<nuages.size(); k++ )
{
if (nuages[k]->type==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 );
}
}

@ -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;
}

@ -74,3 +74,4 @@ void drawSky( int ymin, int ymax )
for(int y=ymin; y<=ymax; y++ )
gint_dhline( 0, SCREEN_WIDTH, y, color );
};

Loading…
Cancel
Save