I made this eons ago so its pretty sloppy.
I built it off a little red aeroplane demo I made way back then as well.
The matrix shifting effect is a little wonky since new versions of
DBP have been updated. Im sure some smart cookie will tell you what the problem is there.
Quick Keys
arrow keys to fly
shift to speed up
space to air brake
control to show the deadly fire cone of death.
There is no gravity, because this dragon is weightless when he flies
Rem Project: indi plane
Rem Created: 03/09/03 11:01:13
rem ----------------------------------------
rem ----------------------------------------
rem PROGRAM NAME Dragon flight
rem author INDI
rem info based on A SIMPLE PLANE EXAMPLE
rem date SEPTEMBER 3 2003
rem
rem credits to The Darthster for memblock sin wave sound idea
rem and shift matrix solution
rem david 89 and red-eye for matrix smoothing
rem ----------------------------------------
rem ----------------------------------------
rem SETUP
rem ----------------------------------------
sync on : sync rate 60 : autocam off : hide mouse
set text size 13 : set text font "verdana" : set text to bold
color backdrop rgb(0,0,0)
set camera range 1,9000
if fog available() =1
fog on
fog distance 16000
endif
rem ----------------------------------------
rem DECLARE VARIABLES
rem ----------------------------------------
rem ----------------------------------------
rem INIT MEDIA
rem ----------------------------------------
rem Matrix texture
ink rgb(0,155,0),1
box 0,0,32,32
for i = 1 to 200
ink rgb(0,rnd(155)+100,0),1
dot rnd(32),rnd(32)
next i
get image 1,0,0,31,31
cls
make matrix 1,20000,20000,80,80
position matrix 1,-10000,0,-10000
prepare matrix texture 1,1,1,1
randomize matrix 1,5000
update matrix 1
smooth_matrix(1,80,80,2)
rem Use matrix normals to make it smooth
`for z=1 to 79
` for x=1 to 79
rem Get matrix heights
` h8#=get matrix height(1,x,z-1)
` h4#=get matrix height(1,x-1,z)
` h#=get matrix height(1,x,z)
` h2#=get matrix height(1,x,z)
rem Calculate projected angle X using heights
` x1#=(x-1)*25.0 : y1#=h#
` x2#=(x+0)*25.0 : y2#=h4#
` dx#=x2#-x1#
` dy#=y2#-y1#
` ax#=atanfull(dx#,dy#)
` ax#=wrapvalue(90-ax#)
rem Calculate projected angle Z using heights
` z1#=(z-1)*25.0 : y1#=h2#
` z2#=(z+0)*25.0 : y2#=h8#
` dz#=z2#-z1#
` dy#=y2#-y1#
` az#=atanfull(dz#,dy#)
` az#=wrapvalue(90-az#)
rem Make normal from projected angle
` nx#=sin(ax#)
` ny#=cos(ax#)
` nz#=sin(az#)
rem Setting matrix normal for smoothness
` set matrix normal 1,x,z,nx#,ny#,nz#
` next x
`next z
update matrix 1
rem Matrix texture
ink rgb(255,155,0),1
box 0,0,32,32
get image 2,0,0,31,31
cls
rem the body
make object sphere 1,0.6
texture object 1,2
rem a temp mesh for neck parts
make object sphere 100,0.3
make mesh from object 1,100
delete object 100
rem the neck and head
for i = 1 to 5
add limb 1,i,1
offset limb 1,i,0,i*0.05,i*0.03
texture limb 1,i,2
next i
rotate limb 1,1,15,0,0
scale limb 1,1,100,100,100
rotate limb 1,2,25,0,0
scale limb 1,2,95,95,95
rotate limb 1,3,35,0,0
scale limb 1,3,90,90,90
rotate limb 1,4,45,0,0
scale limb 1,4,85,85,85
rotate limb 1,5,55,0,0
scale limb 1,5,200,200,250
rem offset the first neckbone more foward
offset limb 1,1,0,0.3,0.3
rem linking neck heirachies
link limb 1,1,2
link limb 1,2,3
link limb 1,3,4
link limb 1,4,5
rem a temp mesh for Leg parts
make object cone 100,1
scale object 100,40,70,40
make mesh from object 2,100
delete object 100
rem the leg limbs
for i = 6 to 9
add limb 1,i,2
texture limb 1,i,2
next i
rem Leg offsets
offset limb 1,6,0.3,0,0.3
offset limb 1,7,-0.3,0,-0.3
offset limb 1,8,-0.3,0,0.3
offset limb 1,9,0.3,0,-0.3
rem Leg Rotates
rotate limb 1,6,-55,0,0
rotate limb 1,7,55,0,0
rotate limb 1,8,-55,0,0
rotate limb 1,9,55,0,0
rem a temp mesh for tail parts
make object sphere 100,0.5
make mesh from object 3,100
delete object 100
rem the tail limbs
add limb 1,10,3
offset limb 1,10,0,0,-0.3
scale limb 1,10,80,80,80
add limb 1,11,3
offset limb 1,11,0,0,-0.4
scale limb 1,11,70,70,70
add limb 1,12,3
offset limb 1,12,0,0,-0.5
scale limb 1,12,60,60,60
add limb 1,13,3
offset limb 1,13,0,0,-0.6
scale limb 1,13,50,50,50
add limb 1,14,3
offset limb 1,14,0,0,-0.7
scale limb 1,14,340,40,340
for i = 10 to 14
texture limb 1,i,2
next i
rem offset the first tail bone more backward
offset limb 1,10,0,0,-0.5
rem linking tail heirachies
link limb 1,10,11
link limb 1,11,12
link limb 1,12,13
link limb 1,13,14
rem a temp mesh for wing parts
make object cone 100,2
scale object 100,50,100,10
make mesh from object 3,100
delete object 100
rem wings
add limb 1,15,3
texture limb 1,15,2
offset limb 1,15,-0.4,0.3,-0.2
rotate limb 1,15,30,90,-75
add limb 1,16,3
texture limb 1,16,2
offset limb 1,16,0.4,0.3,-0.2
rotate limb 1,16,30,-90,75
rem a temp flamecone
make object cone 5,1
rotate object 5,180,0,0
scale object 5,40,100,40
glue object to limb 5,1,5
ghost object on 5
hide object 5
speed# = 15
rem ----------------------------------------
rem PRE MAIN
rem ----------------------------------------
`set shadow shading on 1
set light range 0,16000
position object 1,0,5000,0
ink rgb(255,255,255),1
rem ----------------------------------------
rem MAIN
rem ----------------------------------------
disable escapekey
while escapekey()=0
rem banking rolling left
if leftkey()=1
rem body
roll object left 1,1.0
rem neck
rotate limb 1,1,0,wrapvalue(-35),0
rem tail
rotate limb 1,10,0,wrapvalue(-15),0
rem front leg right
rotate limb 1,6,-75,0,0
rem front leg left
rotate limb 1,8,0,0,0
endif
rem banking rolling right
if rightkey()=1
rem body
roll object right 1,1.0
rem neck
rotate limb 1,1,0,35,0
rem tail
rotate limb 1,10,0,15,0
rem front leg right
rotate limb 1,6,0,0,0
rem front leg left
rotate limb 1,8,-75,0,0
endif
if leftkey()=0 and rightkey()=0
rotate limb 1,1,0,0,0
rotate limb 1,10,0,0,0
rem Leg Rotates
rotate limb 1,6,-75,0,0
rotate limb 1,7,75,0,0
rotate limb 1,8,-75,0,0
rotate limb 1,9,75,0,0
endif
if upkey()=1
rem body
pitch object down 1,1
rem neck
rotate limb 1,1,35,0,0
rem tail
rotate limb 1,10,35,0,0
rem front leg right
rotate limb 1,6,95,0,0
rem front leg left
rotate limb 1,8,95,0,0
rem wings
rotate limb 1,15,30,340,-75
rotate limb 1,16,30,-340,75
endif
if downkey()=1
rem body
pitch object up 1,1
rem neck
rotate limb 1,1,wrapvalue(-35),0,0
rem tail
rotate limb 1,10,wrapvalue(-25),0,0
rem wings
rotate limb 1,15,30,20,-75
rotate limb 1,16,30,-20,75
endif
if upkey()=0 and downkey()=0
rotate limb 1,3,0,0,0
rotate limb 1,10,0,0,0
rotate limb 1,15,30,90,-75
rotate limb 1,16,30,-90,75
endif
if inkey$()="["
turn object left 1,1
rem neck
rotate limb 1,1,0,wrapvalue(-35),0
rem front leg right
rotate limb 1,6,-55,0,0
rem front leg left
rotate limb 1,8,0,0,0
endif
if inkey$()="]"
turn object right 1,1
rem neck
rotate limb 1,1,0,35,0
rem front leg right
rotate limb 1,6,0,0,0
rem front leg left
rotate limb 1,8,-55,0,0
endif
if shiftkey()=1
rem wings
rotate limb 1,15,30,90,-75-rnd(60)
rotate limb 1,16,30,-90,75+rnd(60)
speed# = speed# +0.1
endif
if shiftkey()=0
speed# = speed# -0.01
if speed# < 0.0 then speed# = 0.0
endif
if spacekey()=1
speed# = speed# - 1.0
rem neck
rotate limb 1,1,wrapvalue(-55),0,0
rem wings
rotate limb 1,15,30,90,-35-rnd(35)
rotate limb 1,16,30,-90,35+rnd(35)
rem tail
rotate limb 1,10,wrapvalue(-55),0,0
rem front leg right
rotate limb 1,6,-55,0,0
rem front leg left
rotate limb 1,8,-55,0,0
endif
if controlkey()=1
show object 5
else
hide object 5
endif
move object 1,speed#
if object position x(1)>250
position object 1,object position x(1)-250,object position y(1),object position z(1)
shift matrix left 1
update matrix 1
endif
if object position x(1)<-250
position object 1,object position x(1)+250,object position y(1),object position z(1)
shift matrix right 1
update matrix 1
endif
if object position z(1)>250
position object 1,object position x(1),object position y(1),object position z(1)-250
shift matrix up 1
update matrix 1
endif
if object position z(1)<-250
position object 1,object position x(1),object position y(1),object position z(1)+250
shift matrix down 1
update matrix 1
endif
position camera Object position x(1),Object position y(1)+1,Object position z(1)-8
point camera Object position x(1),Object position y(1),Object position z(1)
rem ----------------------------------------
rem DEBUG OUTPUT
rem ----------------------------------------
box 11,11,INT(speed#),21
text 10,30,"speed"+STR$(speed#)
text 10,50,"FPS:"+STR$(screen fps())
text 10,70,"x"+STR$(Object position x(1))
text 10,90,"y"+STR$(Object position y(1))
text 10,110,"z"+STR$(Object position z(1))
sync
endwhile
rem ----------------------------------------
rem CLEAN UP
rem ----------------------------------------
delete matrix 1
delete object 1
delete image 1
end
function smooth_matrix(matnum,tilex,tilez,times)
for multiple=1 to times
for x=1 to tilex-1
for z=1 to tilez-1
a=get matrix height(matnum,x-1,z+1)
b=get matrix height(matnum,x,z+1)
c=get matrix height(matnum,x+1,z+1)
d=get matrix height(matnum,x+1,z)
e=get matrix height(matnum,x+1,z-1)
f=get matrix height(matnum,x,z-1)
g=get matrix height(matnum,x-1,z-1)
h=get matrix height(matnum,x-1,z)
total=a+b+c+d+e+f+g+h
av#=total/8
set matrix height matnum,x,z,av#
next z
next x
next multiple
for x=0 to tilex
set matrix height matnum,x,0,get matrix height(matnum,x,1)
next x
for x=0 to tilex
set matrix height matnum,x,tilez,get matrix height(matnum,x,tilez-1)
next x
for z=0 to tilez
set matrix height matnum,0,z,get matrix height(matnum,1,z)
next z
for z=0 to tilez
set matrix height matnum,tilex,z,get matrix height(matnum,tilex-1,z)
next z
update matrix matnum
endfunction
