Mercurial > molko
comparison examples/example-animation/example-animation.c @ 469:0d6206cee6b9
core: state -> mlk_state
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 27 Feb 2023 11:11:23 +0100 |
parents | 91ce23a36143 |
children | bc5483849614 |
comparison
equal
deleted
inserted
replaced
468:91ce23a36143 | 469:0d6206cee6b9 |
---|---|
43 .x = 10, | 43 .x = 10, |
44 .y = 10, | 44 .y = 10, |
45 .flags = LABEL_FLAGS_SHADOW | 45 .flags = LABEL_FLAGS_SHADOW |
46 }; | 46 }; |
47 | 47 |
48 static struct state *states[1]; | 48 static struct mlk_state *states[1]; |
49 static struct texture numbers; | 49 static struct texture numbers; |
50 static struct mlk_animation animation; | 50 static struct mlk_animation animation; |
51 static struct mlk_sprite sprite; | 51 static struct mlk_sprite sprite; |
52 static int completed = 1; | 52 static int completed = 1; |
53 | 53 |
61 if (mlk_image_openmem(&numbers, assets_sprites_numbers, sizeof (assets_sprites_numbers)) < 0) | 61 if (mlk_image_openmem(&numbers, assets_sprites_numbers, sizeof (assets_sprites_numbers)) < 0) |
62 mlk_panic(); | 62 mlk_panic(); |
63 } | 63 } |
64 | 64 |
65 static void | 65 static void |
66 handle(struct state *st, const union mlk_event *ev) | 66 handle(struct mlk_state *st, const union mlk_event *ev) |
67 { | 67 { |
68 (void)st; | 68 (void)st; |
69 | 69 |
70 switch (ev->type) { | 70 switch (ev->type) { |
71 case MLK_EVENT_KEYDOWN: | 71 case MLK_EVENT_KEYDOWN: |
85 break; | 85 break; |
86 } | 86 } |
87 } | 87 } |
88 | 88 |
89 static void | 89 static void |
90 update(struct state *st, unsigned int ticks) | 90 update(struct mlk_state *st, unsigned int ticks) |
91 { | 91 { |
92 (void)st; | 92 (void)st; |
93 | 93 |
94 if (!completed) | 94 if (!completed) |
95 completed = mlk_animation_update(&animation, ticks); | 95 completed = mlk_animation_update(&animation, ticks); |
96 } | 96 } |
97 | 97 |
98 static void | 98 static void |
99 draw(struct state *st) | 99 draw(struct mlk_state *st) |
100 { | 100 { |
101 (void)st; | 101 (void)st; |
102 | 102 |
103 mlk_painter_set_color(0x4f8fbaff); | 103 mlk_painter_set_color(0x4f8fbaff); |
104 mlk_painter_clear(); | 104 mlk_painter_clear(); |
111 } | 111 } |
112 | 112 |
113 static void | 113 static void |
114 run(void) | 114 run(void) |
115 { | 115 { |
116 struct state state = { | 116 struct mlk_state state = { |
117 .handle = handle, | 117 .handle = handle, |
118 .update = update, | 118 .update = update, |
119 .draw = draw | 119 .draw = draw |
120 }; | 120 }; |
121 | 121 |