On 23 Nov, 2012, at 05:11, Thomas K.M. <
thomas....@gmail.com> wrote:
> As it is now, every frame it will check if buttons != [0,0,0] and then draw a circle if the mouse has been clicked. This has the side effect that it will continue to draw as long as the mouse button is pressed down. I'm also drawing the time of the click next to the circle, and if the click is extended over the change from one second to the next, those two time numbers - f.ex. 5 and 6 will be drawn on top of eachother. Depending on the numbers it can become unintelligible.
>
> Is there a way to draw only on the click - maybe by checking if button was pressed at the frame immediately before?
Yes. In pseudo-code:
if buttons == [0,0,0]: # don't draw anything
mouseClickedBefore = False
else: # something was clicked, so do drawing, but only once
if not mouseClickedBefore:
# do your drawing stuff, then
win.flip()
mouseClickedBefore = True
Cheers,
Mike