Skip to main content

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 with update and render methods.
  • 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:

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Make your changes.
  4. 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pygame_core-0.1.1.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pygame_core-0.1.1-py3-none-any.whl (2.5 kB view details)

Uploaded Python 3

File details

Details for the file pygame_core-0.1.1.tar.gz.

File metadata

  • Download URL: pygame_core-0.1.1.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for pygame_core-0.1.1.tar.gz
Algorithm Hash digest
SHA256 00db64182524bdfd19e906503fa3edc29c1304d5557f2baa336b1c51d83818d5
MD5 88f2937474964b71305ae28f3b2c2400
BLAKE2b-256 a016e9f87976480aef1242e5140f0333c292cd9e14bde2bbb06142628f2a347c

See more details on using hashes here.

File details

Details for the file pygame_core-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: pygame_core-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 2.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.3

File hashes

Hashes for pygame_core-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 b12c73a639ee6b0aa10a5c1899ebd54937db6f207a419d1150d7e305eba47233
MD5 fc28f608dac4324feced351c8d65a296
BLAKE2b-256 d4e647008e7eccb897db1f373591194e95dbe075eb7442b129aade9d88e964d8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page