rem Setup global stuff
set display mode 640,480,32
hide mouse
autocam off
rem Hide loading
sync on
sync rate 0
sync
center text 320,240,"LOADING"
sync
rem Start off variables
PlayerX#=10.0
PlayerY#=75.0
PlayerZ#=10.0
PlayerGrav#=0.5
PlayerargetAng#=0.0
PlayerSpeed#=0.5
dim BoxLife(100)
dim BoxTriggered(100)
rem Make textures
cls rgb(255,255,0)
text 0,0,"3"
get image 1,0,0,12,16
cls rgb(255,100,0)
text 0,0,"2"
get image 2,0,0,12,16
cls rgb(255,0,0)
text 0,0,"1"
get image 3,0,0,12,16
rem Make player
make object box 1,5,10,5
color object 1,rgb(0,255,0)
make object collision box 1,-2.5,5,-2.5,2.5,5,2.5,0
rem Make level
Obj=2
for y=10 to 1 step -1
for x=1 to 10
read LevelData
if LevelData=1
make object box Obj,10,10,10
position object Obj,x*10,0,y*10
color object Obj,rgb(100+rnd(155),rnd(155),0)
make object collision box Obj,-5,-5,-5,5,5,5,0
BoxLife(Obj)=300
BoxTriggered(Obj)=0
inc Obj,1
endif
next x
next y
rem Lock frame rate
sync on
sync rate 100
rem Start the main loop
do
rem Take input
Up=upkey()
Down=downkey()
Right=rightkey()
Left=leftkey()
rem Control player
if Up=1 and Left=0 and Right=0
PlayerZ#=PlayerZ#+PlayerSpeed#
PlayerTargetAng#=camera angle y()
endif
if Up=1 and Left=1 and Right=0
PlayerZ#=PlayerZ#+(PlayerSpeed#/2)
PlayerX#=PlayerX#-(PlayerSpeed#/2)
PlayerTargetAng#=camera angle y()-45
endif
if Up=1 and Left=0 and Right=1
PlayerZ#=PlayerZ#+(PlayerSpeed#/2)
PlayerX#=PlayerX#+(PlayerSpeed#/2)
PlayerTargetAng#=camera angle y()+45
endif
if Down=1 and Left=0 and Right=0
PlayerZ#=PlayerZ#-PlayerSpeed#
PlayerTargetAng#=camera angle y()+180
endif
if Down=1 and Left=1 and Right=0
PlayerZ#=PlayerZ#-(PlayerSpeed#/2)
PlayerX#=PlayerX#-(PlayerSpeed#/2)
PlayerTargetAng#=camera angle y()-135
endif
if Down=1 and Left=0 and Right=1
PlayerZ#=PlayerZ#-(PlayerSpeed#/2)
PlayerX#=PlayerX#+(PlayerSpeed#/2)
PlayerTargetAng#=camera angle y()+135
endif
if Right=1 and Up=0 and Down=0
PlayerX#=PlayerX#+PlayerSpeed#
PlayerTargetAng#=camera angle y()+90
endif
if Left=1 and Up=0 and Down=0
PlayerX#=PlayerX#-PlayerSpeed#
PlayerTargetAng#=camera angle y()-90
endif
PlayerAng#=curveangle(wrapvalue(PlayerTargetAng#),PlayerAng#,20)
PlayerAng#=wrapvalue(PlayerAng#)
PlayerY#=PlayerY#-PlayerGrav#
rem Update player object
position object 1,PlayerX#,PlayerY#-10,PlayerZ#
if object collision(1,0)>0
PlayerY#=PlayerY#+PlayerGrav#
endif
rem Blow up blocks
for b=2 to Obj-1
if object exist(b)=1
if object collision(b,1)>0
BoxTriggered(b)=1
endif
if BoxTriggered(b)=1
BoxLife(b)=BoxLife(b)-1
endif
if BoxLife(b)<300 and BoxLife(b)>199
texture object b,1
endif
if BoxLife(b)<200 and BoxLife(b)>99
texture object b,2
endif
if BoxLife(b)<100
texture object b,3
endif
if BoxLife(b)<1
delete object b
endif
endif
next b
rem Update player object
position object 1,PlayerX#,PlayerY#,PlayerZ#
yrotate object 1,PlayerAng#
rem Control camera
position camera PlayerX#,PlayerY#+50,PlayerZ#-50
point camera PlayerX#,PlayerY#,PlayerZ#
rem Update the screen
sync
rem End the loop
loop
rem Design level
LevelData:
data 1,1,1,0,1,1,1,0,1,1
data 1,0,1,0,1,0,1,0,1,0
data 1,0,1,0,1,0,1,0,1,0
data 1,0,1,0,1,0,1,0,1,0
data 1,0,1,0,1,0,1,0,1,0
data 1,0,1,0,1,0,1,0,1,0
data 1,0,1,0,1,0,1,0,1,0
data 1,0,1,0,1,0,1,0,1,0
data 1,0,1,0,1,0,1,0,1,0
data 1,0,1,1,1,0,1,1,1,0