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
use sge::prelude::*;
actions! {
FWD, BACK, RIGHT, LEFT, JUMP, REBIND
}
fn main() -> anyhow::Result<()> {
init("Action mapping")?;
bind! {
FWD => KeyCode::KeyW;
BACK => KeyCode::KeyS;
RIGHT => KeyCode::KeyD;
LEFT => KeyCode::KeyA;
JUMP => KeyCode::Space;
REBIND => KeyCode::KeyR;
}
loop {
if action_pressed(FWD) {
println!("FWD pressed");
}
if action_pressed(REBIND) {
bind(FWD, KeyCode::KeyE);
}
if should_quit() {
break;
}
next_frame();
}
Ok(())
}
// // --- Generated Code (slightly simplified) ---
//
// use sge::prelude::*;
//
// const FWD: Action = Action::new(0);
// const BACK: Action = Action::new(1);
// const RIGHT: Action = Action::new(2);
// const LEFT: Action = Action::new(3);
// const JUMP: Action = Action::new(4);
//
// fn main() -> anyhow::Result<()> {
// init("Action mapping")?;
//
// bind(FWD, KeyCode::KeyW);
// bind(BACK, KeyCode::KeyS);
// bind(RIGHT, KeyCode::KeyD);
// bind(LEFT, KeyCode::KeyA);
// bind(JUMP, KeyCode::Space);
//
// loop {
// if action_pressed(FWD) {
// println!("FWD")
// }
//
// if should_quit() {
// break;
// }
//
// next_frame();
// }
// Ok(())
// }