A modular core library for Pygame-based 2D games.
This project has been archived.
The maintainers of this project have marked this project as archived. No new releases are expected.
Project description
Pygame Core
Overview
Pygame Core is a modular and reusable library designed to simplify the development of 2D games using the Pygame library. It provides essential components for managing game loops, scenes, input handling, and utility functions, allowing developers to focus on building their game's unique features.
Features
- Game Loop Management: Simplifies the main game loop with FPS control.
- Scene Management: Enables seamless transitions between game scenes (e.g., menus, gameplay).
- Input Handling: Centralized input management for keyboards or other devices.
- Utilities: Provides tools like collision detection and default settings.
- Extensibility: Designed for easy customization and expansion.
Installation
Install the package using pip:
pip install pygame-core
Usage
Setting Up Your Game
Below is an example of how to use Pygame Core to create a simple game:
import pygame
from core import Game, Scene, SceneManager
class MainMenu(Scene):
def update(self, input_manager):
if input_manager.is_pressed(pygame.K_RETURN):
return Gameplay(self.screen)
def render(self):
self.screen.fill((0, 0, 0))
font = pygame.font.Font(None, 74)
text = font.render("Press Enter to Start", True, (255, 255, 255))
self.screen.blit(text, (150, 300))
class Gameplay(Scene):
def update(self, input_manager):
# Game logic goes here
pass
def render(self):
self.screen.fill((30, 30, 30))
if __name__ == "__main__":
pygame.init()
screen = pygame.display.set_mode((800, 600))
pygame.display.set_caption("Pygame Core Example")
manager = SceneManager(MainMenu(screen))
game = Game(screen)
game.run(manager)
pygame.quit()
Key Components
Game: Manages the main game loop and FPS control.Scene: A base class for creating game scenes withupdateandrendermethods.SceneManager: Handles scene transitions.InputManager: Provides a clean interface for checking key states.Utils: Includes common utilities like collision detection.
Contributing
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Make your changes.
- Run a pylint
pylint core - Submit a pull request.
Please ensure all tests pass before submitting your PR.
License
This project is licensed under the MIT License. See the LICENSE file for more details.
Upload
Remember to update version number in
VERSIONfile and delete the dist folder before uploading.
Build:
python -m build
Upload:
python -m twine upload dist/*
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygame_core-0.1.26.tar.gz.
File metadata
- Download URL: pygame_core-0.1.26.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ed2eae58e407c1c09814a0b17deeae70488d90cfe19071089bc0ae9e622ec40
|
|
| MD5 |
c9f2da6ff032d911006da8811f3bb1e8
|
|
| BLAKE2b-256 |
8ed9e9dc2b79a5603c0e448517aa0b3ceaeebf61de3875e5380ada2a5c0083f0
|
File details
Details for the file pygame_core-0.1.26-py3-none-any.whl.
File metadata
- Download URL: pygame_core-0.1.26-py3-none-any.whl
- Upload date:
- Size: 11.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6755054eda58d45dc1f206e5e9fead83eb22a46df6059030d1f3656976e88356
|
|
| MD5 |
2e5c6fd899903d76ed6d7ba83c4c5773
|
|
| BLAKE2b-256 |
8f4e59b01340eb9b50e68ebfbc5a7f6aec45eb10c29c16d2fba7123e3490bf80
|