polystack-pygame-engine


Namepolystack-pygame-engine JSON
Version 1.2.8 PyPI version JSON
download
home_pagehttps://github.com/PolyStack-Games/Pygame-Engine
SummaryA modular pygame_engine library for Pygame-based 2D games.
upload_time2025-01-11 16:03:39
maintainerNone
docs_urlNone
authorPolyStack Games
requires_pythonNone
licenseMIT
keywords pygame game development engine
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Pygame-Engine

## Overview
Pygame-Engine is a lightweight, Unity-inspired game engine built using Python and Pygame. It provides a modular and extensible framework for 2D game development, including GameObjects, Components, Scene Management, Event Handling, and more.

---

## Features
- **GameObject System**: Modular entities with components like `Transform`, `SpriteRenderer`, and `Collider`.
- **Scene Management**: Easily manage and transition between game scenes.
- **Prefab System**: Save and instantiate reusable GameObject templates.
- **Event System**: Decoupled communication via a publish-subscribe model.
- **Input Manager**: Centralized input handling with customizable key bindings.
- **Scriptable Objects**: Reusable and serializable data containers for configurations and items.

---

## Installation
1. Clone the repository:
   ```bash
   git clone https://github.com/yourusername/pygame-engine.git
   cd pygame-engine
   ```
2. Install dependencies:
   ```bash
   pip install -r requirements.txt
   ```
3. Run an example:
   ```bash
   python examples/basic_game.py
   ```

---

## Usage

### GameObject System
Create GameObjects and add Components:
```python
from engine.game_object import GameObject
from engine.components import Transform, SpriteRenderer

player = GameObject("Player")
player_transform = player.add_component(Transform)
player_renderer = player.add_component(SpriteRenderer)
player_transform.position = [100, 100]
```

### Scene Management
Switch between scenes or reset the current scene:
```python
from engine.scene_manager import SceneManager
from engine.scene import Scene

main_scene = Scene("MainScene")
SceneManager.load_scene(main_scene)
SceneManager.reset_scene()
```

### Prefab System
Save and instantiate reusable prefabs:
```python
from engine.prefab_system import PrefabSystem

PrefabSystem.save_prefab("PlayerPrefab", "player_prefab.json", player)
new_player = PrefabSystem.instantiate_prefab("player_prefab.json")
```

### Event System
Publish and subscribe to events:
```python
from engine.event_system import EventBus

EventBus.subscribe("player_died", lambda score: print(f"Player died with score {score}"))
EventBus.publish("player_died", score=100)
```

### Input Manager
Bind keys to actions:
```python
from engine.input_manager import InputManager

InputManager.bind_action("jump", pygame.K_SPACE, "down")
InputManager.register_callback("jump", lambda: print("Jump!"))
```

---

## Examples
Explore the `examples/` directory for usage demonstrations:
- `basic_game.py`: A basic game showcasing core features.
- `event_bus_example.py`: Demonstrates the EventBus system.
- `input_manager_example.py`: Demonstrates the InputManager system.
- `prefab_system_example.py`: Demonstrates the PrefabSystem.

---

## Contributing
Contributions are welcome! To contribute:
1. Fork the repository.
2. Create a new branch for your feature or bugfix.
3. Commit your changes and create a pull request.

---

## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

---

