-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscene.h
More file actions
49 lines (42 loc) · 1.21 KB
/
scene.h
File metadata and controls
49 lines (42 loc) · 1.21 KB
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
#ifndef SCENE_H
#define SCENE_H
#include <stdint.h>
#include <raylib.h>
#include "context.h"
#include "script.h"
#include "ui.h"
#define TOGGLES_SET(u32, i) ((u32) |= (1U << (i)))
#define TOGGLES_GET(u32, i) (((u32) >> (i)) & 1U)
#define TOGGLES_CLR(u32, i) ((u32) &= ~(1U << (i)))
#define TOGGLES_TOG(u32, i) ((u32) ^= (1U << (i)))
/* Mode specification for `Scene.init` function. */
typedef enum SceneInitMode {
SCENE_INIT, SCENE_CLEAN, SCENE_ALT
} SceneInitMode;
typedef struct Scene {
// Scene title
uintptr_t uid;
void *data, *content;
uint32_t toggles;
char *subtitle;
void
(*init)(Context*, struct Scene*, SceneInitMode),
(*update)(Context*, struct Scene*, float),
(*draw)(Context*, struct Scene*);
} Scene;
/* Creates a new `Scene`. */
static Scene scene_new(char *subtitle,
void (*init)(Context*, struct Scene*, SceneInitMode),
void (*update)(Context*, struct Scene*, float),
void (*draw)(Context*, struct Scene*)) {
return (Scene) {
.uid = (uintptr_t)&subtitle, // UID (it works)
.data = 0,
.content = 0,
.subtitle = subtitle,
.init = init,
.update = update,
.draw = draw
};
}
#endif