I am making a game where you are a cube, and you jump from platform to platform, and try to get all the way to the top (there will be different types of platforms later). At the moment, you can jump through the bottom of the platforms, and it bugs me slightly, is there any simple way to fix this?
My Code:
`Declare Variables
x#=0 : y#=-190 : z#=-390
grav#=.5
xpos=0 : ypos=-200 : zpos=-400
clr1=0 : clr2=0 : clr3=200
der=1
for xnum=10 to 25
`Make Platform
Make Object Cube xnum,100
Scale Object xnum,100,1,200
Make Object Collision Box xnum,-50,-0,-100,50,3,100,0
Color Object xnum,rgb(clr1,clr2,clr3)
Position Object xnum,xpos,ypos,zpos
ypos=ypos+40
if der=1 then zpos=zpos+200
if der=0 then zpos=zpos-200
If clr3=200 : clr3=0 : clr1=200 : gosub rest : endif
If clr1=200 : clr1=0 : clr2=200 : gosub rest : endif
If clr2=200 : clr2=0 : clr3=200 : gosub rest : endif
rest:
if zpos=600 : ypos=ypos-40 : xpos=xpos-100 : zpos=zpos-200 : der=0 : endif
if zpos=-600 : ypos=ypos-40 : xpos=xpos+100 : zpos=zpos+200 : der=1 : endif
next xnum
`Make You
Make Object Cube 1,10
Make Object Collision Box 1,-5,-5,-5,5,5,5,0
Position Object 1,0,-190,-390
`Main Game Loop
Do
`Placing things
position object 1,x#,y#,z#
`Movement
a#=object angle y(1)
d#=70
h#=40
s#=10
if upkey()=1 then x#=newxvalue(x#,a#,.7) : z#=newzvalue(z#,a#,.7)
if downkey()=1 then x#=newxvalue(x#,a#,-.7) : z#=newzvalue(z#,a#,-.7)
if leftkey()=1 then yrotate object 1,wrapvalue(object angle y(1)-2.5)
if rightkey()=1 then yrotate object 1,wrapvalue(object angle y(1)+2.5)
Collision=object collision(1,0)
Set Cursor 20,20
Print Collision
`Gravity
if Collision=0 or collision=100 then grav#=grav#-0.08
if Collision>0 and collision<100 : grav#=0 : jump#=0 : endif
if spacekey()=1 : if grav#=0 : grav#=.5 : jump#=1 : endif : if jump#=1 : grav#=grav#+.3 : endif : endif
If grav#>4 then jump#=0
If grav#<-5 then grav#=-5
y#=y#+grav#
if y#<-700
grav#=0
y#=-190
x#=0
z#=-390
endif
`Camera
set camera to follow x#,y#,z#,a#,d#,h#,s#,1
`End Main Game
Loop
Am I dead yet?