[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Help - Events



When you get a mouse button down event, store the mouse location.

When you get a mouse button up event, check if the cursor location in
the mouse up event is the same as the location in the last mouse
button down event. If so, handle the removal. Else, handle the
dragging.

Hope this helps you.

On Tue, Nov 17, 2009 at 14:26, Thiago Petruccelli
<thiagopetruccelli@xxxxxxxxx> wrote:
> Hi!
>
> I am making a game in wich the player has to fill an area with tiles. It's
> an educational game. But I got a problem with pygame events... Actually I
> think it's a simple problem, but I don't know how to solve.
>
> There are two functionalities for the left click of the mouse: the first is
> to put a tile in the area, when dragging one tile, and the other is to
> remove one tile of the area (when not dragging). The problem is that, when I
> put both codes together, the two things happen at the same time - it puts
> the tile and then removes it. I've tried to block the removal of the tile
> setting a variable, "placed", which blocks the action of removing the tile
> until the next event handling. But it didn't work.
>
> Can someone help me solve this?
>
> Thanks in advance,
> --
> Thiago Henrique Petruccelli
>