collision libary on page 2
>>>NEWEST UPDATES:
one with not really smooth ramp code, but it works..
`make a simple image
ink rgb(12,135,242),0
box 0,0,40,40
for r = 1 to 250
dot rnd(40),rnd(40),rgb(rnd(255),rnd(255),rnd(255))
next r
get image 1,0,0,40,40
`the main settings
sync on
sync rate 75
autocam off
`from here >>>>>>>>>>>>
`this is the player object
make object cube 1,15
position object 1,0,190,0
set object collision on 1
`add some graphics
fog on
fog distance 200
set ambient light 100
`make the ground
make object box 3,400,10,400
position object 3,0,-5,0
`check if an object exist, if not, create one and set the collision on it
for i = 1 to 10
`check
if object exist(i)=0
`make one
make object cube i,80
position object i,rnd(400)-200,0,rnd(400)-200
endif
`if it exists
if object exist(i)=1
`collision on it
set object collision on i
xrotate object i,45
`graphics :P
texture object i,1
endif
next i
xrotate object 1,0
xrotate object 3,0
make object box 11,100,100,400
set object collision on 11
texture object 11,1
`to here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< is all optional
REM REM REM REM REM REM REM REM REM REM
`YOU MUST PUT THESE VARIABLES GLOBAL!!!
REM REM REM REM REM REM REM REM REM REM
global jumping
global start_y#
global jump_angle#
global jumpable
`main loop
do
`sync
sync
`move player
move_player_with_collision(1,0,yang#)
`get the camera angles
yang#=yang#+mousemovex()*0.3
xang#=xang#+mousemovey()*0.3
`get the player object position
x#=object position x(1)
y#=object position y(1)
z#=object position z(1)
`position and rotate the camera
position camera x#,y#,z#
yrotate camera yang#
xrotate camera xang#
`loop
loop
function move_player_with_collision(objectnr,coll,colang#)
remstart
sliding collision:
move on x
check collision
if hit.. restore x
move on z
check collision
if hit.. restore z
jump and gravity.. y
check collision
if hit.. restore y, jump = able
remend
`get the walk angle
objectang#=colang#
`get the old positions
yz#=object position y(objectnr)
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`if 'w' is pressed
if keystate(17)=1
`get the old positions
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`make new positions
newx#=newxvalue(x#,objectang#,abs(sin(objectang#)))
newz#=z#
newy#=y#
`position the object
position object objectnr,newx#,object position y(objectnr),newz#
`if hit.. restore..
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
`get the old positions
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`make new positions
newx#=x#
newz#=newzvalue(z#,objectang#,abs(cos(objectang#)))
newy#=y#
`position the object
position object objectnr,newx#,object position y(objectnr),newz#
`if hit.. restore..
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
endif
`the same is it with all the other directions..
if keystate(31)=1
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=newxvalue(x#,objectang#+180,1)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+180,1)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
endif
if keystate(32)=1
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=newxvalue(x#,objectang#+90,1)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+90,1)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
endif
if keystate(30)=1
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=newxvalue(x#,objectang#+270,1)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+270,1)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
endif
`old pos
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`if you are not jumping
if jumping = 0
`gravity
start_y# = y# - 2.0
`if you want.. and may jump
if spacekey()=1 and jumpable = 1
`set the variables right
jumping = 1
jump_angle# = 0
start_y# = object position y(objectnr)
jumpable = 0
endif
endif
`if you are jumping
if jumping = 1
`increse jump angle
jump_angle# = jump_angle# + 2
`if its 180, then stop jumping
if jump_angle# => 180 then jumping=0
endif
`position the object
position object objectnr,x#,start_y# + sin(jump_angle#)*30.0,z#
`if hit..
if object collision(objectnr,coll)>0
`restore variables
jumping = 0
jump_angle# = 0
jumpable = 1
`reposition the object
position object objectnr,x#,yz#,z#
endif
endfunction
And this one with a simple ai player that's chasing you:
`make a simple image
ink rgb(12,135,242),0
box 0,0,40,40
for r = 1 to 250
dot rnd(40),rnd(40),rgb(rnd(255),rnd(255),rnd(255))
next r
get image 1,0,0,40,40
`the main settings
sync on
sync rate 75
autocam off
`from here >>>>>>>>>>>>
`this is the player object
make object cube 1,15
position object 1,0,190,0
set object collision on 1
`add some graphics
fog on
fog distance 200
set ambient light 100
`make the ground
make object box 3,400,10,400
position object 3,0,-5,0
`check if an object exist, if not, create one and set the collision on it
for i = 50 to 150
`check
if object exist(i)=0
`make one
make object cube i,30
position object i,rnd(400)-200,0,rnd(400)-200
endif
`if it exists
if object exist(i)=1
`collision on it
set object collision on i
`graphics :P
texture object i,1
endif
next i
make object cube 2,15
position object 2,0,190,90
`to here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< is all optional
dim jumping(300)
dim start_y#(300)
dim jump_angle#(300)
dim jumpable(300)
`main loop
do
`sync
sync
`move player
move_player_with_collision(1,0,yang#)
`get the camera angles
yang#=yang#+mousemovex()*0.3
xang#=xang#+mousemovey()*0.3
`get the player object position
x#=object position x(1)
y#=object position y(1)
z#=object position z(1)
point object 2,x#,object position y(2),z#
move_aiplayer_with_collision(2,0,object angle y(2),0.3)
`position and rotate the camera
position camera x#,y#,z#
yrotate camera yang#
xrotate camera xang#
`loop
loop
function move_aiplayer_with_collision(objectnr,coll,ang#,speed#)
`the angle
objectang#=ang#
`get the old positions
yz#=object position y(objectnr)
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`get the old positions
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`make new positions
newx#=newxvalue(x#,objectang#,abs(sin(objectang#))*speed#)
newz#=z#
newy#=y#
`position the object
position object objectnr,newx#,object position y(objectnr),newz#
`if hit.. restore..
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
yhit=1
endif
endif
`get the old positions
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`make new positions
newx#=x#
newz#=newzvalue(z#,objectang#,abs(cos(objectang#))*speed#)
newy#=y#
`position the object
position object objectnr,newx#,object position y(objectnr),newz#
`if hit.. restore..
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
yhit=1
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`if you are not jumping
if jumping(objectnr) = 0
`gravity
start_y#(objectnr) = y# - 2.0
`if you want.. and may jump
if yhit=1 and jumpable(objectnr) = 1
`set the variables right
jumping(objectnr) = 1
jump_angle#(objectnr) = 0
start_y#(objectnr) = object position y(objectnr)
jumpable(objectnr) = 0
endif
endif
`if you are jumping
if jumping(objectnr) = 1
`increse jump angle
jump_angle#(objectnr) = jump_angle#(objectnr) + 5
`if its 180, then stop jumping
if jump_angle#(objectnr) => 180 then jumping(objectnr)=0
endif
`position the object
position object objectnr,x#,start_y#(objectnr) + sin(jump_angle#(objectnr))*40.0,z#
`if hit..
if object collision(objectnr,coll)>0
`restore variables
jumping(objectnr) = 0
jump_angle#(objectnr) = 0
jumpable(objectnr) = 1
`reposition the object
position object objectnr,x#,yz#,z#
endif
yhit=0
endfunction
function move_player_with_collision(objectnr,coll,colang#)
remstart
sliding collision:
move on x
check collision
if hit.. restore x
move on z
check collision
if hit.. restore z
jump and gravity.. y
check collision
if hit.. restore y, jump = able
remend
`get the walk angle
objectang#=colang#
`get the old positions
yz#=object position y(objectnr)
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`if 'w' is pressed
if keystate(17)=1
`get the old positions
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`make new positions
newx#=newxvalue(x#,objectang#,abs(sin(objectang#)))
newz#=z#
newy#=y#
`position the object
position object objectnr,newx#,object position y(objectnr),newz#
`if hit.. restore..
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
`get the old positions
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`make new positions
newx#=x#
newz#=newzvalue(z#,objectang#,abs(cos(objectang#)))
newy#=y#
`position the object
position object objectnr,newx#,object position y(objectnr),newz#
`if hit.. restore..
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
endif
`the same is it with all the other directions..
if keystate(31)=1
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=newxvalue(x#,objectang#+180,1)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+180,1)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
endif
if keystate(32)=1
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=newxvalue(x#,objectang#+90,1)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+90,1)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
endif
if keystate(30)=1
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=newxvalue(x#,objectang#+270,1)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+270,1)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
endif
`old pos
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`if you are not jumping
if jumping(objectnr) = 0
`gravity
start_y#(objectnr) = y# - 2.0
`if you want.. and may jump
if spacekey()=1 and jumpable(objectnr) = 1
`set the variables right
jumping(objectnr) = 1
jump_angle#(objectnr) = 0
start_y#(objectnr) = object position y(objectnr)
jumpable(objectnr) = 0
endif
endif
`if you are jumping
if jumping(objectnr) = 1
`increse jump angle
jump_angle#(objectnr) = jump_angle#(objectnr) + 2
`if its 180, then stop jumping
if jump_angle#(objectnr) => 180 then jumping(objectnr)=0
endif
`position the object
position object objectnr,x#,start_y#(objectnr) + sin(jump_angle#(objectnr))*30.0,z#
`if hit..
if object collision(objectnr,coll)>0
`restore variables
jumping(objectnr) = 0
jump_angle#(objectnr) = 0
jumpable(objectnr) = 1
`reposition the object
position object objectnr,x#,yz#,z#
endif
endfunction
for
DBC users:
`make a simple image
ink rgb(12,135,242),0
box 0,0,40,40
for r = 1 to 250
`dot rnd(40),rnd(40),rgb(rnd(255),rnd(255),rnd(255))
next r
get image 1,0,0,40,40
`the main settings
sync on
sync rate 75
autocam off
`from here >>>>>>>>>>>>
`this is the player object
make object cube 1,15
position object 1,0,190,0
set object collision on 1
`add some graphics
fog on
fog distance 200
set ambient light 100
`make the ground
make object box 3,1400,10,1400
position object 3,0,-5,0
`check if an object exist, if not, create one and set the collision on it
for i = 50 to 150
`check
if object exist(i)=0
`make one
make object cube i,30+rnd(20)
position object i,rnd(700)-200,-10,rnd(700)-200
endif
`if it exists
if object exist(i)=1
`collision on it
set object collision on i
`graphics :P
texture object i,1
a=rnd(10)
if a=1
xrotate object i,45
endif
endif
next i
make object cube 2,15
position object 2,0,190,90
`to here <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< is all optional
dim jumping(300)
dim start_y#(300)
dim jump_angle#(300)
dim jumpable(300)
dim bullet(300,50)
`main loop
do
`sync
sync
`move player
move_player_with_collision(1,0,yang#)
`get the camera angles
yang#=yang#+mousemovex()*0.3
xang#=xang#+mousemovey()*0.3
`get the player object position
x#=object position x(1)
y#=object position y(1)
z#=object position z(1)
point object 2,x#,object position y(2),z#
move_aiplayer_with_collision(2,0,object angle y(2),0.3)
`position and rotate the camera
position camera x#,y#,z#
rotate camera wrapvalue(xang#),wrapvalue(yang#),0
`loop
loop
function shoot_bullets(id,action)
if action = 1
endif
if action =0
endif
endfunction
function make_bullets(id,startobj,amount)
for bullet = 1 to amount
if object exist(bullet+startobj)=1
do
sync
print "SYNTAX ERROR"
PRINT "BULLET OBJECT ALREADY EXISTS >> FUNCTION CALL: 'make bullets'"
set cursor 0,0
loop
endif
make object cube bullet+startobj,10
bullet(id,bullet)=1
next bullet
endfunction
function move_aiplayer_with_collision(objectnr,coll,ang#,speed#)
`the angle
objectang#=wrapvalue(ang#)
`get the old positions
yz#=object position y(objectnr)
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`get the old positions
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`make new positions
newx#=newxvalue(x#,objectang#,abs(sin(objectang#))*speed#)
newz#=z#
newy#=y#
`position the object
position object objectnr,newx#,object position y(objectnr),newz#
`if hit.. restore..
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
yhit=1
endif
endif
`get the old positions
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`make new positions
newx#=x#
newz#=newzvalue(z#,objectang#,abs(cos(objectang#))*speed#)
newy#=y#
`position the object
position object objectnr,newx#,object position y(objectnr),newz#
`if hit.. restore..
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
yhit=1
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`if you are not jumping
if jumping(objectnr) = 0
`gravity
start_y#(objectnr) = y# - 2.0
`if you want.. and may jump
if yhit=1 and jumpable(objectnr) = 1
`set the variables right
jumping(objectnr) = 1
jump_angle#(objectnr) = 0
start_y#(objectnr) = object position y(objectnr)
jumpable(objectnr) = 0
endif
endif
`if you are jumping
if jumping(objectnr) = 1
`increse jump angle
jump_angle#(objectnr) = jump_angle#(objectnr) + 5
`if its 180, then stop jumping
if jump_angle#(objectnr) => 180 then jumping(objectnr)=0
endif
`position the object
position object objectnr,x#,start_y#(objectnr) + sin(jump_angle#(objectnr))*40.0,z#
`if hit..
if object collision(objectnr,coll)>0
`restore variables
jumping(objectnr) = 0
jump_angle#(objectnr) = 0
jumpable(objectnr) = 1
`reposition the object
position object objectnr,x#,yz#,z#
endif
yhit=0
endfunction
function move_player_with_collision(objectnr,coll,colang#)
remstart
sliding collision:
move on x
check collision
if hit.. restore x
move on z
check collision
if hit.. restore z
jump and gravity.. y
check collision
if hit.. restore y, jump = able
remend
`get the walk angle
objectang#=colang#
`get the old positions
yz#=object position y(objectnr)
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`if 'w' is pressed
if keystate(17)=1
`get the old positions
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`make new positions
newx#=newxvalue(x#,objectang#,abs(sin(objectang#)))
newz#=z#
newy#=y#
`position the object
position object objectnr,newx#,object position y(objectnr),newz#
`if hit.. restore..
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
`get the old positions
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`make new positions
newx#=x#
newz#=newzvalue(z#,objectang#,abs(cos(objectang#)))
newy#=y#
`position the object
position object objectnr,newx#,object position y(objectnr),newz#
`if hit.. restore..
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
endif
`the same is it with all the other directions..
if keystate(31)=1
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=newxvalue(x#,objectang#+180,1)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+180,1)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
endif
if keystate(32)=1
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=newxvalue(x#,objectang#+90,1)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+90,1)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
endif
if keystate(30)=1
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=newxvalue(x#,objectang#+270,1)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+270,1)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0
position object objectnr,newx#,newy#+3,newz#
if object collision(objectnr,coll)>0
`put the object back
position object objectnr,x#,y#,z#
endif
endif
endif
`old pos
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
`if you are not jumping
if jumping(objectnr) = 0
`gravity
start_y#(objectnr) = y# - 2.0
`if you want.. and may jump
if spacekey()=1 and jumpable(objectnr) = 1
`set the variables right
jumping(objectnr) = 1
jump_angle#(objectnr) = 0
start_y#(objectnr) = object position y(objectnr)
jumpable(objectnr) = 0
endif
endif
`if you are jumping
if jumping(objectnr) = 1
`increse jump angle
jump_angle#(objectnr) = jump_angle#(objectnr) + 2
`if its 180, then stop jumping
if jump_angle#(objectnr) => 180 then jumping(objectnr)=0
endif
`position the object
position object objectnr,x#,start_y#(objectnr) + sin(jump_angle#(objectnr))*30.0,z#
`if hit..
if object collision(objectnr,coll)>0
`restore variables
jumping(objectnr) = 0
jump_angle#(objectnr) = 0
jumpable(objectnr) = 1
`reposition the object
position object objectnr,x#,yz#,z#
endif
endfunction
Hi everyone
,
This engine is very easy to use, The only thing you need to do is:
setting up your game
do
move_player_with_collision(object,coll,y angle)
loop
That's it!!!
well if this isn't easy..
click the source button for the code.
please tell me what you think
Do you need a complete FPS,3rdPS engine
?? Or a collision command libary?? well here it is:
http://forum.thegamecreators.com/?m=forum_view&t=38869&b=6&p=0