11-28-2023, 02:27 PM
(This post was last modified: 01-02-2024, 01:35 AM by 1micha.elok.)
Running Dino ( inspired by the Dino in Chrome browser ) in a very very simplified version.
This simplified version is only an animated one.
Here is the structure of the program :
1. Initialization
-load image : ground
-load image : dino
2. Main Program (Looping)
-define ESC key to quit
-moving background
-our main character :-) .... the one and only 'Dino'
It still needs improvement on these features that haven't been implemented yet :
- Animated running dino
- Jump over obstacle / cactus
- Avoid a flying bird
- etc.
You are most welcome if you are interested to improve this very simple 'Running Dino'
It's better to start with a simplified version to understand the logic before making it more sophisticated
Note : this code below has used 'set redraw off' .... 'redraw' to avoid flickering graphics as it was suggested by Marcus on the '1945 simplified' post / thread.
Code:
'INITIALIZATION
set window "Dino Simplified",640,480
set redraw off 'to avoid flickering graphics
load image 1,"data_dino/ground.png" 'length = 2400 px
load image 2,"data_dino/ground.png"
load image 3,"data_dino/dino1.png"
speed = 10
ground1X = 0 ; ground1Y = 400
ground2X = 2400 ; ground2Y = 400
dinoX = 40 ; dinoY = 330
'MAIN PROGRAM
do
'ESC TO QUIT
if keydown(KEY_ESCAPE) then end
'MOVING BACKGROUND
cls
draw image 1,ground1X,ground1Y
draw image 2,ground2X,ground2Y
if ground1X = -2400 then
ground1X = 0
ground2X = 2400
else
ground1X = ground1X - speed
ground2X = ground2X - speed
endif
'DINO
draw image 3,dinoX,dinoY
'WAIT BEFORE LOOPING
redraw 'to avoid flickering graphics
wait 40
loop