[plt-scheme] Re: Writing a game and have questions

From: Deep (deepankar.sharma at gmail.com)
Date: Sat Sep 20 13:54:34 EDT 2008

I had thought about this - it certainly is possible to narrow down any
click down to 2-4 hexagons depending on how youre slicing the screen
up. The reason for the offscreen buffer scheme was that its a bit more
general. In the sense that if tomm I was using some ill defined shapes
(like say a Monster which would be an image with alpha) I could still
render their outlines to the offscreen click map and get the results.

I can also express the shapes as convex polygons and do the standard
point inside polygon method - but wanted to know if a cheaper test was
feasible since the click offscreen buffer can be rendered once on
startup and used.

On Sep 20, 11:49 am, Neil Van Dyke <n... at neilvandyke.org> wrote:
> 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/
> _________________________________________________
>   For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme

Posted on the users mailing list.