No, that's not the issue.
For some reason, when I'm calling the function for drawing text, everything goes smoothly ( text 50,50,"MouseYSpeed: "+mouse.YSpeed();text 50,60,"MouseXSpeed: "+mouse.XSpeed() ) but when I assign it to a variable or do anything other than text for that matter, it usually returns 0 but occasionaly returns *something* just to throw me off.
Main program (revised to use RotateEntity rather than TurnEntity because TurnEntity doesn't seem to support roll whereas RotateEntity does)
Import sidesign.minib3d
Global gw=640,gh=480
Graphics3D gw,gh
Include "TMouse.bmx"
Include "TPlayer.bmx"
Global light=CreateLight()
Global player:TPlayer=New TPlayer
player.Create()
PositionEntity player.entity,0,0,0
Global camera=CreateCamera()
PositionEntity camera,0,0.46,-7
RotateEntity camera,-20,0,0
Global cpivot=CreatePivot(player.entity)
'EntityParent(camera,cpivot)
Global p=CreateCube();HideEntity p
For x=1 To 500
x2=CopyEntity(p)
PositionEntity x2,Rand(-800,800),Rand(-800,800),Rand(-800,800)
ScaleEntity x2,Rnd(0.4,8),Rnd(0.4,8),Rnd(0.4,8)
EntityColor x2,Rand(80,250),Rand(80,250),Rand(80,250)
Next
Global fpstimer=CreateTimer(60)
Repeat
Local mys=mouse.YSpeed()
Local mxs=mouse.XSpeed()
Print mys+" , "+mxs
If KeyDown(KEY_W) player.spd:+0.9
If KeyDown(KEY_S) player.spd:-0.9
If KeyDown(KEY_A) player.y:-0.2
If KeyDown(KEY_D) player.y:+0.2
player.p:-Float(mouse.YSpeed())
player.y:+Float(mouse.XSpeed())
player.r:+Float(mouse.XSpeed())
player.update()
MoveMouse gw/2,gh/2
If MouseHit(1)
EndIf
UpdateWorld
RenderWorld
text 50,50,"MouseYSpeed: "+mouse.YSpeed()
text 50,60,"MouseXSpeed: "+mouse.XSpeed()
Flip
WaitTimer(fpstimer)
If KeyDown(KEY_ESCAPE) End
mouse.update()
Forever
TMouse.bmx (thanks to Gfx):
Global mouse:tMouse = New tMouse
Type tMouse
Field lastX:Int
Field lastY:Int
Method XSpeed:Int()
Return MouseX() - lastX
End Method
Method YSpeed:Int()
Return MouseY() - lastY
End Method
Method update()
lastx = MouseX()
lasty = MouseY()
End Method
End Type
And TPlayer.bmx:
Global PlayerMesh=CreateCone(4)
ScaleEntity PlayerMesh,5,2,0.6
TurnEntity PlayerMesh,90,0,0
HideEntity PlayerMesh
Global players=0
Type TPlayer
Global list:TList=CreateList() 'in the case of more than 1 player (online play would be awesome)
Global decellerate#=0.001
Field spd#,maxspd#,p#,y#,r#
Field entity
Field hits=100
Method Create(x#=0,y#=0)
spd#=0
maxspd=40
p#=0;y#=0;r#=0
entity=CopyEntity(PlayerMesh)
list.AddLast(Self)
players:+1
End Method
Method Kill()
FreeEntity entity
players:-1
list.remove(Self)
End Method
Method Update()
If spd>0 spd:-decellerate ElseIf spd<0 spd:+decellerate
If Abs(spd)=<decellerate spd=0
If spd>maxspd spd=maxspd
If spd<-maxspd spd=-maxspd
MoveEntity entity,0,spd/40,0
RotateEntity entity,p,y,r
End Method
End Type