i have bin struggeling with this as i dont want an locked sync rate in my game anymore.
but iam getting nowhere so please help me out on this.
the on helping me will get credits for it in the game later on.
this is spookys code sample.
Rem ***** Main Source File *****
sync on : sync rate 0 : autocam off
` make some objects
make matrix 1,1000,1000,50,50
make object sphere 1,50 : position object 1,500,0,600 : set object wireframe 1,1
make object cube 2,40
make object cube 3,10 : position object 3,400,5,700
position camera 500,20,400
x#=0
gosub init_timer
do
gosub timer_stuff
` player moves 40 units in 1 second and rotates 90 degrees in one second
control camera using arrowkeys 0,40.0*move#,90.0*move#
` rotate sphere so it rotates 180 degrees in 1 second
turn object left 1,180.0*move#
` bob cube up and down so it takes 1 second
x#=wrapvalue(x#+(360.0*move#))
position object 2,550,50.0*sin(x#),600
` make object chase you at rate of 20 units per second
point object 3,camera position x(),camera position y(),camera position z()
xrotate object 3,0
move object 3,20.0*move#
text 0,20,get time$()
text 0,0,str$(screen fps())
sync
loop
init_timer:
` t9 is how often to change speed (in milliseconds)
t1=timer() : t9=1000
return
timer_stuff:
` don't change any of this!
t2=timer() : inc t3
if t2-t1 >= t9
move#=((t2-t1)/1000.0)/t3 : t1=t2 : t3=0 : t4=1
else
if t4=0 then move#=((t2-t1)/1000.0)/t3
endif
return
the problem aint in his code its when iam trying to implennt it to my collision code the player figure dosent move at all when using 20.0*move# instead of wspd=4.5 that simply means iam moving him in steps of 4.5 in all directions.
my collision code or rather jopie dopies.
function move_coll(objectnr,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#
`height off walkable object
hgc=14
`walk speed
wspd=4.5
`gravity strength
grs=6
`max jump height
mjh=50.0
`jump duration smaller value longer jump higher value shorter
jdur=8
`get the old positions
yz#=object position y(objectnr)
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
mocoll=0
`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#,wspd)
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 and object collision(objectnr,coll)<415
position object objectnr,newx#,newy#+hgc,newz#
mocoll=1
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
`put the object back
position object objectnr,x#,y#,z#
mocoll=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#,wspd)
newy#=y#
`position the object
position object objectnr,newx#,object position y(objectnr),newz#
`if hit.. restore..
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
position object objectnr,newx#,newy#+hgc,newz#
mocoll=1
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
`put the object back
position object objectnr,x#,y#,z#
mocoll=1
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,wspd)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
position object objectnr,newx#,newy#+hgc,newz#
mocoll=1
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
`put the object back
position object objectnr,x#,y#,z#
mocoll=1
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+180,wspd)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
position object objectnr,newx#,newy#+hgc,newz#
mocoll=1
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
`put the object back
position object objectnr,x#,y#,z#
mocoll=1
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,wspd)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
position object objectnr,newx#,newy#+hgc,newz#
mocoll=1
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
`put the object back
position object objectnr,x#,y#,z#
mocoll=1
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+90,wspd)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
position object objectnr,newx#,newy#+hgc,newz#
mocoll=1
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
`put the object back
position object objectnr,x#,y#,z#
mocoll=1
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,wspd)
newz#=z#
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
position object objectnr,newx#,newy#+hgc,newz#
mocoll=1
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
`put the object back
position object objectnr,x#,y#,z#
mocoll=1
endif
endif
x#=object position x(objectnr)
y#=object position y(objectnr)
z#=object position z(objectnr)
newx#=x#
newz#=newzvalue(z#,objectang#+270,wspd)
newy#=y#
position object objectnr,newx#,object position y(objectnr),newz#
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
position object objectnr,newx#,newy#+hgc,newz#
mocoll=1
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
`put the object back
position object objectnr,x#,y#,z#
mocoll=1
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# - grs
`if you want.. and may jump
if spacekey()=1 and jumpable(objectnr) = 1
play sound 20
`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) + jdur
`if its 180, then stop jumping
if jump_angle#(objectnr) => 180 then jumping(objectnr)=0
endif
`position the object (jump height)
position object objectnr,x#,start_y#(objectnr) + sin(jump_angle#(objectnr))*mjh,z#
`if hit..
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
if jump_angle#(objectnr)>0 then play sound 21:land=1500
`restore variables
jumping(objectnr) = 0
jump_angle#(objectnr) = 0
if spacekey()=0 then jumpable(objectnr) = 1
`reposition the object
position object objectnr,x#,yz#,z#
endif
`fix weird collison bugg
if object collision(objectnr,coll)>0 and object collision(objectnr,coll)<415
position object objectnr,x#,y#+0.0000000000000001,z#
if keystate(17)=1 then move object objectnr,-wspd
if keystate(31)=1 then move object objectnr,wspd
if keystate(30)=1 then move object right objectnr,wspd
if keystate(32)=1 then move object left objectnr,wspd
endif
endfunction
i yust dont know where the problem is?
AMD ATHLON 1.8 XP WITH AN GEFORCE 4 TITANIUM 4600 (128 MB) AND 256 MB DDRAM (266).