{"id":23007443,"url":"https://github.com/xor-bits/main_game_loop","last_synced_at":"2025-07-07T01:32:37.148Z","repository":{"id":62444267,"uuid":"477683594","full_name":"xor-bits/main_game_loop","owner":"xor-bits","description":null,"archived":false,"fork":false,"pushed_at":"2022-11-27T23:17:20.000Z","size":195,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-03-15T01:03:59.393Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/xor-bits.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-04-04T12:07:02.000Z","updated_at":"2023-04-03T12:02:44.000Z","dependencies_parsed_at":"2023-01-22T05:37:56.816Z","dependency_job_id":null,"html_url":"https://github.com/xor-bits/main_game_loop","commit_stats":null,"previous_names":["overpeek/main_game_loop"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xor-bits%2Fmain_game_loop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xor-bits%2Fmain_game_loop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xor-bits%2Fmain_game_loop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xor-bits%2Fmain_game_loop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xor-bits","download_url":"https://codeload.github.com/xor-bits/main_game_loop/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246837615,"owners_count":20841906,"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":[],"created_at":"2024-12-15T08:15:38.314Z","updated_at":"2025-04-02T15:21:21.631Z","avatar_url":"https://github.com/xor-bits.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# main_game_loop\n\n[![dependency status](https://deps.rs/repo/github/Overpeek/main_game_loop/status.svg)](https://deps.rs/repo/github/Overpeek/main_game_loop)\n[![build status](https://github.com/Overpeek/main_game_loop/actions/workflows/rust.yml/badge.svg)](https://github.com/Overpeek/main_game_loop/actions)\n[![crates.io](https://img.shields.io/crates/v/main_game_loop.svg?label=main_game_loop)](https://crates.io/crates/main_game_loop)\n[![docs.rs](https://docs.rs/main_game_loop/badge.svg)](https://docs.rs/main_game_loop/)\n\n\u003c/div\u003e\n\n### Example usage with some random `Engine`\n\n```rust\nstruct App {\n    window: Window,\n    ws: WindowState,\n    update_loop: UpdateLoop,\n}\n\nimpl App {\n    fn init(target: \u0026EventLoopTarget) -\u003e Self {\n        let window = WindowBuilder::new().build(target).unwrap();\n        let ws = WindowState::new(\u0026window);\n        let update_loop = UpdateLoop::new(UpdateRate::PerSecond(60));\n\n        Self {\n            window,\n            ws,\n            update_loop,\n        }\n    }\n\n    fn event(\u0026mut self, event: Event, _: \u0026EventLoopTarget, control: \u0026mut ControlFlow) {\n        self.ws.event(\u0026event);\n\n        if self.ws.should_close {\n            *control = ControlFlow::Exit;\n        }\n    }\n\n    fn draw(\u0026mut self) {\n        self.update_loop.update(|| {\n            // update();\n        });\n\n        // draw();\n    }\n}\n\nfn main() {\n    run_app!(App);\n}\n```\n\n### Example usage with different init, event and draw functions\n\n```rust\nuse main_game_loop::prelude::*;\n\nstruct App {\n    // ...\n}\n\nasync fn init(target: \u0026EventLoopTarget) -\u003e App {\n    // init\n\n    App {\n        // ..\n    }\n}\n\nimpl App {\n    fn draw(\u0026mut self) {\n        // draw\n    }\n}\n\n#[tokio::main]\nasync fn main() {\n    run_app!(\n        async init,\n        |_, _, _, _| {\n            // events\n        },\n        App::draw\n    );\n}\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxor-bits%2Fmain_game_loop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxor-bits%2Fmain_game_loop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxor-bits%2Fmain_game_loop/lists"}