Build a Fun Star Catcher Game Using Pygame – A Simple Project for Python Game Coding Beginners

Build a Fun Star Catcher Game Using Pygame – A Simple Project for Python Game Coding Beginners

If you're learning Python and interested in creating something interactive, building games is one of the best ways to sharpen your skills. In this post, we’ll walk through the idea behind a simple yet engaging game called Star Catcher, built using Pygame. This is a perfect project if you're looking for inspiration in python game coding or just want to try a small fun project in your free time.

What is Star Catcher?

Star Catcher is a straightforward arcade-style game where the player controls a basket that moves left and right at the bottom of the screen. Stars fall from the top, and the goal is to catch them before they hit the ground. As simple as it sounds, this game is a great way to practice essential programming skills like conditionals, loops, collision detection, and real-time interaction — all vital parts of python coding for games.

Why Choose This Python Game Project?

There are plenty of python games out there, but many of them are too complex for beginners. This one is designed with simplicity and playability in mind, especially if you're new to writing python code for games. With just a few moving parts and a clear objective, it’s easy to understand and extend later if you want to add more features like power-ups or sound effects.

What You'll Learn

  • How to use Pygame to set up a game window and handle user input
  • Implementing falling objects and collision detection
  • Creating a scoring system and game over screen
  • Making mobile-friendly design choices for games in python

🌐 Build a Fun Star Catcher Game Using Pygame


import pygame
import random

# Initialize Pygame
pygame.init()

# Screen settings (mobile-friendly)
WIDTH, HEIGHT = 360, 640
screen = pygame.display.set_mode((WIDTH, HEIGHT))
pygame.display.set_caption("⭐ Star Catcher")
clock = pygame.time.Clock()
FPS = 60

# Colors
WHITE = (255, 255, 255)
BLACK = (15, 15, 15)
YELLOW = (255, 215, 0)
BLUE = (50, 150, 255)
RED = (255, 50, 50)

# Player settings
player_width, player_height = 60, 15
player_y = HEIGHT - 50
player_speed = 5

# Star settings
star_radius = 10
star_count = 3  # Now 3 stars
star_min_speed = 3
star_max_speed = 5  # Medium speed

# Fonts
font = pygame.font.SysFont('arial', 22, bold=True)
big_font = pygame.font.SysFont('arial', 36, bold=True)

def reset_game():
    return WIDTH // 2 - player_width // 2, [], 0, False

def create_star():
    return {
        'x': random.randint(star_radius, WIDTH - star_radius),
        'y': random.randint(-HEIGHT, 0),
        'speed': random.uniform(star_min_speed, star_max_speed)
    }

def main():
    player_x, stars, score, game_over = reset_game()

    for _ in range(star_count):
        stars.append(create_star())

    running = True
    while running:
        screen.fill(BLACK)
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False

        keys = pygame.key.get_pressed()

        if not game_over:
            # Player movement
            if keys[pygame.K_LEFT] and player_x > 0:
                player_x -= player_speed
            if keys[pygame.K_RIGHT] and player_x < WIDTH - player_width:
                player_x += player_speed

            # Update and draw stars
            for star in stars[:]:
                star['y'] += star['speed']
                player_rect = pygame.Rect(player_x, player_y, player_width, player_height)
                star_rect = pygame.Rect(star['x'] - star_radius, star['y'] - star_radius, star_radius * 2, star_radius * 2)

                if player_rect.colliderect(star_rect):
                    score += 1
                    stars.remove(star)
                    stars.append(create_star())
                elif star['y'] > HEIGHT:
                    game_over = True

            # Draw player and stars
            pygame.draw.rect(screen, BLUE, (player_x, player_y, player_width, player_height), border_radius=6)
            for star in stars:
                pygame.draw.circle(screen, YELLOW, (int(star['x']), int(star['y'])), star_radius)

            score_text = font.render(f"Score: {score}", True, WHITE)
            screen.blit(score_text, (10, 10))
        else:
            # Game Over UI
            over_text = big_font.render("Game Over!", True, RED)
            score_text = font.render(f"Final Score: {score}", True, WHITE)
            restart_text = font.render("Press SPACE to Restart", True, WHITE)
            screen.blit(over_text, (WIDTH // 2 - over_text.get_width() // 2, HEIGHT // 2 - 60))
            screen.blit(score_text, (WIDTH // 2 - score_text.get_width() // 2, HEIGHT // 2))
            screen.blit(restart_text, (WIDTH // 2 - restart_text.get_width() // 2, HEIGHT // 2 + 40))

            if keys[pygame.K_SPACE]:
                player_x, stars, score, game_over = reset_game()
                for _ in range(star_count):
                    stars.append(create_star())

        pygame.display.flip()
        clock.tick(FPS)

    pygame.quit()

if __name__ == "__main__":
    main()


🔍 Output Preview

Project Overview

The game is built using a small screen resolution (360x640), making it ideal for mobile and tablet play. The player can move the basket using the arrow keys to catch stars that fall at a medium speed. The game ends when a star is missed — keeping the gameplay short, simple, and addictive.

This project uses only three stars at a time to ensure it's not overwhelming and provides a good balance for those exploring python games code with clean and minimal logic.

💡 This is an excellent beginner project if you’re a student, hobbyist, or someone exploring python code for game development.

Ready to Build?

You don’t need advanced knowledge to create this game. If you know the basics of Python and have installed Pygame, you're ready to start. Whether you're doing it for fun, a college project, or looking to build your portfolio of coding games in python, Star Catcher is a fantastic place to begin.

If you’d like to add more functionality — like multiple levels, increasing speed, or sound effects — this project can grow with you. It’s lightweight, flexible, and a perfect entry point into the world of python coding games.

Final Thoughts

Whether you're searching for a small game to learn Python better, or looking for a simple idea to teach beginners, Star Catcher fits perfectly. Simple game mechanics, real-time feedback, and hands-on logic make it one of the best mini-projects if you're diving into python code games or learning how to code a game in Python.