DEV Community

Guyzie754
Guyzie754

Posted on

1

pygame button gui

    def button (msg, x, y, w, h, ic, ac, action=None ):
        mouse = pygame.mouse.get_pos()
        click = pygame.mouse.get_pressed()

        if (x+w > mouse[0] > x) and (y+h > mouse[1] > y):
            pygame.draw.rect(watercycle, CYAN, (x, y, w, h))
            if (click[0] == 1 and action != None):
                if  (action == "Start"):
                    game_loop()
                elif  (action == "Load"):
                    ##Function that makes the loading of the saved file##
                elif  (action == "Exit"):
                    pygame.quit()

        else:
            pygame.draw.rect(watercycle, BLUE, (x, y, w, h))
            smallText = pygame.font.Font("freesansbold.ttf", 20)
            textSurf, textRect = text_objects(msg, smallText)
            textRect.center = ( (x+(w/2)), (y+(h/2)) )
            watercycle.blit(textSurf, textRect)
Enter fullscreen mode Exit fullscreen mode

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

AWS Security LIVE!

Hosted by security experts, AWS Security LIVE! showcases AWS Partners tackling real-world security challenges. Join live and get your security questions answered.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️