thanx for the example andrewT, I want that when i press the upkey the player will move slowly but if I press the upkey twice in 3 sec then the player will move fastly
hope u understand
Edit:
thank you very much now it works and thats what i want
my last problem is that when i press the spacekey the player wont jump and the animation is playing just when i'am pressing the spacekey
here is the code
change the media with some objects
the terrain i'am using can be found in the examples folder
Rem Project: Ai
Rem Created: 13/05/2009 21:47:51
Rem ***** Main Source File *****
set display mode 1024,768,32
sync on
sync rate 40
autocam off
backdrop on
set camera range 0,0.5,1000000
color backdrop 0
global health as integer,keydown,movespeed as float,force as float,oldtime,jump as boolean ,player,load as boolean,save,view
health= 100:player=1:keydown=0:oldtime=0:movespeed=0:force=15.0
make_player()
make_sky()
make_terrain()
Do
ox#=object position x(player)
oy#=object position y(player)
oz#=object position z(player)
gosub move_player
if walk=0 then loop object player,415,452
if walk=1 then loop object player,47,77
if walk=2 then loop object player,101,121
if walk=3 then loop object player,353,416
x#=object position x(player)
y#=object position y(player)
z#=object position z(player)
c = sc_sphereslidegroup(1,ox#,oy#,oz#,x#,y#,z#,30,0)
if c>0
x#=sc_getcollisionslidex()
y#=sc_getcollisionslidey()
z#=sc_getcollisionslidez()
jump=0
endif
position object player,x#,y#,z#
set camera to follow object position x(player),object position y(player),object position z(player),object angle y(player),250.0,150.0,30.0,1
rem Move 47 - 77
rem Run 101-121
rem Idle 415-452
rem Jump 353-416
update terrain 4
sync
loop
move_player:
if scancode()>0 and keydown=0
keydown=1
if upkey()=1
if timer()-oldtime < 300
movespeed=8.0
walk=2
else
movespeed=4.0
walk=1
endif
endif
if downkey()=1
if timer()-oldtime < 300
movespeed=-8.0
walk=2
else
movespeed=-4.0
walk=1
endif
endif
oldtime=timer()
endif
if scancode()=0
movespeed=0.0
turnspeed=0.0
keydown=0
walk=0
endif
if rightkey()=1 then yrotate object player,wrapvalue(object angle y(player)+4.0):walk=2
if leftkey()=1 then yrotate object player,wrapvalue(object angle y(player)-4.0):walk=2
move object player,movespeed
if spacekey()=1 and jump=0
jump=1
walk=3
endif
y#=y#+force
force=force-.5
if force<-8.0 then force=-8.0
position object player,object position x(player),y#,object position z(player)
return
Function make_player()
load object "tony/kham.x",player
scale object player,60,60,60
set object speed player,50
yrotate object player,180
position object player,1000,10000,10000
fix object pivot player
sc_setupobject player,1,0
endfunction
Function make_terrain()
load image "texture.bmp",1
load image "detail.tga",2
make object terrain 4 ` create the terrain object
set terrain heightmap 4, "map.bmp" ` set the heightmap
set terrain scale 4, 100, 10, 50 ` set the scale
set terrain split 4, 16 ` split value by 16 * 16
set terrain tiling 4, 4 ` detail map tiling
set terrain light 4, 1, -0.25, 0, 1, 1, 0.78, 0.5 ` light - xdir, ydir, zdir, red, green, blue, intensity
set terrain texture 4, 1, 2 ` base and detail texture
build terrain 4
SC_setupcomplexobject 4,1,2
endfunction
Function make_sky()
load object "cloudcube.x",3
scale object 3,10000000,10000000,10000000
set object light 3,0 : set object texture 3,2,0
position object 3,0,-10000,0
endfunction
thanx for help