Crates.io | quicksilver |
lib.rs | quicksilver |
version | 0.4.0 |
source | src |
created_at | 2018-01-07 18:50:47.819837 |
updated_at | 2020-10-14 02:34:25.843862 |
description | A simple game framework for 2D games in pure Rust |
homepage | https://ryanisaacg.github.io/quicksilver |
repository | https://github.com/ryanisaacg/quicksilver |
max_upload_size | |
id | 45862 |
size | 664,507 |
A simple 2D game framework written in pure Rust, for both the Web and Desktop
I've posted an update on my website about Quicksilver. To keep a long story short: Quicksilver is no longer actively developed. For now I will continue to triage bugs and pull requests and (maybe) fix small bugs.
This version of Quicksilver is currently working its way through alpha! There is still work to do on the API and on bugfixes, as well as waiting on an upstream library for audio support. Please feel free to use this version and provide feedback! If you run into bugs or want to give feedback on API decisions, please open an issue.
Create a rust project and add this line to your Cargo.toml
file under [dependencies]
:
quicksilver = "0.4.0-alpha0.6"
Then replace src/main.rs
with the following (the contents of quicksilver's
examples/01_square.rs
):
// Example 1: The Square
// Open a window, and draw a colored square in it
use quicksilver::{
geom::{Rectangle, Vector},
graphics::Color,
run, Graphics, Input, Result, Settings, Window,
};
fn main() {
run(
Settings {
title: "Square Example",
..Settings::default()
},
app,
);
}
async fn app(window: Window, mut gfx: Graphics, mut input: Input) -> Result<()> {
// Clear the screen to a blank, white color
gfx.clear(Color::WHITE);
// Paint a blue square with a red outline in the center of our screen
// It should have a top-left of (350, 100) and a size of (150, 100)
let rect = Rectangle::new(Vector::new(350.0, 100.0), Vector::new(100.0, 100.0));
gfx.fill_rect(&rect, Color::BLUE);
gfx.stroke_rect(&rect, Color::RED);
// Send the data to be drawn
gfx.present(&window)?;
loop {
while let Some(_) = input.next_event().await {}
}
}
A good way to get started with Quicksilver is to read and run the examples which also serve as tutorials. If you have any questions, feel free to open an issue or ask for help in the Rust Community Discord from other Quicksilver users and developers.
Want to add your project? Feel free to open an issue or PR!
Quicksilver should always compile and run on the latest stable version of Rust, for both web and desktop.
Make sure to put all your assets in a top-level folder of your crate called static/
. All
Quicksilver file loading-APIs will expect paths that originate in the static folder, so
static/image.png
should be referenced as image.png
.
On Windows and Mac, all you'll need to build Quicksilver is a recent stable version of rustc
and cargo
. A few of Quicksilver's dependencies require Linux packages to build, namely
libudev
, zlib
, and alsa
. To install these on Ubuntu or Debian, run the command
sudo apt install libudev-dev zlib1g-dev alsa libasound2-dev
.
If you're deploying for desktop platforms, build in release mode (cargo build --release
)
and copy the executable file produced (found at "target/release/") and any assets you used
(image files, etc.) and create an archive (on Windows a zip file, on Unix a tar file). You
should be able to distribute this archive with no problems; if there are any, please open an
issue.
If you're deploying for the web, first make sure you've
installed the cargo web tool. Then use cargo web deploy
to build your application for distribution (located at target/deploy
).
If you want to test your application locally, use cargo web start --features quicksilver/stdweb
and open your
favorite browser to the port it provides.
Quicksilver has recently gained experimental support for wasm-bindgen
, under the web-sys
feature. The workflow is not currently documented here, but it should be the same as using any other
library with wasm-bindgen
.
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:
Each are enabled by default, but you can specify which features you actually want to use.
The engine is supported on Windows, macOS, Linux, and the web via WebAssembly.
Mobile support would be a future possibility, but likely only through external contributions.