This is my code (including the gravity part):
if jump = 1
if xxx = 8
else
xxx = xxx + 1
posy# = posy# + 0.5
endif
endif
if object collision(1,2) or object collision(1,3)
else
posy# = posy# - 2
endif
position object 1,posx#,posy#,posz#
Now, the first time I press space it goes up but then it won't after that, and its very jumpy when im jumping. I'm trying to make it progressively go upward instead of just appearing up then falling down with this.
Full code:
sync on
sync rate 60
make camera 1
backdrop on
color backdrop RGB(255,0,0)
make object cube 1,20
position object 1,0,0,0
color object 1,RGB(0,50,255)
make object collision box 1, - 10,-10,-10,10,10,10,0
make object box 2,100,1,100
position object 2,0,-1,0
make object box 3,100,1,100
position object 3,-50,-100,0
color object 3,RGB(50,50,50)
make object cube 4,20
make object collision box 4, - 10,-10,-10,10,10,10,0
position object 4,50,0,0
color object 4,RGB(150,2,75)
gravity# = 0
xxx = 1
jump = 0
do
prevx# = object position x(1)
prevy# = object position y(1)
prevz# = object position z(1)
posx# = prevx#
posy# = prevy#
posz# = prevz#
if upkey() = 1
posz# = posz# + 1
endif
if downkey() = 1
posz# = posz# - 1
endif
if rightkey() = 1
posx# = posx# + 1
endif
if leftkey() = 1
posx# = posx# - 1
endif
if spacekey() = 1
jump = 1
endif
if jump = 1
if xxx = 8
else
xxx = xxx + 1
posy# = posy# + 0.5
endif
endif
if object collision(1,2) or object collision(1,3)
else
posy# = posy# - 2
endif
position object 1,posx#,posy#,posz#
if object collision(1,4)
position object 1,prevx#,prevy#,prevz#
endif
position camera 1,object position x(1)-75,object position y(1)+100,object position z(1)
point camera 1,object position x(1),object position y(1),object position z(1)
sync
loop
Always program as if the person maintaining your program is a psychopath that knows where you live