Crate quicksilver[−][src]
quicksilver
A 2D game framework written in pure Rust
A quick example
// Draw some multi-colored geometry to the screen extern crate quicksilver; use quicksilver::{ State, run, geom::{Circle, Rectangle, Transform}, graphics::{Color, Draw, Window, WindowBuilder} }; struct DrawGeometry; impl State for DrawGeometry { fn new() -> DrawGeometry { DrawGeometry } fn draw(&mut self, window: &mut Window) { window.clear(Color::black()); window.draw(&Draw::rectangle(Rectangle::new(100, 100, 32, 32)).with_color(Color::red())); window.draw(&Draw::rectangle(Rectangle::new(400, 300, 32, 32)).with_color(Color::blue()).with_transform(Transform::rotate(45)).with_z(10)); window.draw(&Draw::circle(Circle::new(400, 300, 100)).with_color(Color::green())); window.present(); } } fn main() { run::<DrawGeometry>(WindowBuilder::new("Draw Geometry", 800, 600)); }
Run this with cargo run
or, if you have the wasm32 toolchain installed, you can build for the web
(instructions in the quicksilver README
You should see a red square in the top-left, and a green circle with a blue rectangle inside it on the bottom-right.
Optional Features
Quicksilver by default tries to provide all features a 2D application may need, but not all applications need these features. The optional features available are collision support (via ncollide2d), font support (via rusttype), gamepad support (via gilrs), saving (via serde_json), and sounds (via rodio).
Each are enabled by default, but you can specify which features you actually want to use.
Modules
geom |
A 2D geometry module |
graphics |
A module to draw 2D graphics in a window It also includes image loading |
input |
A collection of polling input structures |
saving |
A module for saving / loading application data |
sound |
A sound API that allows playing clips at given volumes |
Structs
FileLoader |
A Future that loads a file into an owned Vec of bytes |
Timer |
A structure that allows accumulation of actions in a loop |
Enums
Async |
Return type of future, indicating whether a value is ready or not. |
QuicksilverError |
An error generated by some Quicksilver subsystem |
Traits
Future |
Trait for types which are a placeholder of a value that may become available at some later point in time. |
State |
The structure responsible for managing the game loop state |
Functions
run |
Run the application's game loop |