forward/back speed increases infinatley :/

Blitz3D Forums/Blitz3D Beginners Area/forward/back speed increases infinatley :/

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Edit: sorry about the spacing in the code - the site seems to do this on it's own.


; mini-mini-mini Sausage Dweller - puki - 2004

Graphics3D 800,600; change this to whatever you want
HidePointer

walkspeed#=.2; speed at which the camera/player moves at - originally set to .1 (just in case you changed it)
no_of_data=11; number of lines of data in mapdata

SeedRnd MilliSecs(); this is vital for random numbers (helps the bot choose more randomly)

light=CreateLight()

;create the ground
floor1=CreatePlane()
EntityColor floor1,50,255,50
PositionEntity floor1,0,-2.3,0 
EntityType floor1,2


;create camera/player
Global player=CreatePivot()
Global camera=CreateCamera(player)
CameraRange camera,1,100
CameraClsColor camera,50,50,200; colour the sky
PositionEntity player,5,1,15
EntityType player,1


;create wall block
block=CreateCube()
FlipMesh block
ScaleEntity block,25,25,25
EntityColor block,150,0,0
EntityAlpha block,.8
EntityType block,2

Collisions 1,2,2,3; stops you walking though the walls


; MAIN LOOP ***************************************************

While Not KeyHit(1)

pz=EntityZ(player)
px=EntityX(player)

Gosub MoveCamera

UpdateWorld
RenderWorld
Flip
Wend
End

;---------------------------------------------------------------

; I could have used functions - but gosubs will suffice (no need to use 'Global' variables)

.MoveCamera
mx#=-.25*MouseXSpeed()
my#=.25*MouseYSpeed()
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2

TurnEntity player,0,mx#,0,1
TurnEntity camera,my#,0,0,0

If KeyDown(200) Or KeyDown(17) Then MoveEntity player,0,0,walkspeed
If KeyDown(208) Or KeyDown(31) Then MoveEntity player,0,0,-walkspeed
If KeyDown(205) Or KeyDown(32) Then MoveEntity player,walkspeed,0,0
If KeyDown(203) Or KeyDown(30) Then MoveEntity player,-walkspeed,0,0
Return