[plt-scheme] Writing a game and have questions

From: Neil Van Dyke (neil at neilvandyke.org)
Date: Sat Sep 20 11:49:08 EDT 2008

Have you considered an arithmetic or algorithmic solution, using only 
the coordinates of the mouse click and what you know about hexagonal grid?

The input to your function would be the X and Y coordinates on your 
canvas where the mouse was clicked.  The output of your function would 
be some kind of identifier for the clicked hexagon, such as an object, 
array index, or hexagonal-coordinates.

By sketching this out on paper, I think you will see how you can at 
least narrow down the selected hexagon to only a few.  Once you have 
that coarse mapping between the coordinates, trigonometry or arithmetic 
will tell you to which side of a diagonal line a point falls...


deepankar wrote at 09/20/2008 11:23 AM:
> I draw a tiled array of hexagons on a canvas using paths. Now I would 
> like to detect which hexagon is beeing clicked on.


-- 
http://www.neilvandyke.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20080920/d0f6725b/attachment.html>

Posted on the users mailing list.