This works but might not be what you want.
Rem Project: Movement Test
Rem ***** Main Source File *****
#constant ARENA_OBJECT_NUM = 200
#constant PLAYER_OBJECT_START = 300
#constant ANGLE_DOWN = 0.0
#constant ANGLE_DOWN_LEFT = 45.0
#constant ANGLE_LEFT = 90.0
#constant ANGLE_UP_LEFT = 135.0
#constant ANGLE_UP = 180.0
#constant ANGLE_UP_RIGHT = 225.0
#constant ANGLE_RIGHT = 270.0
#constant ANGLE_DOWN_RIGHT = 315.0
#constant PLAYER_SPEED = 0.04
#constant KEYS_PLAYER_UP = 200
#constant KEYS_PLAYER_LEFT = 203
#constant KEYS_PLAYER_DOWN = 208
#constant KEYS_PLAYER_RIGHT = 205
type Player
X#, Y#, Z#
LegsObjNum
TorsoObjNum
LegsAngle#
TorsoAngle#
endtype
global tPlayer as Player
global allowdirection = 0
randomize timer()
rem Hide the pointer.
hide mouse
rem Setup graphics mode.
gosub SetupGraphics
rem Setup the Camera.
gosub SetupCamera
rem Setup the lights for the scene.
gosub SetupLights
rem Set up the arena.
gosub CreateArena
rem Set up the Player.
gosub CreatePlayer
rem Main Loop.
while not escapekey()
gosub SystemDisplay
ProcessPlayer()
gosub ProcessCamera
sync
endwhile
end
rem Setup the player objects.
CreatePlayer:
tPlayer.X# = 0
tPlayer.Y# = 2
tPlayer.Z# = 0
tPlayer.LegsObjNum = PLAYER_OBJECT_START
tPlayer.TorsoObjNum = PLAYER_OBJECT_START + 1
tPlayer.LegsAngle# = PLAYER_DOWN
tPlayer.TorsoAngle# = 0.0
make object cone tPlayer.LegsObjNum, 5
rotate object tPlayer.LegsObjNum, -90, 0, 0
position object tPlayer.LegsObjNum, 0, 4, 0
return
rem Process the player movement and controls.
function ProcessPlayer()
if keystate(KEYS_PLAYER_UP) = 0
if keystate(KEYS_PLAYER_DOWN) = 0
if keystate(KEYS_PLAYER_LEFT) = 0
if keystate(KEYS_PLAYER_RIGHT) = 0
allowdirection = 0
endif
endif
endif
endif
if keystate(KEYS_PLAYER_UP) = 1
if keystate(KEYS_PLAYER_LEFT) = 0
if keystate(KEYS_PLAYER_RIGHT) = 0
if keystate(KEYS_PLAYER_DOWN) = 0
if allowdirection <= 1
direction = 1
allowdirection = 1
endif
endif
endif
endif
endif
if keystate(KEYS_PLAYER_UP) = 1
if keystate(KEYS_PLAYER_LEFT) = 0
if keystate(KEYS_PLAYER_RIGHT) = 1
if keystate(KEYS_PLAYER_DOWN) = 0
if allowdirection <= 2
direction = 2
allowdirection = 2
endif
endif
endif
endif
endif
if keystate(KEYS_PLAYER_UP) = 0
if keystate(KEYS_PLAYER_LEFT) = 0
if keystate(KEYS_PLAYER_RIGHT) = 1
if keystate(KEYS_PLAYER_DOWN) = 0
if allowdirection <= 1
direction = 3
allowdirection = 1
endif
endif
endif
endif
endif
if keystate(KEYS_PLAYER_UP) = 0
if keystate(KEYS_PLAYER_LEFT) = 0
if keystate(KEYS_PLAYER_RIGHT) = 1
if keystate(KEYS_PLAYER_DOWN) = 1
if allowdirection <= 2
direction = 4
allowdirection = 2
endif
endif
endif
endif
endif
if keystate(KEYS_PLAYER_UP) = 0
if keystate(KEYS_PLAYER_LEFT) = 0
if keystate(KEYS_PLAYER_RIGHT) = 0
if keystate(KEYS_PLAYER_DOWN) = 1
if allowdirection <= 1
direction = 5
allowdirection = 1
endif
endif
endif
endif
endif
if keystate(KEYS_PLAYER_UP) = 0
if keystate(KEYS_PLAYER_LEFT) = 1
if keystate(KEYS_PLAYER_RIGHT) = 0
if keystate(KEYS_PLAYER_DOWN) = 1
if allowdirection <= 2
direction = 6
allowdirection = 2
endif
endif
endif
endif
endif
if keystate(KEYS_PLAYER_UP) = 0
if keystate(KEYS_PLAYER_LEFT) = 1
if keystate(KEYS_PLAYER_RIGHT) = 0
if keystate(KEYS_PLAYER_DOWN) = 0
if allowdirection <= 1
direction = 7
allowdirection = 1
endif
endif
endif
endif
endif
if keystate(KEYS_PLAYER_UP) = 1
if keystate(KEYS_PLAYER_LEFT) = 1
if keystate(KEYS_PLAYER_RIGHT) = 0
if keystate(KEYS_PLAYER_DOWN) = 0
if allowdirection <= 2
direction = 8
allowdirection = 2
endif
endif
endif
endif
endif
select direction
case 1
tPlayer.Z# = tPlayer.Z# + PLAYER_SPEED
tPlayer.LegsAngle# = ANGLE_UP
endcase
case 2
tPlayer.Z# = tPlayer.Z# + PLAYER_SPEED
tPlayer.X# = tPlayer.X# + PLAYER_SPEED
tPlayer.LegsAngle# = ANGLE_UP_RIGHT
endcase
case 3
tPlayer.X# = tPlayer.X# + PLAYER_SPEED
tPlayer.LegsAngle# = ANGLE_RIGHT
endcase
case 4
tPlayer.Z# = tPlayer.Z# - PLAYER_SPEED
tPlayer.X# = tPlayer.X# + PLAYER_SPEED
tPlayer.LegsAngle# = ANGLE_DOWN_RIGHT
endcase
case 5
tPlayer.Z# = tPlayer.Z# - PLAYER_SPEED
tPlayer.LegsAngle# = ANGLE_DOWN
endcase
case 6
tPlayer.Z# = tPlayer.Z# - PLAYER_SPEED
tPlayer.X# = tPlayer.X# - PLAYER_SPEED
tPlayer.LegsAngle# = ANGLE_DOWN_LEFT
endcase
case 7
tPlayer.X# = tPlayer.X# - PLAYER_SPEED
tPlayer.LegsAngle# = ANGLE_LEFT
endcase
case 8
tPlayer.Z# = tPlayer.Z# + PLAYER_SPEED
tPlayer.X# = tPlayer.X# - PLAYER_SPEED
tPlayer.LegsAngle# = ANGLE_UP_LEFT
endcase
case default
tPlayer.X# = tPlayer.X#
tPlayer.LegsAngle# = tPlayer.LegsAngle#
endcase
endselect
yrotate object tPlayer.LegsObjNum, tPlayer.LegsAngle#
position object tPlayer.LegsObjNum, tPlayer.X#, tPlayer.Y#, tPlayer.Z#
endfunction
rem Setup camera.
SetupCamera:
set camera range 0.1, 10000
return
rem Process the camera.
ProcessCamera:
position camera 0, 0, 30, -50
point camera 0,0,0
return
rem Create the arena floor.
CreateArena:
make object box ARENA_OBJECT_NUM, 100.0, 60.0, 1.0
position object ARENA_OBJECT_NUM, 0.0, -1.0, 0.0
rotate object ARENA_OBJECT_NUM, 90.0, 0.0, 0.0
return
SetupLights:
rem Set Ambient lighting.
set ambient light 0
rem Setup point light for the scene.
make light 1
set point light 1, 0, 100, 0
color light 1, 150, 150, 150
set normalization on
return
rem System Display.
SystemDisplay:
text 10, 10, "Graphics: " + Str$(ResX) + "x" + Str$(ResY) + "x" + Str$(BPP)
text 10, 22, "FPS: " + Str$(screen fps())
text 10, 33, "Camera X: " + Str$(camera position x())
text 10, 44, "Camera Y: " + Str$(camera position y())
text 10, 55, "Camera Z: " + Str$(camera position z())
text 10, 66, "Player Angle: " + Str$(tPlayer.LegsAngle#)
return
rem Setup graphics.
SetupGraphics:
sync on
rem sync rate 100
if (check display mode(1024,768,32)=1)
ResX = 1024 : ResY = 768 : BPP = 32
set display mode 1024, 768, 32
else if (check display mode(1024,768,16)=1)
ResX = 1024 : ResY = 768 : BPP = 16
set display mode 1024, 768, 16
else if (check display mode(800,600,32)=1)
ResX = 800 : ResY = 600 : BPP = 32
set display mode 800, 600, 32
else if (check display mode(800,600,16)=1)
ResX = 800 : ResY = 600 : BPP = 16
set display mode 800, 600, 16
else if (check display mode(640,480,32)=1)
ResX = 640 : ResY = 480 : BPP = 32
set display mode 640, 480, 32
else if (check display mode(640,480,16)=1)
ResX = 640 : ResY = 480 : BPP = 16
set display mode 640, 480, 16
else
print "Your graphics card does not support any of the program's display modes!"
end
endif:endif:endif:endif:endif:endif
return
"People don't fail ..... they stop trying." Specs. P4 2.8GHz 800 FSB | 512MB DDR333
GeForce FX 5200 AGP 256MB | Windows XP Pro Full