{"id":24484288,"url":"https://github.com/betterbuiltfool/pyrite_framework","last_synced_at":"2025-04-13T18:07:54.193Z","repository":{"id":272639552,"uuid":"908026601","full_name":"BetterBuiltFool/pyrite_framework","owner":"BetterBuiltFool","description":"A higher-level framework for making games with Pygame-ce","archived":false,"fork":false,"pushed_at":"2025-04-10T17:13:19.000Z","size":760,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T18:08:09.534Z","etag":null,"topics":["framework","game-development","gamedev","library","pygame-ce","pygame-library","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/BetterBuiltFool.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-24T23:02:04.000Z","updated_at":"2025-04-10T17:02:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"273f1217-d0fa-4ca8-8039-80eb9a659533","html_url":"https://github.com/BetterBuiltFool/pyrite_framework","commit_stats":null,"previous_names":["betterbuiltfool/pyrite_framework"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BetterBuiltFool%2Fpyrite_framework","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BetterBuiltFool%2Fpyrite_framework/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BetterBuiltFool%2Fpyrite_framework/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BetterBuiltFool%2Fpyrite_framework/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BetterBuiltFool","download_url":"https://codeload.github.com/BetterBuiltFool/pyrite_framework/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248270858,"owners_count":21075796,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["framework","game-development","gamedev","library","pygame-ce","pygame-library","python"],"created_at":"2025-01-21T13:14:14.068Z","updated_at":"2025-04-13T18:07:54.184Z","avatar_url":"https://github.com/BetterBuiltFool.png","language":"Python","readme":"\u003c!-- Improved compatibility of back to top link: See: https://github.com/othneildrew/Best-README-Template/pull/73 --\u003e\n\u003ca id=\"readme-top\"\u003e\u003c/a\u003e\n\u003c!--\n*** Thanks for checking out the Best-README-Template. If you have a suggestion\n*** that would make this better, please fork the repo and create a pull request\n*** or simply open an issue with the tag \"enhancement\".\n*** Don't forget to give the project a star!\n*** Thanks again! Now go create something AMAZING! :D\n--\u003e\n\n\n\n\u003c!-- PROJECT SHIELDS --\u003e\n\u003c!--\n*** I'm using markdown \"reference style\" links for readability.\n*** Reference links are enclosed in brackets [ ] instead of parentheses ( ).\n*** See the bottom of this document for the declaration of the reference variables\n*** for contributors-url, forks-url, etc. This is an optional, concise syntax you may use.\n*** https://www.markdownguide.org/basic-syntax/#reference-style-links\n--\u003e\n[![Contributors][contributors-shield]][contributors-url]\n[![Forks][forks-shield]][forks-url]\n[![Stargazers][stars-shield]][stars-url]\n[![Issues][issues-shield]][issues-url]\n[![MIT License][license-shield]][license-url]\n\u003c!--\n[![LinkedIn][linkedin-shield]][linkedin-url]\n--\u003e\n\n\n\n\u003c!-- PROJECT LOGO --\u003e\n\u003cbr /\u003e\n\u003c!--\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://github.com/BetterBuiltFool/pyrite_framework\"\u003e\n    \u003cimg src=\"images/logo.png\" alt=\"Logo\" width=\"80\" height=\"80\"\u003e\n  \u003c/a\u003e\n--\u003e\n\n\u003ch3 align=\"center\"\u003ePyrite\u003c/h3\u003e\n\n  \u003cp align=\"center\"\u003e\n    The Foolproof Game Framework\n    \u003cbr /\u003e\n    \u003ca href=\"https://github.com/BetterBuiltFool/pyrite_framework\"\u003e\u003cstrong\u003eExplore the docs »\u003c/strong\u003e\u003c/a\u003e\n    \u003cbr /\u003e\n    \u003cbr /\u003e\n    \u003c!--\n    \u003ca href=\"https://github.com/BetterBuiltFool/pyrite_framework\"\u003eView Demo\u003c/a\u003e\n    ·\n    --\u003e\n    \u003ca href=\"https://github.com/BetterBuiltFool/pyrite_framework/issues/new?labels=bug\u0026template=bug-report---.md\"\u003eReport Bug\u003c/a\u003e\n    ·\n    \u003ca href=\"https://github.com/BetterBuiltFool/pyrite_framework/issues/new?labels=enhancement\u0026template=feature-request---.md\"\u003eRequest Feature\u003c/a\u003e\n  \u003c/p\u003e\n\u003c/div\u003e\n\n\n\n\u003c!-- TABLE OF CONTENTS --\u003e\n\u003cdetails\u003e\n  \u003csummary\u003eTable of Contents\u003c/summary\u003e\n  \u003col\u003e\n    \u003cli\u003e\n      \u003ca href=\"#about-the-project\"\u003eAbout The Project\u003c/a\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\n      \u003ca href=\"#getting-started\"\u003eGetting Started\u003c/a\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#installation\"\u003eInstallation\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#usage\"\u003eUsage\u003c/a\u003e\u003c/li\u003e\n      \u003cul\u003e\n        \u003cli\u003e\u003ca href=\"#using-game\"\u003eUsing Game\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#loop-phases\"\u003eLoop Phases\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#entities-and-renderables\"\u003eEntities and Renderables\u003c/a\u003e\u003c/li\u003e\n        \u003cli\u003e\u003ca href=\"#forget-about-screen-space\"\u003eForget About Screen Space\u003c/a\u003e\u003c/li\u003e\n      \u003c/ul\u003e\n    \u003cli\u003e\u003ca href=\"#roadmap\"\u003eRoadmap\u003c/a\u003e\u003c/li\u003e\n    \u003c!--\u003cli\u003e\u003ca href=\"#contributing\"\u003eContributing\u003c/a\u003e\u003c/li\u003e--\u003e\n    \u003cli\u003e\u003ca href=\"#license\"\u003eLicense\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#contact\"\u003eContact\u003c/a\u003e\u003c/li\u003e\n    \u003cli\u003e\u003ca href=\"#acknowledgments\"\u003eAcknowledgments\u003c/a\u003e\u003c/li\u003e\n  \u003c/ol\u003e\n\u003c/details\u003e\n\n\n\n\u003c!-- ABOUT THE PROJECT --\u003e\n## About The Project\n\n\u003c!--\n[![Product Name Screen Shot][product-screenshot]](https://example.com)\n--\u003e\n\nPyrite is a framework for eliminating much of the boilerplate of setting up a pygame project and getting running, while encouraging good project architecture with proper seperation of responsibilities among game elements. It includes several built-in systems to get development up and going.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\u003c!-- GETTING STARTED --\u003e\n## Getting Started\n\nPyrite is written in pure python, with no system dependencies, and should be OS-agnostic.\n\n### Installation\n\nPyrite can be installed from the [PyPI][pypi-url] using [pip][pip-url]:\n\n```sh\npip install pyrite-framework\n```\n\nand can be imported for use with:\n```python\nimport pyrite\n```\n\nPyrite additionally is built for pygame-ce, which must also be installed.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- USAGE EXAMPLES --\u003e\n## Usage\n\nAt its core, Pyrite is built around a single main class: the Game class.\nGame is useable as-is in its default state, or it can be subclassed to allow for more specific behaviors.\n\n### Using Game\n\nA game can be started in multiple ways.\n\n1. Traditional way\n\n```python\nimport pyrite\n\nmy_game = pyrite.Game()  # Creating with default settings\n# ----------------------\n#\n# Game setup stuff here\n#\n# ----------------------\nmy_game.main()\n```\n\nThis will create a window with a black background, at the default size (800x600), with a caption of \"Game\"\n\nKeep in mind, anything after calling main() will be on hold until after the game stops running.\n\n2. Context Manager\n\nAlternatively, we can use python's ```with``` syntax to create a game.\n\n```python\nimport pyrite\n\nwith pyrite.Game() as my_game:\n    # ----------------------\n    #\n    # Game setup stuff here\n    #\n    # ----------------------\n```\n\nAs with the above example, this will start a game with default settings. As a context manager, Game will start itself once the context ends.\n\nUsing context manager syntax offers a couple benefits.\n1. Avoids needing to manually call main().\n\n    This is minor, but it's an additional step that needs to be minded otherwise.\n\n2. Indentation helps make it clear what code is being used to set up the game.\n\n3. Errors are captured.\n\n    Any error that occurs during the set up will be captured by the context manager, and Game has a setting to suppress these errors.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n### Game Settings\n\nGame has several data classes that hold information for it. You can construct the yourself and pass them to the game instance, or you can pass their parameters as keywords into the Game constructor.\n\n```python\n# This:\ndisplay_settings = DisplaySettings((400, 300))\nwith Game(display_settings=display_settings) as my_game:\n    ...\n\n# Is the same as this\nwith Game(resolution=(400, 300)) as my_game:\n    ...\n```\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n### Loop Phases\n\nA game is built around a loop, and that loop has certain phases. The pyrite game loop offers these phases:\n\n1. Events: The pygame event queue is processed\n\n2. Const_update: Runs at a fixed rate, regardless of frame rate. Useful for time-invariant things, like physics.\n\n3. Pre_update: Runs earlier than the main update phase.\n\n4. Update: Main update phase. Most logic is run here.\n\n5. Post-update: Runs after the main update phase.\n\n6. Render: For drawing to the screen.\n\nThe basic Game class will call each of the phases on all enabled Entities and Renderables, but also has these available as methods to allow for more specific behavior when subclassed.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n### Entities and Renderables\n\nThese are the core feature of Pyrite. Most objects in your game should inherit from at least one of these. They allow you to define behaviors, and render out images onto the screen.\n\n#### Entity\n\nAn entity is any object that has behavior. They can be typical objects, like an enemy, or obstacle, or they can be systems and services, like a physics service. To use, simply subclass Entity, and overwrite at least one of the four update-phase methods or the on_event method. Then, when the entity is created, it will automatically have those methods called each frame.\n\n```python\n\nclass MyEntity(Entity):\n\n    def __init__(self, container=None, enabled=True):\n        super().__init__(container, enabled)\n        self.position: tuple[int, int] = (0, 0)\n\n\n    def update(self, delta_time: float):\n        keys = pygame.key.get_pressed()\n        x = y = 0\n        if keys[pygame.K_w]:\n            y -= 1\n        if keys[pygame.K_s]:\n            y += 1\n        if keys[pygame.K_a]:\n            x -= 1\n        if keys[pygame.K_d]:\n            x += 1\n        self.move((x, y))\n\n    \n    def move(self, direction: tuple[int, int]):\n        self.position = (\n            self.position[0] + direction[0], self.position[1] + direction[1]\n        )\n```\n\nThis will create a simple entity that will move with the WASD keys. Note, however, that it does not show anything on screen, as it is not renderable.\n\n\n#### Renderables\n\nRenderables are anything that needs to be drawn to the screen. They must implement the render method, which must return a ready-to-draw surface, and the get_rect method, which returns a pygame Rectangle, with the position and size of the renderable.\nClasses can inherit from both Entity and Renderable, to allow them to both be drawn and have behavior.\n\n```python\nclass MyRenderable(Renderable):\n\n    # __init__ here\n\n    def get_rect(self) -\u003e pygame.Rect:\n        return pygame.Rect(100, 50, 10, 10)\n\n    def render(self, delta_time: float):\n        surface = Surface((10, 10))\n        surface.fill(Color(\"fuchsia\"))\n        return surface\n```\n\nThis will draw a small fuchsia square at a world position of 100, 50.\n\n#### UI Elements\n\nThere's a special layer in the the render system, the UI layer. Renderables in the UI layer are always drawn in screen space, not world space.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n### Screen Space vs World Space\n\nIn base pygame, all surfaces are rendered in terms of screen space. This means that changing the resolution changes the size of the display, but not the objects on it. This means either a complicated setup that accounts for the window size before figuring out where to draw everything, or locking down the resolution, never to be changed.\n\nPyrite features a camera system as part of its default renderer. Cameras are moveable and zoomable, and automatically ignore any renderables they can't see, speeding up your game when items are offscreen.\n\nYou can even have multiple cameras, rendered to different parts of the screen!*\n\nRenderables have layers and draw indexes to ensure that everything is drawn in the desired order. You can even add additional layers, and have cameras ignore layers, as needed.\n\nCameras are, or course, optional. Pyrite can treat your world space just like screen space if you don't want/need cameras for your project.\n\n*Currently, multiple cameras slows the game greatly.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- ROADMAP --\u003e\n## Roadmap\n\n- [ ] (Eternal) Improve the renderer. Faster rendering means more renderables!\n\n\u003c!--\n- [ ] Feature 2\n- [ ] Feature 3\n    - [ ] Nested Feature\n--\u003e\n\nSee the [open issues](https://github.com/BetterBuiltFool/pyrite_framework/issues) for a full list of proposed features (and known issues).\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- CONTRIBUTING --\u003e\n\u003c!--\n## Contributing\n\nContributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.\n\nIf you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag \"enhancement\".\nDon't forget to give the project a star! Thanks again!\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n### Top contributors:\n\n\u003ca href=\"https://github.com/BetterBuiltFool/pyrite_framework/graphs/contributors\"\u003e\n  \u003cimg src=\"https://contrib.rocks/image?repo=BetterBuiltFool/pyrite_framework\" alt=\"contrib.rocks image\" /\u003e\n\u003c/a\u003e\n--\u003e\n\n\n\n\u003c!-- LICENSE --\u003e\n## License\n\nDistributed under the MIT License. See `LICENSE.txt` for more information.\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- CONTACT --\u003e\n## Contact\n\nBetter Built Fool - betterbuiltfool@gmail.com\n\nBluesky - [@betterbuiltfool.bsky.social](https://bsky.app/profile/betterbuiltfool.bsky.social)\n\u003c!--\n - [@twitter_handle](https://twitter.com/twitter_handle)\n--\u003e\n\nProject Link: [https://github.com/BetterBuiltFool/pyrite_framework](https://github.com/BetterBuiltFool/pyrite_framework)\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n\n\n\n\u003c!-- ACKNOWLEDGMENTS --\u003e\n\u003c!--## Acknowledgments\n\n* []()\n* []()\n* []()\n\n\u003cp align=\"right\"\u003e(\u003ca href=\"#readme-top\"\u003eback to top\u003c/a\u003e)\u003c/p\u003e\n--\u003e\n\n\n\u003c!-- MARKDOWN LINKS \u0026 IMAGES --\u003e\n\u003c!-- https://www.markdownguide.org/basic-syntax/#reference-style-links --\u003e\n[contributors-shield]: https://img.shields.io/github/contributors/BetterBuiltFool/pyrite_framework.svg?style=for-the-badge\n[contributors-url]: https://github.com/BetterBuiltFool/pyrite_framework/graphs/contributors\n[forks-shield]: https://img.shields.io/github/forks/BetterBuiltFool/pyrite_framework.svg?style=for-the-badge\n[forks-url]: https://github.com/BetterBuiltFool/pyrite_framework/network/members\n[stars-shield]: https://img.shields.io/github/stars/BetterBuiltFool/pyrite_framework.svg?style=for-the-badge\n[stars-url]: https://github.com/BetterBuiltFool/pyrite_framework/stargazers\n[issues-shield]: https://img.shields.io/github/issues/BetterBuiltFool/pyrite_framework.svg?style=for-the-badge\n[issues-url]: https://github.com/BetterBuiltFool/pyrite_framework/issues\n[license-shield]: https://img.shields.io/github/license/BetterBuiltFool/pyrite_framework.svg?style=for-the-badge\n[license-url]: https://github.com/BetterBuiltFool/pyrite_framework/blob/main/LICENSE\n[linkedin-shield]: https://img.shields.io/badge/-LinkedIn-black.svg?style=for-the-badge\u0026logo=linkedin\u0026colorB=555\n[linkedin-url]: https://linkedin.com/in/linkedin_username\n[product-screenshot]: images/screenshot.png\n[Next.js]: https://img.shields.io/badge/next.js-000000?style=for-the-badge\u0026logo=nextdotjs\u0026logoColor=white\n[Next-url]: https://nextjs.org/\n[python.org]: https://img.shields.io/badge/python-3670A0?style=for-the-badge\u0026logo=python\u0026logoColor=ffdd54\n[python-url]: https://www.python.org/\n[React.js]: https://img.shields.io/badge/React-20232A?style=for-the-badge\u0026logo=react\u0026logoColor=61DAFB\n[React-url]: https://reactjs.org/\n[Vue.js]: https://img.shields.io/badge/Vue.js-35495E?style=for-the-badge\u0026logo=vuedotjs\u0026logoColor=4FC08D\n[Vue-url]: https://vuejs.org/\n[Angular.io]: https://img.shields.io/badge/Angular-DD0031?style=for-the-badge\u0026logo=angular\u0026logoColor=white\n[Angular-url]: https://angular.io/\n[Svelte.dev]: https://img.shields.io/badge/Svelte-4A4A55?style=for-the-badge\u0026logo=svelte\u0026logoColor=FF3E00\n[Svelte-url]: https://svelte.dev/\n[Laravel.com]: https://img.shields.io/badge/Laravel-FF2D20?style=for-the-badge\u0026logo=laravel\u0026logoColor=white\n[Laravel-url]: https://laravel.com\n[Bootstrap.com]: https://img.shields.io/badge/Bootstrap-563D7C?style=for-the-badge\u0026logo=bootstrap\u0026logoColor=white\n[Bootstrap-url]: https://getbootstrap.com\n[JQuery.com]: https://img.shields.io/badge/jQuery-0769AD?style=for-the-badge\u0026logo=jquery\u0026logoColor=white\n[JQuery-url]: https://jquery.com \n[pypi-url]: https://pypi.org/project/pyrite-framework\n[pip-url]: https://pip.pypa.io/en/stable/","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetterbuiltfool%2Fpyrite_framework","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbetterbuiltfool%2Fpyrite_framework","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbetterbuiltfool%2Fpyrite_framework/lists"}