Sinisterly
Pygame Mouse Events Trouble - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Python (https://sinister.ly/Forum-Python)
+--- Thread: Pygame Mouse Events Trouble (/Thread-Pygame-Mouse-Events-Trouble)

Pages: 1 2


Pygame Mouse Events Trouble - xxxxxxxxxxxxxxxxxxxxxxxxx - 12-12-2015

Code:
for event in pygame.event.get():
        if event.type == pygame.MOUSEBUTTONDOWN:
            mouse_pressed == 1
            if mouse_pressed == 1:
                stuff()
Issue is the script runs and ends, while I want to keep it open and wait for it to get a mouse click.
ty


RE: l - Sans - 12-12-2015

http://bfy.tw/3FO5 might help you out


RE: l - xxxxxxxxxxxxxxxxxxxxxxxxx - 12-12-2015

(12-12-2015, 04:33 AM)Sans Wrote: http://bfy.tw/3FO5 might help you out

u got me good!
actually made me virus total so I can see where it redirects ;(


RE: l - m0dem - 12-12-2015

Your name just screams spam and cancer. Really.... a user named "xxxxxxxxxxxxxxxxxxxxxxxxx"... and a thread named "L"...
I suggest you clean up, before @roger_smith cleans up

btw: before you go telling me about how I am not answering your question.... just don't.


RE: l - xxxxxxxxxxxxxxxxxxxxxxxxx - 12-12-2015

(12-12-2015, 04:39 AM)m0dem Wrote: Your name just screams spam and cancer. Really.... a user named "xxxxxxxxxxxxxxxxxxxxxxxxx"... and a thread named "L"...
I suggest you clean up, before @roger_smith cleans up

Sorry for not having the most HQ title or my username not being up to your standards Mr. m0dem!


RE: l - m0dem - 12-12-2015

(12-12-2015, 04:41 AM)xxxxxxxxxxxxxxxxxxxxxxxxx Wrote: Sorry for not having the most HQ title or my username not being up to your standards Mr. m0dem!

The title isn't "not HQ", it isn't even a title!!! You can change it to be more like... a title... by editing you main post. (for example, Pygame Mouse Events Trouble)

btw: Do you still need help with your script?


RE: Pygame Mouse Events Trouble - xxxxxxxxxxxxxxxxxxxxxxxxx - 12-12-2015

(12-12-2015, 04:47 AM)m0dem Wrote: The title isn't "not HQ", it isn't even a title!!! You can change it to be more like... a title... by editing you main post. (for example, Pygame Mouse Events Trouble)

btw: Do you still need help with your script?

Sure send me your JID
also changed title.


RE: Pygame Mouse Events Trouble - m0dem - 12-12-2015

All you need:
Code:
for event in pygame.event.get():
    if event.type == pygame.MOUSEBUTTONUP:
        # do stuff...
^^^ (inside your main loop) ^^^

The problem with your code is: on line 3 ( mouse_pressed == 1 ) ... you can't use the equal to ( == ) operator to assign variables, you can only use the assignment operator ( = ) (not to mention this variable and next if statement are completely unneeded.)
If it doesn't work, just say.

btw: Good job on changing the title! Smile


RE: Pygame Mouse Events Trouble - m0dem - 12-12-2015

@xxxxxxxxxxxxxxxxxxxxxxxxx
I assumed you had initialized everything else (the screen) before the loop through events, right?
You have to initialize the window or it will not work.
I don't know if Pygame is what you are looking for if you just want to get key presses...


RE: Pygame Mouse Events Trouble - xxxxxxxxxxxxxxxxxxxxxxxxx - 12-12-2015

(12-12-2015, 07:51 PM)m0dem Wrote: @xxxxxxxxxxxxxxxxxxxxxxxxx
I assumed you had initialized everything else (the screen) before the loop through events, right?
You have to initialize the window or it will not work.
I don't know if Pygame is what you are looking for if you just want to get key presses...

No didn't notice I had to call screen only used pygameinit()
Any recommendations then?