Dusk Rally - an OpenDBC example for the DarkBASIC Professional profile dbproExample
examples/dbpro/demos/dusk_rally/dusk_rally.dba · 1072 lines (938 code)
Three laps of a coastal circuit against three rivals while the sun sets over the sea: headlights and street lamps take over as the light fades. The title screen races on its own until a key is hit. Up/W accelerates, Down/S brakes and reverses, Left/Right or A/D steer, SPACE is the handbrake, C changes the camera, ESC quits. Code and media are part of OpenDBC (MIT code, CC0 media).
How it is built
- Program shape. Frame-driven: a main
do … loopruns every frame undersync on, so the program callssyncitself to present each frame. - Structure. 15 user function(s):
DriveCar,AIInputs,KeepOnTrack,PlaceCar,Shadowed,Clock$,anykey,Wrap(+7 more); 20 GOSUB subroutine(s):simulate,build_circuit,build_world,build_cars,build_minimap,load_sounds,new_race,read_input(+12 more). - Data. 7 array(s) declared with
DIM; constant tables inDATAblocks read withREAD; 1 user-definedTYPE(s). - Assets. Loads 36 media file(s) from the example folder:
textures/detail.jpg,textures/sea.jpg,textures/gloss.jpg,textures/flare.jpg,textures/flare_red.jpg,textures/barrier_bump.jpg(+30 more).
Commands used (137)
View source (1072 lines)
rem ==================================================================
rem Dusk Rally - an OpenDBC example for the DarkBASIC Professional profile
rem Three laps of a coastal circuit against three rivals while the sun
rem sets over the sea: headlights and street lamps take over as the
rem light fades. The title screen races on its own until a key is hit.
rem Up/W accelerates, Down/S brakes and reverses, Left/Right or A/D
rem steer, SPACE is the handbrake, C changes the camera, ESC quits.
rem Code and media are part of OpenDBC (MIT code, CC0 media).
rem ==================================================================
#constant CONTROLS 14
#constant SPS 24
#constant SAMPLES 336
#constant ROAD_HALF 7.0
#constant CURB_OUT 8.6
#constant BARRIER 14.0
#constant LAMP_STEP 12
#constant LAMP_SIDE 16.5
#constant LAMP_REACH 12.5
#constant LAMP_HEIGHT 7.4
#constant LAMPS 28
#constant CARS 4
#constant LAPS 3
#constant DT 0.0166667
#constant MAX_STEPS 4
#constant TOP_SPEED 62.0
#constant SUN_AZIMUTH -35.0
rem Object, image and light numbers
#constant OBJ_SKY 1
#constant OBJ_GROUND 3
#constant OBJ_SEA 4
#constant OBJ_BULBS 5
#constant OBJ_GANTRY 6
#constant OBJ_STAND 7
#constant OBJ_LIGHTHOUSE 8
#constant OBJ_STARTLAMP 10
#constant OBJ_CIRCUIT 20
#constant OBJ_ROAD 21
#constant OBJ_WALL 41First 40 lines shown — 1032 more in examples/dbpro/demos/dusk_rally/dusk_rally.dba.