Search code examples
pythonmouseeventmouserect

Click the mouse to continue python 2


How can I continue the game when the player clicks on the mouse? I tried making a huge rectangle and then

if rectangleRect.collidepoint(mousex,mousey):

    blablablabla 

I know for sure it can be done much easier, but I don't know how. Anyone got some suggestions?


Solution

  • Actually you should try:

    if event.key == MOUSEBUTTONDOWN:    #Remember to use from pygame.locals import *
        pass                            #Create code to make rectangle
                                        #Of course, top and bottom is mousex and mousey
    elif event.key == MOUSEBUTTONUP:
        pass                            #Do nothing else
    

    Use a while loop and some if and elif staements to help continue the game as proceeded. You should make a class for the rectangle to make the creation easier and smoother. And to keep the rectangle from doing weird stuff, remember to use:

    pygame.display.flip()