Skip to main content

All Questions

Tagged with
Filter by
Sorted by
Tagged with
0 votes
0 answers
457 views

How to properly resize canvas according to screen size? (Javascript)

So, as the question says I need to resize the canvas according to screen size. However the thing is that that's not it. I also need to have the mouse coordinates updated proportionally. Seems like I ...
Nirabhra's user avatar
0 votes
1 answer
849 views

Detect how much mouse has rotated in a circle around an XY point

How can I detect if the mouse cursor is moving in a circle around a target, and calculate how many turns it's done? For example, if I rotate the mouse 4 times around a specific XY point on the screen, ...
jon's user avatar
  • 103
0 votes
1 answer
85 views

How to check mouse coordinates and mouse events

I'm building a simple game where if the mouse's X coordinate is greater than 200, and you click, the screen will turn red. Here's the code: var mouseX = event.clientX; var mouseY = event.clientY; ...
The Gamer King's user avatar
0 votes
1 answer
242 views

How to move 2D objects based on mouse movement with pointer locking?

I'm using pointer locking for a 2D game (where you perform calculations based on the delta in mouse positions from frame to frame). I'm having some basic math/logic issues with accomplishing what I ...
Mythics Winter's user avatar
0 votes
1 answer
569 views

Mouse position to grid position not working

I have a function which converts my mouse position to grid position in the game but it is not working properly... its slightly off. I have two functions - one which converts from grid to screen ...
Dave's user avatar
  • 480
3 votes
1 answer
114 views

Mouse input and structure in JS [closed]

I am creating a simple concept where I have a small menu to choose a tool from and then I can click and drag to build. For example, I click on the rails tool and then I can click and move the mouse ...
fmtoffolo's user avatar
3 votes
1 answer
3k views

How can I detect mouse events on sprites in a canvas?

I'm making an HTML 5 game. I want mouse clicks on sprites drawn in a canvas element cause events that my code can react to. At the moment, I'm doing it by checking through all of my sprites in a for-...
aaa111's user avatar
  • 175
4 votes
1 answer
3k views

Unity MouseWheel weapon change

I am trying to make a simple weapon change in Unity3D. The best way to do this is with the mouse scroll wheel, as far as I can see. I googled on how to do this and found that I have to use ...
BallzOfSteel's user avatar