Creating Start Menu in Pygame

Last Updated : 20 Mar, 2026

A start menu is the first screen users see when launching a game and provides options such as Play, Settings or Quit. In Pygame, start menus are created by drawing buttons on the screen and handling mouse events to trigger different functions based on the user's selection.

Prerequisites

  • Python 3.x or later installed on the system
  • Pygame library installed

If Pygame is not installed, install it using the following command:

pip install pygame

Python Implementation

The following program demonstrates how to create a simple start menu with Play and Quit buttons. Clicking Play opens the game screen, while Quit closes the application.

Python
import pygame
import sys

pygame.init()

screen = pygame.display.set_mode((720, 720))
pygame.display.set_caption("Start Menu Example")

WHITE = (255,255,255)
LIGHT = (170,170,170)
DARK = (100,100,100)
BG = (60,25,60)

font = pygame.font.SysFont("Corbel", 40)

def game():
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()

        screen.fill((40, 40, 40))

        text = font.render("Game Started!", True, WHITE)
        screen.blit(text, (250, 350))

        pygame.display.update()

def start_menu():

    while True:

        screen.fill(BG)
        mouse = pygame.mouse.get_pos()

        play_button = pygame.Rect(300, 300, 140, 50)
        quit_button = pygame.Rect(300, 380, 140, 50)

        pygame.draw.rect(screen, LIGHT if play_button.collidepoint(mouse) else DARK, play_button)
        pygame.draw.rect(screen, LIGHT if quit_button.collidepoint(mouse) else DARK, quit_button)

        play_text = font.render("Play", True, WHITE)
        quit_text = font.render("Quit", True, WHITE)

        screen.blit(play_text, (335, 305))
        screen.blit(quit_text, (335, 385))

        for event in pygame.event.get():

            if event.type == pygame.QUIT:
                pygame.quit()
                sys.exit()

            if event.type == pygame.MOUSEBUTTONDOWN:

                if play_button.collidepoint(mouse):
                    game()

                if quit_button.collidepoint(mouse):
                    pygame.quit()
                    sys.exit()

        pygame.display.update()

start_menu()

Output

A window opens displaying Play and Quit buttons:

Screenshot-2026-03-10-120157
window displaying Play and Quit

Clicking Play starts the game screen and clicking Quit closes the program:

Screenshot-2026-03-10-120344
Game started after clicking play button

Explanation:

  • pygame.init() initializes all modules of Pygame required for the program.
  • pygame.display.set_mode((720, 720)) creates the main game window with a resolution of 720 × 720 pixels.
  • def start_menu(): defines the function that displays the start menu screen and handles button interactions.
  • pygame.Rect(300, 300, 140, 50) creates rectangular button areas used for Play and Quit options.
  • play_button.collidepoint(mouse) checks whether the mouse pointer is hovering over or clicking the button.
  • if event.type == pygame.MOUSEBUTTONDOWN: detects mouse click events to determine which button was pressed.
  • game() calls the game function when the Play button is clicked.
  • pygame.quit() and sys.exit() safely closes the application when the Quit button is selected.
Comment