Expand description
§audio-code
A simple, high level game engine for audio games: games played by ear, without graphics. Everything a blind or visually impaired player needs is built in:
- Speech through the player’s screen reader or system voice (
speech, via prism) - Sound: one-line playback, 3D positioned sounds, music with cross fades (
audio) - Virtual UI: spoken menus, sliders, checkboxes, text fields and dialogs (
ui) - Physics: walls, floors, gravity, triggers and ray casts (
physics) - Vehicles: cars and trucks with weight, speed, gears, brakes and fuel (
vehicle) - Time: frame timing, a scheduler, timers, cooldowns and intervals (
time) - Input: pressed / held / released, custom key repeat, typed text (
input) - Translations: one text file per language, engine texts in English and German (
lang) - Optional wxWidgets integration through wxDragon (
audio_code::wx, featurewxdragon)
§A complete game in 30 lines
use audio_code::prelude::*;
struct Game {
x: f32,
}
impl Scene for Game {
fn start(&mut self, ctx: &mut Context) {
ctx.speech.speak("Walk with left and right. Find the beacon!");
ctx.audio.play_looped_at("beacon", vec3(10.0, 0.0, 0.0));
}
fn update(&mut self, ctx: &mut Context) {
if ctx.input.repeating(Key::Left, 0.25, 0.25) {
self.x -= 1.0;
}
if ctx.input.repeating(Key::Right, 0.25, 0.25) {
self.x += 1.0;
}
ctx.audio.set_listener(vec3(self.x, 0.0, 0.0), 0.0);
if self.x == 10.0 {
ctx.speech.speak("You found it!");
ctx.quit();
}
}
}
fn main() -> audio_code::Result<()> {
Engine::new("Beacon").run(Game { x: 0.0 })
}Start with Engine, Scene and Context, then read the module docs. The docs
folder of the repository contains a longer guide.
Modules§
- audio
- High level sound: one-liners for effects, 3D positioned sounds and music.
Available as
ctx.audio. - input
- Keyboard input. Available as
ctx.input. - lang
- Translations: play the same game in several languages. Available as
ctx.lang. - level
- Build levels from text maps.
- math
- Vectors, angles and direction helpers made for audio games.
- physics
- Simple, predictable 3D physics. Available as
ctx.physics. - prelude
- Everything you normally need:
use audio_code::prelude::*; - speech
- Screen reader and text-to-speech output. Available as
ctx.speech. - storage
- Simple saving: high scores, settings, progress. Available as
ctx.storage. - time
- Everything about time: frame timing, game-time scheduling and simple timers.
- ui
- Virtual, speech based user interface. Available as
ctx.ui. - vehicle
- Cars and trucks: weight, speed, engine, gears, steering, brakes, fuel and sounds.
Structs§
- Context
- Everything your game can use, passed to every
Scenemethod. - Engine
- Configures and starts the game.
- Runner
- Drives scenes frame by frame. Window backends feed it key events and call
Runner::frame. You only need this when writing your own backend or tests.
Enums§
- Error
- Everything that can go wrong inside the engine.
Traits§
- Scene
- One screen or state of your game: main menu, a level, the game over screen…
Functions§
- run
- The quickest way to start: a whole game as one closure that runs every frame.
Type Aliases§
- Result
- Shorthand for
std::result::Result<T, audio_code::Error>.