Overview
This is a template for starting 2D game projects in Rust. The choice of libraries are only meant as examples, but they have been carefully chosen such that:
- We get cross-platform support (defined to be at least Linux, Windows, and OSX)
- They are compatible with each other
Furthermore, we define the minimal requirements of 2D games as follows:
- HUD elements -> font rendering, orthographic textured quads, etc
- GUI elements -> font rendering, click events, text entry fields, buttons, that sort of thing
- Audio -> sound effects and background music
- Mouse events
- Keyboard events
In addition to the minimal requirements we also hope to reuse this template for starting 3D game projects. As such we also include full OpenGL support.
Building
Windows
- Visit SDL download page and grab the correct SDL development libraries. I use the msvc toolchain, so I grab the Visual C++ development libraries.
If you're on msvc you'll need to set LIB to point to SDL2.lib. In
my case, I unzipped the files to my desktop and I set the following
path:
export LIB="C:\Users\dagit\Desktop\SDL2-2.0.5\lib\x64"On the GNU toolchain you set LIBRARY_PATH instead of LIB.
-
Copy
SDL2.dllinto the top of your crate (next toCargo.toml). -
Checkout/update git submodules:
$ git submodule update --init --recursive
If you encounter an error during this step, I may need to give you access to the scene-rs repository.
- Use cargo as normal, eg.,
cargo build
Linux
TODO
OSX
-
Checkout/update git submodules:
$ git submodule update --init --recursive
-
Follow the instructions for
rust-sdl2for OSX: https://github.com/AngryLawyer/rust-sdl2#mac-os-xFor homebrew users this is roughly:
$ brew install sdl2 $ export LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib"
-
Use cargo as normal, eg.,
cargo build