Here is some code including some simple level loading from data commandsd as well as some simple controls. In the top left of the screen you will be told if you are on the floor, jumping, falling or climbing.
The controols are:
Left Key - Move Left
Right Key - Move Right
Up Key - Jump
Hold Up Key - Hang to Bottom Of Surface
rem Project: Realms Of Tutopia I
rem Created: 24/01/2005 16:45:11
rem Author: Andrew Neale
rem Setup display
set display mode 800,600,32
autocam off
hide mouse
rem Create a player object
make object box 1,25,40,25
make object collision box 1,-12.5,-20,-12.5,12.5,20,12.5,0
rem Create a level
LevelObject=2
for y=12 to 1 step -1
for x=1 to 12
read TestLevel1Data
if TestLevel1Data=1
make object box LevelObject,50,50,50
position object LevelObject,x*50,y*50,0
make object collision box LevelObject,-25,-25,-25,25,25,25,0
inc LevelObject
endif
if TestLevel1Data=9
position object 1,x*50,y*50,0
x#=x*50
y#=y*50
z#=0
endif
next x
next y
rem Variables
Right=90
Left=270
Direction=Right
Jump=0
rem Manual synchronisation
sync on
sync rate 0
rem Main loop
do
rem Store old variables
oldx#=x#
oldy#=y#
rem Print whether the player is walking, jumping, falling or climbing
set cursor 0,0
if OnFloor=0
if Jump=0
print "Falling"
else
print "Jumping"
endif
endif
if OnFloor=1
print "On Foot"
endif
if OnFloor=2
print "Climbing"
endif
rem Control character
if upkey()=0
PressJump=0
endif
if upkey()=1 and Jump=0 and PressJump=0
if OnFloor>0
PressJump=1
Jump=100
endif
endif
if upkey()=1 and OnFloor=2 and PressJump=1
y#=y#+2
endif
if Jump>0
dec Jump
y#=y#+2
endif
if rightkey()=1
Direction=Right
x#=x#+1
endif
if leftkey()=1
Direction=Left
x#=x#-1
endif
y#=y#-1.0
position object 1,x#,oldy#,z#
if object collision(1,0)>0
dec x#,get object collision x()
endif
position object 1,x#,y#,z#
if object collision(1,0)>0
OnFloor=1
if y#<object position y(object collision(1,0))
if upkey()=1
OnFloor=2
else
OnFloor=0
endif
endif
y#=oldy#
else
OnFloor=0
endif
position object 1,x#,y#,z#
yrotate object 1,curveangle(Direction,object angle y(1),50)
rem Control camera
position camera x#,y#,z#-250
point camera x#,y#,z#
rem Update screen
sync
rem End main loop
loop
TestLevel1Data:
data 1,1,1,1,1,1,1,1,1,1,1,1
data 1,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,1,1,0,0,0,0,0,1
data 1,0,1,0,0,0,0,1,0,0,0,1
data 1,0,0,0,0,0,0,0,0,1,0,1
data 1,0,0,1,0,0,0,0,0,0,0,1
data 1,0,0,0,0,1,0,0,0,0,1,1
data 1,0,0,0,0,0,0,0,0,0,0,1
data 1,0,0,0,0,0,1,0,0,1,0,1
data 1,0,0,0,0,1,1,0,0,0,0,1
data 1,9,0,1,0,0,0,0,0,0,1,1
data 1,1,1,1,1,1,1,1,1,1,1,1