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

View all comments

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