Logo

index : binary-tree

---

  • summary
  • about
  • tree
  • log
  • branches
<< path: root/things/binary-tree.git/html/src/state.jai blob: 1dc6ebe98c17707a407b2edb7a6c3abee9dcc9ca [raw] [clear marker]

        
0
1
2State :: struct {
3 id: Mode;
4 camera: Camera2D;
5}
6
7
8state_init :: (current_mode: Mode, st: ..State) {
9 for st array_add(*states, it);
10 current = state_find(current_mode);
11}
12
13state_switch :: (state_id: Mode) {
14 idx := state_find(state_id);
15 new_state := *states[idx];
16 old_state := *states[current];
17
18 old_state.camera = camera;
19 camera = new_state.camera;
20
21 current = idx;
22}
23
24
25#scope_file
26
27
28states: [..]State;
29current: int;
30
31
32state_find :: (id: Mode) -> idx: int {
33 ok, idx := array_find(states, { id, {} }, find_by_id);
34 assert(ok, "Should not happen @ state_find");
35 return idx;
36}
37
38find_by_id :: (a: State, b: State) -> bool {
39 return a.id == b.id;
40}
41
42
Copyright 2026  E766CB298A6D1E64 | Git-Thing heavily inspired by cgit