Welcome to the Platformer Game repository! This project is a platform game developed in Python using the Pygame library.
- Graphics and sound with Pygame
- Interactive menu
- Ranking system
- Player movement and animations
- Collision detection
- Item collection
To get started, install the necessary dependencies:
pip install pygameRun the main script to start the game:
python main.pyThe code is organized into the following sections:
Imports essential libraries like Pygame, sys, random, time, and serial (unused ones have been removed).
Sets the Pygame window title and gets the screen size.
Creates a menu screen with a background image, title, and buttons to play or quit the game. Uses the Button class to handle button interactions.
Displays a ranking screen with player names and times. Opens a text file to read and display existing rankings. Uses the get_font function to create text objects.
Prompts the user to enter their name using a text input box. Uses the get_font function to create text objects.
Reads existing ranking data from a text file. Updates the ranking with the new player's name and time. Sorts the ranking data based on time.
Reads a map file and creates a 2D list representing the game map.
Loads animation sprites from a directory. Sets animation frames and durations. Creates a dictionary to store animation data.
Initializes the game window and sets up the clock. Loads game assets (images, sounds, fonts). Defines variables for player movement, jumping, and game state. Enters the main game loop:
- Processes user input (keyboard) for movement and jumping
- Updates player position based on movement and collisions
- Handles jump logic (gravity and jump height)
- Renders game elements: background image, coins and other collectibles, animated player character, text for score and timer
- Detects collisions with obstacles and collectibles
- Manages level transitions and end game conditions
Contributions are welcome! Feel free to open issues or submit pull requests.