{"id":13534420,"url":"https://github.com/not-fl3/macroquad","last_synced_at":"2025-05-14T07:05:03.940Z","repository":{"id":37019882,"uuid":"232636908","full_name":"not-fl3/macroquad","owner":"not-fl3","description":"Cross-platform game engine in Rust. ","archived":false,"fork":false,"pushed_at":"2025-05-04T13:59:40.000Z","size":19825,"stargazers_count":3735,"open_issues_count":298,"forks_count":360,"subscribers_count":35,"default_branch":"master","last_synced_at":"2025-05-07T06:38:32.829Z","etag":null,"topics":["android","game-engine","ios","rust","wasm"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/not-fl3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE-APACHE","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},"funding":{"patreon":"fedorgames","github":"not-fl3"}},"created_at":"2020-01-08T19:01:01.000Z","updated_at":"2025-05-06T22:25:50.000Z","dependencies_parsed_at":"2023-02-18T00:55:16.980Z","dependency_job_id":"5803f74a-792b-490b-8852-d31b7dcb7d05","html_url":"https://github.com/not-fl3/macroquad","commit_stats":{"total_commits":676,"total_committers":148,"mean_commits":"4.5675675675675675","dds":0.4171597633136095,"last_synced_commit":"455f3fba8ed8d2e214f847c417eb964d101d4cf5"},"previous_names":[],"tags_count":26,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/not-fl3%2Fmacroquad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/not-fl3%2Fmacroquad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/not-fl3%2Fmacroquad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/not-fl3%2Fmacroquad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/not-fl3","download_url":"https://codeload.github.com/not-fl3/macroquad/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254092648,"owners_count":22013290,"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":["android","game-engine","ios","rust","wasm"],"created_at":"2024-08-01T07:01:32.630Z","updated_at":"2025-05-14T07:05:03.897Z","avatar_url":"https://github.com/not-fl3.png","language":"Rust","readme":"# macroquad\n\n[![Github Actions](https://github.com/not-fl3/macroquad/workflows/CI/badge.svg)](https://github.com/not-fl3/macroquad/actions?query=workflow%3A)\n[![Docs](https://docs.rs/macroquad/badge.svg?version=0.4.5)](https://docs.rs/macroquad/0.4.5/macroquad/index.html)\n[![Crates.io version](https://img.shields.io/crates/v/macroquad.svg)](https://crates.io/crates/macroquad)\n[![Discord chat](https://img.shields.io/discord/710177966440579103.svg?label=discord%20chat)](https://discord.gg/WfEp6ut)\n\n`macroquad` is a simple and easy to use game library for Rust programming language, heavily inspired by [raylib](https://github.com/raysan5/raylib).\n\n## Features\n\n* Same code for all supported platforms, no platform dependent defines required.\n* Efficient 2D rendering with automatic geometry batching.\n* Minimal amount of dependencies: build after `cargo clean` takes only 16s on x230(~6 years old laptop).\n* Immediate mode UI library included.\n* Single command deploy for both WASM and Android.\n\n## Supported Platforms\n\n* PC: Windows/Linux/macOS;\n* HTML5;\n* Android;\n* IOS.\n\n## Build Instructions\n\n### Setting Up a Macroquad Project\n\nMacroquad is a normal rust dependency, therefore an empty macroquad project may be created with:\n\n```bash\n# Create empty cargo project\ncargo init --bin\n```\n\nAdd macroquad as a dependency to Cargo.toml:\n```toml\n\n[dependencies]\nmacroquad = \"0.4\"\n```\n\nPut some macroquad code in `src/main.rs`:\n```rust\nuse macroquad::prelude::*;\n\n#[macroquad::main(\"BasicShapes\")]\nasync fn main() {\n    loop {\n        clear_background(RED);\n\n        draw_line(40.0, 40.0, 100.0, 200.0, 15.0, BLUE);\n        draw_rectangle(screen_width() / 2.0 - 60.0, 100.0, 120.0, 60.0, GREEN);\n        draw_circle(screen_width() - 30.0, screen_height() - 30.0, 15.0, YELLOW);\n\n        draw_text(\"IT WORKS!\", 20.0, 20.0, 30.0, DARKGRAY);\n\n        next_frame().await\n    }\n}\n```\n\nAnd to run it natively:\n```bash\ncargo run\n```\n\nFor more examples take a look at [Macroquad examples folder](https://github.com/not-fl3/macroquad/tree/master/examples)\n\n### Linux\n\n```bash\n# ubuntu system dependencies\napt install pkg-config libx11-dev libxi-dev libgl1-mesa-dev libasound2-dev\n\n# fedora system dependencies\ndnf install libX11-devel libXi-devel mesa-libGL-devel alsa-lib-devel\n\n# arch linux system dependencies\n pacman -S pkg-config libx11 libxi mesa-libgl alsa-lib\n```\n\n### Windows\n\nOn windows both MSVC and GNU target are supported, no additional dependencies required.\n\nAlso cross-compilation to windows from linux is supported:\n\n```sh\nrustup target add x86_64-pc-windows-gnu\n\ncargo run --target x86_64-pc-windows-gnu\n```\n\n### WASM\n\n```sh\nrustup target add wasm32-unknown-unknown\ncargo build --target wasm32-unknown-unknown\n```\n\nThis will produce .wasm file in `target/debug/wasm32-unknown-unknown/CRATENAME.wasm` or in `target/release/wasm32-unknown-unknown/CRATENAME.wasm` if built with `--release`.\n\nAnd then use the following .html to load it:\n\n\u003cdetails\u003e\u003csummary\u003eindex.html\u003c/summary\u003e\n\n```html\n\u003chtml lang=\"en\"\u003e\n\n\u003chead\u003e\n    \u003cmeta charset=\"utf-8\"\u003e\n    \u003ctitle\u003eTITLE\u003c/title\u003e\n    \u003cstyle\u003e\n        html,\n        body,\n        canvas {\n            margin: 0px;\n            padding: 0px;\n            width: 100%;\n            height: 100%;\n            overflow: hidden;\n            position: absolute;\n            background: black;\n            z-index: 0;\n        }\n    \u003c/style\u003e\n\u003c/head\u003e\n\n\u003cbody\u003e\n    \u003ccanvas id=\"glcanvas\" tabindex='1'\u003e\u003c/canvas\u003e\n    \u003c!-- Minified and statically hosted version of https://github.com/not-fl3/macroquad/blob/master/js/mq_js_bundle.js --\u003e\n    \u003cscript src=\"https://not-fl3.github.io/miniquad-samples/mq_js_bundle.js\"\u003e\u003c/script\u003e\n    \u003cscript\u003eload(\"CRATENAME.wasm\");\u003c/script\u003e \u003c!-- Your compiled wasm file --\u003e\n\u003c/body\u003e\n\n\u003c/html\u003e\n```\n\u003c/details\u003e\n\nOne of the ways to server static .wasm and .html:\n\n```sh\ncargo install basic-http-server\nbasic-http-server .\n```\n\n### IOS\n\nTo run on the simulator:\n\n```\nmkdir MyGame.app\ncargo build --target x86_64-apple-ios --release\ncp target/release/mygame MyGame.app\n# only if the game have any assets\ncp -r assets MyGame.app\ncat \u003e MyGame.app/Info.plist \u003c\u003c EOF\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003c!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"\u003e\n\u003cplist version=\"1.0\"\u003e\n\u003cdict\u003e\n\u003ckey\u003eCFBundleExecutable\u003c/key\u003e\n\u003cstring\u003emygame\u003c/string\u003e\n\u003ckey\u003eCFBundleIdentifier\u003c/key\u003e\n\u003cstring\u003ecom.mygame\u003c/string\u003e\n\u003ckey\u003eCFBundleName\u003c/key\u003e\n\u003cstring\u003emygame\u003c/string\u003e\n\u003ckey\u003eCFBundleVersion\u003c/key\u003e\n\u003cstring\u003e1\u003c/string\u003e\n\u003ckey\u003eCFBundleShortVersionString\u003c/key\u003e\n\u003cstring\u003e1.0\u003c/string\u003e\n\u003c/dict\u003e\n\u003c/plist\u003e\nEOF\n\nxcrun simctl install booted MyGame.app/\nxcrun simctl launch booted com.mygame\n```\n\nFor details and instructions on provisioning for real iphone, check [https://macroquad.rs/articles/ios/](https://macroquad.rs/articles/ios/)\n\n\u003cdetails\u003e\n\u003csummary\u003eTips\u003c/summary\u003e\nAdding the following snippet to your Cargo.toml ensures that all dependencies compile in release even in debug mode. In macroquad, this has the effect of making images load several times faster and your applications much more performant, while keeping compile times miraculously low.\n\n```toml\n[profile.dev.package.'*']\nopt-level = 3\n```\n\u003c/details\u003e\n\n## async/await\n\nWhile macroquad attempts to use as few Rust-specific concepts as possible, `.await` in all examples looks a bit scary.\nRust's `async/await` is used to solve just one problem - cross platform main loop organization.\n\n\u003cdetails\u003e\n\u003csummary\u003eDetails\u003c/summary\u003e\n\n\nThe problem: on WASM and android it's not really easy to organize the main loop like this:\n```\nfn main() {\n    // do some initialization\n\n    // start main loop\n    loop {\n        // handle input\n\n        // update logic\n\n        // draw frame\n    }\n}\n```\n\nIt is fixable on Android with threads, but on web there is not way to \"pause\" and \"resume\" WASM execution, so no WASM code should block ever.\nWhile that loop is blocking for the entire game execution!\nThe C++ solution for that problem: https://kripken.github.io/blog/wasm/2019/07/16/asyncify.html\n\nBut in Rust we have async/await. Rust's `futures` are basically continuations - `future`'s stack may be stored into a variable to pause/resume execution of future's code at a later point.\n\nasync/await support in macroquad comes without any external dependencies - no runtime, no executors and futures-rs is not involved. It's just a way to preserve `main`'s stack on WASM and keep the code cross platform without any WASM-specific main loop.\n\u003c/Details\u003e\n\n## Community\n\n- [Quads Discord server](https://discord.gg/WfEp6ut) - a place to chat with the library's devs and other community members.\n- [Awesome Quads](https://github.com/ozkriff/awesome-quads) - a curated list of links to miniquad/macroquad-related code \u0026 resources.\n\n# Platinum sponsors\n\nMacroquad is supported by:\n\n[SourceGear](https://www.sourcegear.com/)\n","funding_links":["https://patreon.com/fedorgames","https://github.com/sponsors/not-fl3"],"categories":["Code","Rust","Game engines","Libraries"],"sub_categories":["Engines and Frameworks","Rust"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnot-fl3%2Fmacroquad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnot-fl3%2Fmacroquad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnot-fl3%2Fmacroquad/lists"}