A game engine oriented toward low power mobile linux phones/tablets. It's written in Rust and uses Gtk and Cairo! All drawing is done with an Cairo Context that this library has extended to do some really common graphics operations.
This project is super alpha but usable. If you want to join in, feel free to open up an issue or make a PR!
[dependencies]
mochi = "0.0"
```rust init(include_bytes!("game.gresource"));
let imgmochi = imagefromresource("/game/mochi.png"); let imgmochieaten = imagefromresource("/game/mochieaten.png");
rungame(move |window, ctx, pointer, deltatime| { if pointer.isdown() { ctx.drawimagecentered(window.width / 2.0, window.height / 2.0, imgmochieaten); } else { ctx.drawimagecentered(window.width / 2.0, window.height / 2.0, imgmochi); } }); ```
Mochi works off resources put into a Glib resource file. This is pretty simple to do. Just make an xml file that references your images:
xml
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
<gresource prefix="/pong">
<file>ball.png</file>
<file>paddle.png</file>
</gresource>
</gresources>
Build into a gresource
file that Glib can understand:
rust
glib-compile-resources game.xml
Inline the bytes of the game.gresource
into your code during init:
rust
init(include_bytes!("game.gresource"));
Now your game has everything it needs in it's binary! The images can be acquired as needed using the resource paths you setup.
rust
let img_ball = image_from_resource("/pong/ball.png");
This project is licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted
for inclusion in mochi
by you, as defined in the Apache-2.0 license, shall be
dual licensed as above, without any additional terms or conditions.