Hey guys,
I'm in a bit of a pickle. I have a player object that moves in a grid system where each grid slot is about 50x50 pixels. I'm trying to make the player move left and right between grid slots via mouse control, but it's not working very well. The movement doesnt need to be smooth either, it just needs to move over to the next slot.
Here is my code for that particular functionality:
Here is some mouse related code:
The MoveRight() and MoveLeft() methods for the player work fine when using the keyboard.
I guess the main problem is that the movement of the player is too imprecise between the grid slots. It tends to move across too many at once, and sometimes it gets "stuck" in a particular column.
Anyone have any ideas?
I'm in a bit of a pickle. I have a player object that moves in a grid system where each grid slot is about 50x50 pixels. I'm trying to make the player move left and right between grid slots via mouse control, but it's not working very well. The movement doesnt need to be smooth either, it just needs to move over to the next slot.
Here is my code for that particular functionality:
checkMouseX() If (mouseXpos - lastmouseXpos%) > 50 Then Player.MoveRight() If (mouseXpos - lastmouseXpos%) < -49 Then Player.MoveLeft() updateMouseX()
Here is some mouse related code:
HideMouse() Global mouseXpos% Global lastmouseXpos% lastmouseXpos% = MouseX() Function checkMouseX() mouseXpos = MouseX() End Function Function updateMouseX() lastMouseXpos = mouseXpos mouseXpos% = MouseX() End Function
The MoveRight() and MoveLeft() methods for the player work fine when using the keyboard.
I guess the main problem is that the movement of the player is too imprecise between the grid slots. It tends to move across too many at once, and sometimes it gets "stuck" in a particular column.
Anyone have any ideas?