{"id":14151100,"url":"https://github.com/zipxing/rust_pixel","last_synced_at":"2025-08-05T17:33:00.481Z","repository":{"id":244345101,"uuid":"814971321","full_name":"zipxing/rust_pixel","owner":"zipxing","description":"Rust 2d game engine, ideal for developing mini-games\u0026app, support terminal, sdl, web modes.","archived":false,"fork":false,"pushed_at":"2024-11-21T07:40:15.000Z","size":38683,"stargazers_count":148,"open_issues_count":0,"forks_count":14,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-11-21T08:24:47.817Z","etag":null,"topics":[],"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/zipxing.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}},"created_at":"2024-06-14T04:48:27.000Z","updated_at":"2024-11-21T07:40:18.000Z","dependencies_parsed_at":"2024-09-15T07:03:03.811Z","dependency_job_id":"4c0d23a5-ee1f-4a65-be3c-e013d8a07939","html_url":"https://github.com/zipxing/rust_pixel","commit_stats":null,"previous_names":["zipxing/rust_pixel"],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zipxing%2Frust_pixel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zipxing%2Frust_pixel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zipxing%2Frust_pixel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zipxing%2Frust_pixel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zipxing","download_url":"https://codeload.github.com/zipxing/rust_pixel/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228781769,"owners_count":17971509,"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-08-17T04:00:52.618Z","updated_at":"2025-08-05T17:33:00.431Z","avatar_url":"https://github.com/zipxing.png","language":"Rust","readme":"![logo](./screen-shot/logo.png)\n\n![License] [![Latest Version]][crates.io] ![Downloads] [![API Documentation]][docs.rs] ![MSRV]\n\n[License]: https://img.shields.io/badge/license-Apache2.0-blue.svg\n[Latest Version]: https://img.shields.io/crates/v/rust_pixel.svg\n[crates.io]: https://crates.io/crates/rust_pixel\n[Downloads]: https://img.shields.io/crates/d/rust_pixel.svg\n[API Documentation]: https://docs.rs/rust_pixel/badge.svg\n[docs.rs]: https://docs.rs/rust_pixel\n[MSRV]: https://img.shields.io/badge/rust-1.71+-brightgreen.svg?\u0026logo=rust\n\n[Change Log]\u0026nbsp; | \u0026nbsp;[Principle]\u0026nbsp; | \u0026nbsp;[Coding]\u0026nbsp; | \u0026nbsp;[FAQ]\u0026nbsp; | \u0026nbsp;[TODO]\u0026nbsp; | \u0026nbsp;[Art Center Roadmap]\n\n[Change Log]: doc/change.md\n[Principle]: doc/principle.md\n[Coding]: doc/coding.md\n[FAQ]: doc/faq.md\n[TODO]: doc/todo.md\n[Art Center Roadmap]: doc/ascii_art_center_roadmap.md\n\nRustPixel is a **2D game engine** \u0026 **rapid prototyping tools**, supporting both **text** and **graphics** rendering modes.\u003cbr\u003e\nIt is suitable for creating **2D pixel-style games** and developing **terminal applications**.\u003cbr\u003e\nIt can be compiled into **FFI** for front-end and back-end use, and into **WASM** for web projects.\n\n- Text Mode: Built with **crossterm**, runs in the terminal, and uses **ASCII \u0026 Unicode Emoji** for drawing.\n- Graphical Mode: Built with **wgpu** \u0026 **glow** \u0026 **sdl2**, using **PETSCII/ASCII \u0026 custom graphics symbols** for rendering.\n\n[online demo]: https://zipxing.github.io/rust_pixel\n\nHere is a petscii art painting browser made with **rust_pixel**. Special thanks to x.com/PETSCIIWORLD for the character painting and the transition shader provided by **gltransition**. Click here for [online demo]。\n\nhttps://github.com/user-attachments/assets/4758f2b6-66c2-47ed-997d-a9066be449aa\n\n### Features\n\n- Game loops \u0026 Model/Render design pattern (game.rs)\n- Event/Timer messaging mechanism (event.rs)\n- Unified render adapter trait for text \u0026 graphics mode( adapter.rs ) \n- Support text render mode (crossterm) (cross_adapter.rs)\n- OpenGL mode supports sdl and wasm (glow \u0026 sdl2 | winit) (sdl_adapter.rs, winit_glow_adapter.rs, web_adapter.rs)\n- Wgpu drawing mode (winit \u0026 wgpu) (winit_wgpu_adapter.rs)\n- 3 core OpenGl shaders for gl \u0026 web graphics mode: (gl/) \n- 3 core Wgpu shaders for wgpu graphics mode: (wgpu/) \n    - instance rendering shader for draw mainbuffer (render_symbols.rs) \n    - transition shader for transition effect (render_transition.rs)\n    - general 2d shader for draw render texture (render_general2d.rs)\n- Some common game algorithms (algorithm.rs, algorithm/, util.rs, util/)\n- audio \u0026 log support (audio.rs, log.rs)\n- Demo games: tetris, tower, poker... (apps/)\n- Demo terminal ui app: palette... (apps/)\n- Examples of wrapping core algorithms into FFI and WASM (apps/poker/ffi, apps/poker/wasm)\n- Cargo style cli tool: cargo-pixel\n\n### Installation Guide\n\nThe main steps of the installation process are as follows:\n- Install [DroidSansMono Nerd Font] \u0026 setup terminal (for text render mode)\n- Install dependent libraries and softwares\n- Install **Rust** and **Wasm-pack**\n\nThe detailed steps for each operating system: \u0026nbsp;\u0026nbsp;[MacOS]\u0026nbsp;\u0026nbsp; | \u0026nbsp;\u0026nbsp;[Linux]\u0026nbsp;\u0026nbsp; | \u0026nbsp;\u0026nbsp;[Windows (WSL)]\u0026nbsp;\u0026nbsp; | \u0026nbsp;\u0026nbsp;[Windows (Native)]\n\n[MacOS]: doc/mac.md\n[Linux]: doc/linux.md\n[Windows (WSL)]: doc/win.md\n[Windows (Native)]: doc/win-native.md\n[DroidSansMono Nerd Font]: https://github.com/ryanoasis/nerd-fonts\n\nStarting from version 0.5.3, you can deploy **cargo-pixel** directly from crates.io:\n```\ncargo install rust_pixel         # use crates.io rust_pixel crate deploy cargo-pixel\ncargo pixel                      # first run cargo-pixel will clone rust_pixel to \u003chomedir\u003e/rust_pixel_work automatic \ncd ~/rust_pixel_work             # cd to workspace\ncargo pixel r petview s          # run demo game...\n```\n\nTo use the newest code, you should clone **RustPixel** and deploy **cargo-pixel** tool:\n``` \ngit clone https://github.com/zipxing/rust_pixel\ncd rust_pixel\ncargo install --path . --force\n``` \n\nIf you have installed an old version of cargo-pixel, you may get an error when running it. git update is required and the new version of cargo-pixel is deployed manually:\n```\ncd rust_pixel\ngit pull\ncargo install --path . --force\n```\n\n### Usage Instructions\n``` \ncd rust_pixel\ncargo pixel run snake term            #Run the snake game in terminal mode\ncargo pixel r snake t                 #Run the snake game in terminal mode - shorthand\ncargo pixel r tetris s                #Run the Tetris game in SDL window mode\ncargo pixel r tower w                 #Run tower in web,visit http://localhost:8080/ in your browser\ncargo pixel r tower w --webport 8081  #Change web server port\ncargo pixel r tower w -r              #Run with release mode\ncargo pixel r petview g -r            #Run the petview game in winit+glow mode\ncargo pixel r petview wg -r           #Run the petview game in winit+wgpu mode\n``` \n\nYou can also use cargo pixel to create your own game or app:\n```\ncargo pixel c mygame           #Create mygame in ./apps using apps/template as a template\n```\nCreat a standalone app in some directory:\n```\ncargo pixel c myapp ..  #Create a standalone crate in ../myapp \ncd ../myapp \ncargo pixel r myapp t\ncargo pixel r myapp s\n\n```\n\nRustPixel also includes several tools:\n1. **palette**: A terminal-ui tool to generate, analyze, convert and manipulate colors.\n```\ncargo pixel r palette t -r\n```\n ![palette](./screen-shot/palette.gif)\n\n2. **edit**: Used to edit character art assets, example:\n``` \n#term mode\ncargo pixel edit term . assets/logo.txt\nor\ncargo pixel e t . assets/logo.txt\n\n#graphics mode\ncargo pixel edit sdl . assets/logo.pix\nor \ncargo pixel e s . assets/logo.pix\n```\n ![tedit_t](./screen-shot/tedit_term.png)\n ![tedit_s](./screen-shot/tedit_sdl.png)\n\n3. **petii**: Used to convert regular images into PETSCII character art, example:\n```\ncargo pixel p assets/a.png \u003e a.pix\ncargo pixel e g . assets/a.pix\n```\n```\ncargo pixel p assets/lion.png 40 40 \u003e assets/lion.pix\ncargo pixel e g . assets/lion.pix\n```\n ![tpetii_1](./screen-shot/a.png)\n ![tpetii_2](./screen-shot/lion.png)\n\n4. Script to automatically **convert gif images into PETSCII animations (.ssf)**\n```\ncargo pixel cg assets/sdq/fire.gif assets/sdq/fire.ssf 40 25 \ncargo pixel ssf . assets/sdq/fire.ssf       # preview ssf \n```\n\n### Demo games\n1. snake: A snake game with a cool PETSCII animations\n```\n#graphics mode\ncargo pixel r snake s -r\n```\n\n![graphics mode](./screen-shot/snake_sdl.gif)\n\n``` \n#term mode\ncargo pixel r snake t -r\n```\n\n```\n#web mode\ncargo pixel r snake w -r\n#and visit http://localhost:8080/ in your browser\n```\n\n2. tetris: A Tetris game where you can play against AI\n``` \n#term mode\ncargo pixel r tetris t -r\n```\n\n ![term mode](./screen-shot/tetris_term.gif)\n\n```\n#graphics mode\ncargo pixel r tetris s -r\n```\n\n![graphics mode](./screen-shot/tetris_sdl.gif)\n\n```\n#web mode\ncargo pixel r tetris w -r\n#and visit http://localhost:8080/ in your browser\n```\n\n![web mode](./screen-shot/tetris_web.gif)\n\n3. poker: Includes the core algorithms for Texas Hold'em and Gin Rummy\n``` \ncargo pixel r poker t -r\ncargo pixel r gin_rummy t -r\n```\n ![gin_rummy](./screen-shot/ginrummy.png)\n ![red_black](./screen-shot/redblack.png)\n\nThe poker/ffi directory demo how to wrap Rust algorithms into CFFI for use with other languages, showcasing C++ and Python calling poker_ffi\n```\ncd apps/poker/ffi\nmake run\n```\nThe poker/wasm directory demo how to wrap Rust algorithms into wasm for JS calling\n```\ncd apps/poker/wasm\nmake run\n```\n\n4. tower: A tower defense game prototype demonstrating the use of objpool and pixel_sprite for pixel-perfect sprite movement\n``` \n#graphics mode\ncargo pixel r tower s -r\n\n#web mode\ncargo pixel r tower w -r\n#and visit http://localhost:8080/ in your browser\n```\n ![tower](./screen-shot/tower_sdl.gif)\n\nand so on ... ...\n\n\n\n","funding_links":[],"categories":["Programming","Applications","Recently Updated"],"sub_categories":["Rust 🦀","Games","[Oct 06, 2024](/content/2024/10/06/README.md)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzipxing%2Frust_pixel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzipxing%2Frust_pixel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzipxing%2Frust_pixel/lists"}