{"id":26997186,"url":"https://github.com/jiggly-balls/game-state","last_synced_at":"2026-01-02T09:31:25.011Z","repository":{"id":271092475,"uuid":"878767416","full_name":"Jiggly-Balls/game-state","owner":"Jiggly-Balls","description":"A pygame utility package that allows you to handle different screens in an organized manner.","archived":false,"fork":false,"pushed_at":"2025-06-28T15:23:01.000Z","size":274,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-28T16:40:33.954Z","etag":null,"topics":["game","oop","pygame","pygame-ce","python","python3","state-management","utility"],"latest_commit_sha":null,"homepage":"https://game-state.readthedocs.io/en/stable/","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/Jiggly-Balls.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-10-26T04:03:08.000Z","updated_at":"2025-06-28T15:23:04.000Z","dependencies_parsed_at":"2025-01-05T13:22:19.622Z","dependency_job_id":"fcc55147-c258-40a4-ad46-8d6f8b933a80","html_url":"https://github.com/Jiggly-Balls/game-state","commit_stats":null,"previous_names":["jiggly-ball/game-state","jiggly-balls/game-state"],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/Jiggly-Balls/game-state","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jiggly-Balls%2Fgame-state","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jiggly-Balls%2Fgame-state/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jiggly-Balls%2Fgame-state/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jiggly-Balls%2Fgame-state/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jiggly-Balls","download_url":"https://codeload.github.com/Jiggly-Balls/game-state/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jiggly-Balls%2Fgame-state/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266302981,"owners_count":23908275,"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","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["game","oop","pygame","pygame-ce","python","python3","state-management","utility"],"created_at":"2025-04-04T02:17:08.175Z","updated_at":"2026-01-02T09:31:25.006Z","avatar_url":"https://github.com/Jiggly-Balls.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n[![PyPI](https://img.shields.io/pypi/v/game-state.svg?style=for-the-badge\u0026logo=pypi\u0026color=blueviolet\u0026logoColor=white)](https://pypi.org/project/game-state/)\n[![Github Releases](https://img.shields.io/github/v/release/Jiggly-Balls/game-state?color=blueviolet\u0026include_prereleases\u0026label=Latest%20Release\u0026logo=github\u0026sort=semver\u0026style=for-the-badge\u0026logoColor=white)](https://github.com/Jiggly-Balls/game-state/releases)\n[![Downloads](https://img.shields.io/pypi/dm/game-state?label=Downloads%20/%20Month\u0026color=blueviolet\u0026logo=pypi\u0026logoColor=white\u0026style=for-the-badge)](https://pypi.org/project/game-state/)\n[![PyPI Downloads](https://img.shields.io/pepy/dt/game-state?label=Total%20Downloads\u0026color=blueviolet\u0026logo=pypi\u0026logoColor=white\u0026style=for-the-badge)](https://pepy.tech/projects/game-state)\n[![License](https://img.shields.io/pypi/l/game-state?color=blueviolet\u0026logo=c\u0026logoColor=white\u0026style=for-the-badge)](https://github.com/Jiggly-Balls/game-state/blob/main/LICENSE)\n[![Docs](https://img.shields.io/readthedocs/game-state?color=blueviolet\u0026logo=readthedocs\u0026logoColor=white\u0026style=for-the-badge)](https://game-state.readthedocs.io/en/latest/)\n![Versions](https://img.shields.io/badge/Python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11%20%7C%203.12%20%7C%203.13%20%7C%203.14-blue?color=blueviolet\u0026logo=python\u0026logoColor=white\u0026style=for-the-badge)\n\n\u003c/div\u003e\n\n# Game-State\n\nA state machine for organizing different in-game screens in python.\n\n## Table of Contents\n\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Getting Started](#getting-started)\n- [Links](#links)\n\n### Requirements\n\nThis library supports python versions `3.8` - `3.14`.\n\n### Installation\n\nCreate and activate a virtual environment in your workspace (optional) and run the following command-\n\n```\npip install game_state\n```\n\n\u003e **Note:** This package does not have any dependancy on `pygame`, hence you will need to install them separately on your own. This gives you the freedom to work with `pygame`, `pygame-ce` or any of it's forks.\n\n### Getting Started\n\nThis is an example of creating two screens.\nOne displaying green colour and the other blue with a player.\n\n```py\nimport pygame\nfrom game_state import State, StateManager\nfrom game_state.utils import MISSING\n\n\nGREEN = (0, 255, 0)\nBLUE = (0, 0, 255)\nspeed = 200\npygame.init()\npygame.display.init()\npygame.display.set_caption(\"Game State Example\")\n\n\nclass MyBaseState(State[\"MyBaseState\"]):\n    screen: pygame.Surface = MISSING\n\n\nclass MainMenuState(MyBaseState, state_name=\"MainMenu\"):\n    def process_event(self, event: pygame.event.Event) -\u003e None:\n        if event.type == pygame.QUIT:\n            self.manager.is_running = False\n\n        if event.type == pygame.KEYDOWN and event.key == pygame.K_w:\n            self.manager.change_state(\"Game\")\n\n    def process_update(self, *args: float) -\u003e None:\n        self.screen.fill(GREEN)\n        pygame.display.update()\n\n\nclass GameState(MyBaseState, state_name=\"Game\"):\n    def __init__(self) -\u003e None:\n        self.player_x: float = 250.0\n\n    def process_event(self, event: pygame.event.Event) -\u003e None:\n        if event.type == pygame.QUIT:\n            self.manager.is_running = False\n\n        if event.type == pygame.KEYDOWN and event.key == pygame.K_w:\n            self.manager.change_state(\"MainMenu\")\n\n    def process_update(self, *args: float) -\u003e None:\n        dt = args[0]\n\n        self.screen.fill(BLUE)\n\n        # Player movement-\n        pressed = pygame.key.get_pressed()\n        if pressed[pygame.K_a]:\n            self.player_x -= speed * dt\n\n        if pressed[pygame.K_d]:\n            self.player_x += speed * dt\n\n        pygame.draw.rect(\n            self.screen,\n            \"red\",\n            (\n                self.player_x,\n                100,\n                50,\n                50,\n            ),\n        )\n        pygame.display.update()\n\n\ndef main() -\u003e None:\n    screen = pygame.display.set_mode((500, 600))\n\n    state_manager = StateManager[MyBaseState](\n        bound_state_type=MyBaseState, screen=screen\n    )\n    state_manager.load_states(MainMenuState, GameState)\n    state_manager.change_state(\"MainMenu\")\n\n    clock = pygame.time.Clock()\n\n    while state_manager.is_running:\n        dt = clock.tick(60) / 1000\n\n        for event in pygame.event.get():\n            state_manager.current_state.process_event(event)\n\n        state_manager.current_state.process_update(dt)\n\n\nif __name__ == \"__main__\":\n    main()\n\n```\n\nYou can have a look at the [game state guide](https://game-state.readthedocs.io/en/latest/guide.html#using-the-library) for a more detailed explaination.\n\n### Links\n\n- Guide \u0026 API Reference: https://game-state.readthedocs.io/en/stable/\n- PyPI Page: https://pypi.org/project/game-state/\n- Github Page: https://github.com/Jiggly-Balls/game-state/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiggly-balls%2Fgame-state","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiggly-balls%2Fgame-state","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiggly-balls%2Fgame-state/lists"}