## Acknowledgments
- [Pygame](https://www.pygame.org/) for providing the core library.
- Unity for inspiring the engine's architecture.

---

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/PolyStack-Games/Pygame-Engine",
    "name": "polystack-pygame-engine",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "pygame game development engine",
    "author": "PolyStack Games",
    "author_email": "nicklasbeyerlydersen@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/48/69/e50d97fbff2b5b019ebf4c39fe49091fa2676bd722a347c627336774a180/polystack_pygame_engine-1.2.8.tar.gz",
    "platform": null,
    "description": "# Pygame-Engine\n\n## Overview\nPygame-Engine is a lightweight, Unity-inspired game engine built using Python and Pygame. It provides a modular and extensible framework for 2D game development, including GameObjects, Components, Scene Management, Event Handling, and more.\n\n---\n\n## Features\n- **GameObject System**: Modular entities with components like `Transform`, `SpriteRenderer`, and `Collider`.\n- **Scene Management**: Easily manage and transition between game scenes.\n- **Prefab System**: Save and instantiate reusable GameObject templates.\n- **Event System**: Decoupled communication via a publish-subscribe model.\n- **Input Manager**: Centralized input handling with customizable key bindings.\n- **Scriptable Objects**: Reusable and serializable data containers for configurations and items.\n\n---\n\n## Installation\n1. Clone the repository:\n   ```bash\n   git clone https://github.com/yourusername/pygame-engine.git\n   cd pygame-engine\n   ```\n2. Install dependencies:\n   ```bash\n   pip install -r requirements.txt\n   ```\n3. Run an example:\n   ```bash\n   python examples/basic_game.py\n   ```\n\n---\n\n## Usage\n\n### GameObject System\nCreate GameObjects and add Components:\n```python\nfrom engine.game_object import GameObject\nfrom engine.components import Transform, SpriteRenderer\n\nplayer = GameObject(\"Player\")\nplayer_transform = player.add_component(Transform)\nplayer_renderer = player.add_component(SpriteRenderer)\nplayer_transform.position = [100, 100]\n```\n\n### Scene Management\nSwitch between scenes or reset the current scene:\n```python\nfrom engine.scene_manager import SceneManager\nfrom engine.scene import Scene\n\nmain_scene = Scene(\"MainScene\")\nSceneManager.load_scene(main_scene)\nSceneManager.reset_scene()\n```\n\n### Prefab System\nSave and instantiate reusable prefabs:\n```python\nfrom engine.prefab_system import PrefabSystem\n\nPrefabSystem.save_prefab(\"PlayerPrefab\", \"player_prefab.json\", player)\nnew_player = PrefabSystem.instantiate_prefab(\"player_prefab.json\")\n```\n\n### Event System\nPublish and subscribe to events:\n```python\nfrom engine.event_system import EventBus\n\nEventBus.subscribe(\"player_died\", lambda score: print(f\"Player died with score {score}\"))\nEventBus.publish(\"player_died\", score=100)\n```\n\n### Input Manager\nBind keys to actions:\n```python\nfrom engine.input_manager import InputManager\n\nInputManager.bind_action(\"jump\", pygame.K_SPACE, \"down\")\nInputManager.register_callback(\"jump\", lambda: print(\"Jump!\"))\n```\n\n---\n\n## Examples\nExplore the `examples/` directory for usage demonstrations:\n- `basic_game.py`: A basic game showcasing core features.\n- `event_bus_example.py`: Demonstrates the EventBus system.\n- `input_manager_example.py`: Demonstrates the InputManager system.\n- `prefab_system_example.py`: Demonstrates the PrefabSystem.\n\n---\n\n## Contributing\nContributions are welcome! To contribute:\n1. Fork the repository.\n2. Create a new branch for your feature or bugfix.\n3. Commit your changes and create a pull request.\n\n---\n\n## License\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n## Acknowledgments\n- [Pygame](https://www.pygame.org/) for providing the core library.\n- Unity for inspiring the engine's architecture.\n\n---\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A modular pygame_engine library for Pygame-based 2D games.",
    "version": "1.2.8",
    "project_urls": {
        "Homepage": "https://github.com/PolyStack-Games/Pygame-Engine",
        "Source": "https://github.com/PolyStack-Games/Pygame-Engine"
    },
    "split_keywords": [
        "pygame",
        "game",
        "development",
        "engine"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bd27eab72268d5091eb85a2b90fea5c32ed11fa582fbe6ef4f9582c4c041c2c4",
                "md5": "2806cf1ac49623ff0f0dc0c892f00a1b",
                "sha256": "78b6858465a2267fde2ac62999f0b00ce14301e2f6fd32bb5e200fcfb9b2553f"
            },
            "downloads": -1,
            "filename": "polystack_pygame_engine-1.2.8-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2806cf1ac49623ff0f0dc0c892f00a1b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 20433,
            "upload_time": "2025-01-11T16:03:37",
            "upload_time_iso_8601": "2025-01-11T16:03:37.133037Z",
            "url": "https://files.pythonhosted.org/packages/bd/27/eab72268d5091eb85a2b90fea5c32ed11fa582fbe6ef4f9582c4c041c2c4/polystack_pygame_engine-1.2.8-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4869e50d97fbff2b5b019ebf4c39fe49091fa2676bd722a347c627336774a180",
                "md5": "7cf50024a8fe5932b21da84059fc77ac",
                "sha256": "325643f2ed4143d19928612f4d8d10f312f05369f2c2b1ca34ea155fcf8d3026"
            },
            "downloads": -1,
            "filename": "polystack_pygame_engine-1.2.8.tar.gz",
            "has_sig": false,
            "md5_digest": "7cf50024a8fe5932b21da84059fc77ac",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 16346,
            "upload_time": "2025-01-11T16:03:39",
            "upload_time_iso_8601": "2025-01-11T16:03:39.954525Z",
            "url": "https://files.pythonhosted.org/packages/48/69/e50d97fbff2b5b019ebf4c39fe49091fa2676bd722a347c627336774a180/polystack_pygame_engine-1.2.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-01-11 16:03:39",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "PolyStack-Games",
    "github_project": "Pygame-Engine",
    "github_not_found": true,
    "lcname": "polystack-pygame-engine"
}
        
Elapsed time: 0.42241s