On 5/18/10, Greg Ewing <
greg.ewing@xxxxxxxxxxxxxxxx> wrote:
> Alex Hall wrote:
>> Can Pygame detect
>> where on the grid that is with some sort of onImageClick type method,
>> or do I have to track coordinates?
>
> Just track coordinates. For a regular grid, it's very easy. If the
> user clicks at (x, y) and the size of your grid cell is (w, h), then
> the coordinates of the clicked cell are (x // w, y // h).
>
>> Looks like I have to do a lot more reading on sprites.
>
> I wouldn't bother with sprites. Just loop over your grid coordinates,
> calculate the pixel coordinates of the corresponding rect for each
> cell, and fill it with the appropriate colour.
>
>> maybe define a
>> blue, red, and white rect
>
> Rects don't have colours, they just hold coordinates. You only need
> one rect. The colour is specified when you make the call to draw it.
>
> --
> Greg
>