1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
//! # 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`, feature `wxdragon`)
//!
//! ## A complete game in 30 lines
//!
//! ```no_run
//! 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.
pub use ;
// Compiles the code blocks in the README as doc tests, so they cannot go stale.
;
pub use ;
/// The quickest way to start: a whole game as one closure that runs every frame.
///
/// ```no_run
/// use audio_code::prelude::*;
///
/// fn main() -> audio_code::Result<()> {
/// let mut score = 0;
/// audio_code::run("Clicker", move |ctx| {
/// if ctx.once("intro") {
/// ctx.speak("Press space as often as you can. Escape quits.");
/// }
/// if ctx.pressed(Key::Space) {
/// score += 1;
/// ctx.audio.play_tone(400.0 + score as f32 * 10.0, 0.05);
/// }
/// if ctx.pressed(Key::Escape) {
/// ctx.speak(format!("Your score: {score}"));
/// ctx.quit();
/// }
/// })
/// }
/// ```
///
/// When the game grows, move to [`Scene`]s.
/// Everything you normally need: `use audio_code::prelude::*;`