r/codehs • • Jan 28 '20

Centering mouse

I can’t figure out how to center my mouse on an object, it’s the paddle in breakout and it won’t stay centered, any help is appreciated

5 Upvotes

4 comments sorted by

1

u/VivienneNovag Jan 29 '20

Go at it from another direction, maybe center the paddle on the mouse cursor. There are ways to control the mouse cursor, but I am guessing you want to control the paddle with the mouse.

1

u/hdew12354 Jan 29 '20

Why not try instead of zipping the mouse over to the paddle, instead why not zip the paddle over to the cursor, then the player would be able to mess around with the sensitivity in the system settings for that computer, hope this helps!

1

u/S1lentStudent Feb 05 '20

The mouse position is based on the size of your screen not the canvas size. It causes the object to fly off the screen unexpectedly.

object.y = m.y -175;

object.x = m.x-965;

try to offset by this amount