the board is somehow more complex than just a grid, i'm actually making my own digital copy of the game "Risk", if you don't know it, the board is the world map.
i wasn't really an "expert" in GDI, all i had was simple knowledge about basic operations in it.
when i realized there's a modern graphics library that Microsoft recommends to replace GDI, i thought to myself:
why learn the old method?
i'm still fresh so let's start on the right path.
Note that the coordinates that turn up with WM_LBUTTONDOWN, etc are already in client coordinates. |
Oh... i'm starting to mix things up....
well... even if the second approach works in this specific case, i think it would still fail when i push it up a little.
consider i want to create a simple 2D strategy game (like "age of empires").
in this case, i can't create windows for objects that are out of the screen borders.
it really looks intimidating monitoring the mouse and telling which object is it hovering on.
i'll keep searching MSDN while waiting for any other suggestions, maybe DirectInput can do the trick.
(i.e. you ask each object if the position is in their area) |
i actually had that in mind, but i'm concerned about performance, this approach could contain lots of overhead (asking each individual object to perform hit-testing.)
you know what, this gave me an idea:
maybe not test
ALL objects to test the mouse position, maybe i can create a list, contains pointers to the base class of everything.
each time an object is inside the screen borders it adds a pointer to itself to that list, and when hit-testing, i can ask just the elements in that list to hit-test, not all objects.
maybe another approach:
get rid of that list, i can tell the object to create its layered window only when it enters the screen borders, and when its completely out of the screen it can send WM_DESTROY.