@fubarpk Thanks for your feedback .
@Mesher Coming from you it's a great compliment .I have seen some of your codes and they are impressive .
Here a new variant code
// Project: Drawing order
// Created: 2020-03-22
// show all errors
SetErrorMode(2)
// set window properties
SetWindowTitle( "Drawing order" )
SetWindowSize( 640, 480, 0 )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( 640, 480 ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( 30, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
giro=360/8
dim x[10] as float
dim y[10] as float
dim col[10]
dim dist[10] as float
paso as float
px as float
py as float
px=0
py=300
x[10]=0
y[10]=10
do
`D R A W I N G O R D E R ---------------------------------------------------------------
`bird animation
ale#=ale#+5
if ale#>100 then ale#=0
xx#=xx#+2
if xx#>360 then xx#=0
cx#=cx#+cos(xx#)*8
cy#=cy#+sin(xx#)
if xx#>500 then xx#=0
`SKY
w=makecolor(162,162,250)
drawbox(0,0,640,300,w,w,w,w,1)
`BIRD
w=makecolor(255,255,255)
drawellipse(140+cx#,140+ale#,80,30+ale#,w,w+100,1)
drawellipse(140+cx#+90,140+ale#,80,30+ale#,w,w+100,1)
w=makecolor(162,162,250)
drawellipse(130+cx#,150+ale#,80,30+ale#,w,w,1)
drawellipse(140+cx#+100,150+ale#,80,30+ale#,w,w,1)
w=makecolor(240,240,240)
drawellipse(85+cx#+100,130+(ale#/10),10,13,w,w,1)
`GROUND
b=makecolor(90,70,0)
drawbox(0,200,640,480,b,b,b,b,1)
bt=makecolor(120,100,0)
drawellipse(200,340,180,60,bt,bt,1)
`-------------------------------------------------------------------------------------------
for dep= 400 to 1 step -1
For i =1 To 10
dx#=x[i]-px
dz#=y[i]-py
dist[i]=sqrt((dx#*dx#)+(dz#*dz#))
if i<9
x[i]=sin(i*giro+paso)*130
endif
y[i]=cos(i*giro+paso)*40
x[9]=0 `center of trees
y[9]=0 `center of trees
y[10]=-12 `box y position
q=makecolor(255-dist[i]/2,255-dist[i]/2,0)
if dep=trunc(dist[i])
if i<9
drawbox(200+x[i]-2600/dist[i],300+y[i]-12600/dist[i],200+x[i]+2600/dist[i],300+y[i]+12600/dist[i],q,q,q,q,1)
g=makecolor(0,255-dist[i]/2,0)
for t= 1 to 16
drawbox (200+x[i]-(9600-t*500)/dist[i],300+y[i]/4-(22600+t*2000)/dist[i],200+x[i]+(9600-t*500)/dist[i],300+y[i]-(10600+t*2000)/dist[i],g,g,g,g,1)
next
drawbox (200+x[i]-(15600-t*500)/dist[i],300+y[i]-(22600)/dist[i],200+x[i]+(7600)/dist[i],300+y[i]-(10200)/dist[i],g,g,g,g,1)
endif
if i=9
w=makecolor(255,255,0)
drawellipse(200+x[9],160+y[9],40,40,w,w,1)
g=makecolor(255,255,0)
endif
if i=10
c=makecolor(120,220,210)
d=makecolor(lt,0,0)
drawellipse(box+125,300,17,17,d,d+100,1)
drawbox(box+100,300,box+150,340,c,c,c,c,1)
h=makecolor(0,0,0)
drawline(box+100,300,box+100,310+y[10]-20,h,h)
endif
endif
next
next
box=box+1
if box>300 then box=0
lt=lt+20
if lt>255 then lt=0
paso=paso+2
sync()
loop
And here a little gif showing how thist tecnic of raycasting works .
I'm not a grumpy grandpa