comparison examples/example-notify/example-notify.c @ 459:541cb950997b

examples: add libmlk-example library
author David Demelier <markand@malikania.fr>
date Sun, 26 Feb 2023 19:44:47 +0100
parents 773a082f0b91
children 5729efd23286
comparison
equal deleted inserted replaced
458:02c1481b7dbb 459:541cb950997b
53 { 53 {
54 if (core_init("fr.malikania", "example-notify") < 0 || ui_init() < 0) 54 if (core_init("fr.malikania", "example-notify") < 0 || ui_init() < 0)
55 panic(); 55 panic();
56 if (window_open("Example - Notify", W, H) < 0) 56 if (window_open("Example - Notify", W, H) < 0)
57 panic(); 57 panic();
58 if (image_openmem(&icon, assets_sword, sizeof (assets_sword)) < 0) 58 if (mlk_image_openmem(&icon, assets_images_sword, sizeof (assets_images_sword)) < 0)
59 panic(); 59 panic();
60 } 60 }
61 61
62 static void 62 static void
63 handle(struct state *st, const union event *ev) 63 handle(struct state *st, const union mlk_event *ev)
64 { 64 {
65 (void)st; 65 (void)st;
66 66
67 switch (ev->type) { 67 switch (ev->type) {
68 case EVENT_QUIT: 68 case MLK_EVENT_QUIT:
69 game_quit(); 69 mlk_game_quit();
70 break; 70 break;
71 case EVENT_KEYDOWN: 71 case MLK_EVENT_KEYDOWN:
72 if (ev->key.key == KEY_SPACE) 72 if (ev->key.key == MLK_KEY_SPACE)
73 notify(&icon, "Quest", "Quest finished."); 73 notify(&icon, "Quest", "Quest finished.");
74 break; 74 break;
75 default: 75 default:
76 break; 76 break;
77 } 77 }
88 static void 88 static void
89 draw(struct state *st) 89 draw(struct state *st)
90 { 90 {
91 (void)st; 91 (void)st;
92 92
93 painter_set_color(0xffffffff); 93 mlk_painter_set_color(0xffffffff);
94 painter_clear(); 94 mlk_painter_clear();
95 label_draw(&help); 95 label_draw(&help);
96 notify_draw(); 96 notify_draw();
97 painter_present(); 97 mlk_painter_present();
98 } 98 }
99 99
100 static void 100 static void
101 run(void) 101 run(void)
102 { 102 {
104 .handle = handle, 104 .handle = handle,
105 .update = update, 105 .update = update,
106 .draw = draw 106 .draw = draw
107 }; 107 };
108 108
109 game_init(states, UTIL_SIZE(states)); 109 mlk_game_init(states, UTIL_SIZE(states));
110 game_push(&state); 110 mlk_game_push(&state);
111 game_loop(); 111 mlk_game_loop();
112 } 112 }
113 113
114 static void 114 static void
115 quit(void) 115 quit(void)
116 { 116 {