0
\$\begingroup\$

My first post on gamedev :) And my first go at game dev :D

To ease me in, I'm starting with a lemmings clone.

I have my lemmings moving about and already have a MouseAdapter for moving around the map with the mouse.

In order to detect when the mouse is over a lemming I thought the easiest way would be to override the mouseMoved method. This would iterator over the lemmings and check if the mouse coords are in the lemmings rectangle. Is the normal way to do this?

I realised this wouldn't work for a lemming walking under/past the mouse cursor.

\$\endgroup\$
3
  • \$\begingroup\$ I'd say just check when you need to. Do you need to check for lemmings every time you move your mouse? Probably not. So instead check when you're trying to perform an action that requires the mouse to be above the lemming. \$\endgroup\$
    – Charanor
    Apr 1, 2017 at 11:44
  • \$\begingroup\$ Maybe you're too young to have played the original Lemmings :) Cursor needs to change when either the mouse is moved over a lemming or when a lemming walks under the mouse cursor. \$\endgroup\$
    – TedTrippin
    Apr 1, 2017 at 22:25
  • \$\begingroup\$ Very true haha but that wasn't my point. My point was that those events don't happen when you move your mouse, they happen whenever the game updates (new frame) so your code should check every frame not just when you move your mouse :) \$\endgroup\$
    – Charanor
    Apr 2, 2017 at 7:50

1 Answer 1

0
\$\begingroup\$

Solved it by having a second mask just for the "lemmings", then I can check this every time it paints.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .