Skip to content

Latest commit

 

History

66 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Python Platformer

A 2D platformer game built with Python and Pygame, featuring state management, multiple enemy types, collectible items, and level progression.

Description

This platformer game implements classic side-scrolling gameplay with modern software architecture patterns. The game features a state management system for handling different game screens (menu, gameplay, game over), player combat mechanics with projectiles, various enemy AI behaviors, collectible items for health and progression, and a save/load system for game progress.

Features

  • State Management System: Clean separation between menu, gameplay, and game over states
  • Player Mechanics:
    • Movement and jumping physics
    • Shooting system with bullet projectiles
    • Health system with visual indicators
  • Enemy Types:
    • Walking enemies with patrol behavior
    • Ghost enemies with unique movement patterns
  • Collectibles:
    • Hearts for health restoration
    • Keys for unlocking areas/progression
    • Level completion portals
  • Level System:
    • Multiple levels with custom maps
    • Save/load functionality for game progress
  • Asset Management: Organized sprite and image assets for all game entities

Technologies

  • Python 3.x
  • Pygame - Game development framework for graphics, input handling, and game loop

Project Structure

python-platformer/
├── PythonGame/
│   └── src/
│       ├── main.py                 # Entry point and game loop
│       ├── save_data.json          # Player progress save file
│       ├── player/
│       │   ├── player.py           # Player character controller
│       │   └── bullet.py           # Projectile mechanics
│       ├── enemies/
│       │   ├── walking_enemy.py    # Ground-based enemy AI
│       │   └── ghost_enemy.py      # Flying enemy AI
│       ├── pickups/
│       │   ├── heart.py            # Health pickup item
│       │   ├── key.py              # Key collectible
│       │   └── next_level.py       # Level transition portal
│       ├── levels/
│       │   └── level.py            # Level loader and manager
│       ├── misc/
│       │   ├── global_settings.py  # Game configuration (resolution, FPS)
│       │   ├── state_manager.py    # State machine controller
│       │   ├── game_state.py       # Base state interface
│       │   ├── menu_state.py       # Main menu implementation
│       │   ├── play_state.py       # Active gameplay state
│       │   └── gameover_state.py   # Game over screen
│       └── assets/
│           ├── player/             # Player sprite sheets
│           ├── walking_enemy/      # Walking enemy sprites
│           ├── ghost_enemy/        # Ghost enemy sprites
│           ├── bullets/            # Projectile graphics
│           ├── pickups/            # Collectible item sprites
│           ├── platforms/          # Platform tile graphics
│           ├── maps/               # Level map data
│           ├── map_test.png        # Test level image
│           └── map_test_2.png      # Second test level
└── README.md

Installation

  1. Clone the repository:
git clone https://github.com/a1fut/python-platformer.git
cd python-platformer
  1. Install Python 3.x (if not already installed):

  2. Install Pygame:

pip install pygame

Usage

Run the game from the project directory:

cd PythonGame/src
python main.py

Controls

  • Arrow Keys / A/D - Move left/right
  • Space - Jump
  • Mouse Click / Shoot Key - Fire projectiles
  • ESC - Pause/Menu

Architecture

The game uses a State Pattern for managing different game screens:

  • StateManager: Handles state transitions and delegates events
  • MenuState: Main menu interface
  • PlayState: Active gameplay with player, enemies, and level management
  • GameOverState: End screen with restart options

Game settings (screen dimensions, FPS, colors) are centralized in global_settings.py for easy configuration.

Game Progress

Player progress is automatically saved to save_data.json, tracking:

  • Current level
  • Health status
  • Keys collected
  • Game completion status

About

Python uni project for PJATK

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages