- Notifications
You must be signed in to change notification settings - Fork14
Rust 2d game engine, ideal for developing mini-games&app, support terminal, sdl, web modes.
License
zipxing/rust_pixel
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Change Log | Principle | Coding | FAQ | TODO
RustPixel is a2D game engine &rapid prototyping tools, supporting bothtext andgraphics rendering modes.
It is suitable for creating2D pixel-style games and developingterminal applications.
It can be compiled intoFFI for front-end and back-end use, and intoWASM for web projects.
- Text Mode: Built withcrossterm, runs in the terminal, and usesASCII & Unicode Emoji for drawing.
- Graphical Mode (SDL2 & WEB): Built withglow &sdl2, usingPETSCII & custom graphics symbols for rendering.
Here is a petscii art painting browser made withrust_pixel. Special thanks to x.com/PETSCIIWORLD for the character painting and the transition shader provided bygltransition. Click here foronline demo。
petview.mp4
- Game loops & Model/Render design pattern (game.rs)
- Event/Timer messaging mechanism (event.rs)
- Support text render mode (crossterm) (adapter.rs, cross.rs)
- Unified OpenGL drawing mode supports sdl and wasm (glow & sdl2) (adapter.rs, sdl.rs, web.rs)
- 3 core OpenGl shaders for sdl2 & web graphics mode: (gl/)
- gl instance rendering shader for draw mainbuffer (render_symbols.rs)
- gl transition shader for transition effect (render_transition.rs)
- gl general 2d shader for draw render texture (render_general2d.rs)
- Some common game algorithms (algorithm.rs, algorithm/, util.rs, util/)
- audio & log support (audio.rs, log.rs)
- Demo games: tetris, tower, poker... (games/)
- Demo terminal ui app: palette... (apps/)
- Examples of wrapping core algorithms into FFI and WASM (games/poker/ffi, games/poker/wasm)
The main steps of the installation process are as follows:
- InstallDroidSansMono Nerd Font & setup terminal
- Install dependent libraries and softwares
- InstallRust andWasm-pack
The detailed steps for each operating system: MacOS | Linux | Windows
Starting from version 0.5.3, you can deploycargo-pixel directly from crates.io:
cargo install rust_pixel # use crates.io rust_pixel crate deploy cargo-pixelcargo pixel # first run cargo-pixel will clone rust_pixel to <homedir>/rust_pixel_work automatic cd ~/rust_pixel_work # cd to workspacecargo pixel r petview s # run demo game...
To use the newest code, you should cloneRustPixel and deploycargo-pixel tool:
git clone https://github.com/zipxing/rust_pixelcd rust_pixelcargo install --path . --force
If 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:
cd rust_pixelgit pullcargo install --path . --force
cd rust_pixelcargo pixel run snake term #Run the snake game in terminal modecargo pixel r snake t #Run the snake game in terminal mode - shorthandcargo pixel r tetris s #Run the Tetris game in SDL window modecargo pixel r tower w #Run tower in web,visit http://localhost:8080/ in your browsercargo pixel r tower w --webport 8081 #Change web server portcargo pixel r tower w -r #Run with release mode
You can also use cargo pixel to create your own game or app:
cargo pixel c mygame #Create mygame in ./apps using apps/template as a template
Creat a standalone app in some directory:
cargo pixel c myapp .. #Create a standalone crate in ../myapp cd ../myapp cargo pixel r myapp tcargo pixel r myapp s
RustPixel also includes several tools:
- palette: A terminal-ui tool to generate, analyze, convert and manipulate colors.
cargo pixel r palette t -r
- tedit: Used to edit character art assets, example:
#term modecargo pixel r pixel_edit term . assets/logo.txt#graphics modecargo pixel r pixel_edit sdl . assets/logo.pix
- tpetii: Used to convert regular images into PETSCII character art, example:
cargo pixel r pixel_petii t assets/a.png -r > assets/a.pixcargo pixel r pixel_edit s . assets/a.pix
cargo pixel r pixel_petii t assets/lion.png 40 40 -r > assets/lion.pixcargo pixel r pixel_edit s . assets/lion.pix
- Script to automaticallyconvert gif images into PETSCII animations (.ssf)
cargo pixel cg assets/sdq/fire.gif assets/sdq/fire.ssf 40 25
- snake: A snake game with a cool PETSCII animations
#graphics modecargo pixel r snake s -r
#term modecargo pixel r snake t -r
#web modecargo pixel r snake w -r#and visit http://localhost:8080/ in your browser
- tetris: A Tetris game where you can play against AI
#term modecargo pixel r tetris t -r
#graphics modecargo pixel r tetris s -r
#web modecargo pixel r tetris w -r#and visit http://localhost:8080/ in your browser
- poker: Includes the core algorithms for Texas Hold'em and Gin Rummy
cargo pixel r poker t -rcargo pixel r gin_rummy t -r
The poker/ffi directory demo how to wrap Rust algorithms into CFFI for use with other languages, showcasing C++ and Python calling poker_ffi
cd games/poker/ffimake run
The poker/wasm directory demo how to wrap Rust algorithms into wasm for JS calling
cd games/poker/wasmmake run
- tower: A tower defense game prototype demonstrating the use of objpool and pixel_sprite for pixel-perfect sprite movement
#graphics modecargo pixel r tower s -r#web modecargo pixel r tower w -r#and visit http://localhost:8080/ in your browser
and so on ... ...
About
Rust 2d game engine, ideal for developing mini-games&app, support terminal, sdl, web modes.
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.
Contributors3
Uh oh!
There was an error while loading.Please reload this page.