Crate libsm64[−][src]
Expand description
This crate provides bindings and a rust friendly wrapper around the C API of libsm64. libsm64 extracts the logic for the movement and control of Mario from the Super Mario 64 ROM providing a interface to implement your own Mario in your own 3D engine.
Note: You will be required to provide your own copy of a Super Mario 64 (USA) ROM, the correct ROM has a SHA1 hash of ‘9bef1128717f958171a4afac3ed78ee2bb4e86ce’.
Usage:
use std::fs::File;
use libsm64::*;
const ROM_PATH: &str = "./baserom.us.z64";
let rom = File::open(ROM_PATH).unwrap();
let mut sm64 = Sm64::new(rom).unwrap();
// Convert your existing level geometry into LevelTriangles
let level_collision_geometry = create_level_geometry();
// Load the geometry into sm64 to be used for collision detection
sm64.load_level_geometry(&level_collision_geometry);
// Create a new Mario and provide his starting position
let mut mario = sm64.create_mario(0, 0, 0).unwrap();
let input = MarioInput {
stick_x: 0.5,
button_a: true,
..MarioInput::default()
};
// For each iteration of your gameloop, tick Mario's state
let state = mario.tick(input);
println!("Mario's current health: {}", state.health);
// Mario's geometry will be updated to his new position and animation
for triangle in mario.geometry().triangles() {
draw_triangle(&triangle, sm64.texture());
}
Structs
A color
A dynamic surface that can have its position and rotation updated at runtime, good for moving platforms
A level triangle, the main building block of the collision geometry
A instance of Mario that can be controlled
Mario’s geometry
The input for a frame of Mario’s logic
Mario’s state after a tick of logic
A vertex that makes up Mario’s model
A point in 2D space
A point in 3D space
The core interface to libsm64
Representions a transform that can be applied to a dynamic surface
A texture atlas that can be applied to the Mario geometry