Hi !hi! I took time to go over some stairs stuff. It's something I've been wondering about aswell lately. Nothings too complicated about it. I havn't added any collision to this, but what it does do is recognise that you've
1. Come from off the ground to the first step
2. Are on the steps and can move up and down
3. Have come off the top of the steps to the ground
IT also however makes you stay at the 2nd or 3rd level if you walk sideways off. I was going to only make it walk left and right but I left in the rotation of the player.
Keys are arrow keys to move. You will want to press UP to go forward up the stairs, not LEFT KEY like you could expect
Have fun with the code... it's not the only way, but it works.
sync on
sync rate 40
`black pillars
for a=10 to 13
make object box a,10,30,10
color object a,rgb(0,0,0)
next a
position object 10,25,15,75
position object 11,75,15,25
position object 12,25,15,25
position object 13,75,15,75
`controllable object
player_height=10
x#=50
make object box 20,5,player_height,3
position object 20,40,5,20
`triggers
make object box 31,50,1,25
make object box 32,50,1,25
make object box 33,50,1,25
DIM trigger(0,3)
trigger(0,0)=0.0
trigger(0,1)=25.0
trigger(0,2)=50.0
trigger(0,3)=75.0
position object 31,trigger(0,2),1,trigger(0,1)
position object 32,trigger(0,2),3,trigger(0,2)
position object 33,trigger(0,2),5,trigger(0,3)
backdrop on
color backdrop rgb(255,0,0)
InBox=0
previnbox=0
onstairs=0
do
gosub player
gosub steps_on
if onstairs=1
text 240,300,"ON STAIRS!!"
gosub on_stairs
else
text 240,320,"OFF STAIRS!!"
if inbox=0 then y#=player_height/2
endif
position camera -50,15,50
point camera 0,15,50
previnbox=inbox
InBox=inbox(x#,z#)
text 20,20,str$(Inbox)
sync
loop
steps_on:
if previnbox=0
if inbox=31 then onstairs=1
endif
return
on_Stairs:
if previnbox=31
`up
if inbox=32 then y#=4+player_height/2
`down
if inbox=0 then onstairs=0
endif
if previnbox=32
`up
if inbox=33 then y#=6+player_height/2
endif
if previnbox=33
`up
if inbox=0 then onStairs=0
`down
if inbox=32 then y#=4+player_height/2
endif
if previnbox=32
`down
if inbox=31 then y#=2+player_height/2
endif
return
player:
rem Control variables with the cursor keys
if leftkey()=1 then angle#=wrapvalue(angle#-10)
if rightkey()=1 then angle#=wrapvalue(angle#+10)
if upkey()=1
x#=newxvalue(x#, angle#, 1.0)
z#=newzvalue(z#, angle#, 1.0)
endif
if downkey()=1
x#=newxvalue(x#, angle#, -1.0)
z#=newzvalue(z#, angle#, -1.0)
endif
rem Update object position and rotation
position object 20,x#,y#,z#
rotate object 20,0,angle#,0
return
function inbox(x#,z#)
YouAreInBox=0
`You are in X boundaries of steps
if x#>trigger(0,2)-25 AND x#<trigger(0,2)+25
`if you are in box 31
if z#>trigger(0,1)-12.5 AND z#<trigger(0,1)+12.5
YouAreInBox=31
endif
`you are in box 32
if z#>trigger(0,2)-12.5 AND z#<trigger(0,2)+12.5
YouAreInBox=32
endif
`if in box 33
if z#>trigger(0,3)-12.5 AND z#<trigger(0,3)+12.5
YouAreInBox=33
endif
endif
endfunction YouAreInBox
as a side note, don't let the top part of them program confuse you. It was made by me afew weeks ago and it's some kind of basic world I have. The file is saved and I can try new stuff out. The TRIGGER DIM arrays is just storing data on the Z position of the blocks. Don't worry about that, just look at the DO LOOP and GOSUBS. I hope I have put in enough REMinders for you . This also of course means I can use stairs in my levels aswell

Cheers for the chance to code it in.
**Officialy has a mental illness.
" Ahh to finish something! My boy, have you ever accomplished anything? "