Mercurial > molko
comparison libmlk-adventure/adventure/molko.c @ 299:648f5f949afb
core: implement stackable states
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 11 Apr 2021 16:41:34 +0200 |
parents | 196264679079 |
children | 363024b76da7 |
comparison
equal
deleted
inserted
replaced
298:196264679079 | 299:648f5f949afb |
---|---|
83 | 83 |
84 /* Init other stuff. */ | 84 /* Init other stuff. */ |
85 assets_init(); | 85 assets_init(); |
86 | 86 |
87 /* Start to splash. */ | 87 /* Start to splash. */ |
88 game_switch(state_mainmenu_new(), 1); | 88 game_push(state_mainmenu_new()); |
89 molko.team.members[0] = &character_neth; | 89 molko.team.members[0] = &character_neth; |
90 molko.team.members[1] = &character_neth; | 90 molko.team.members[1] = &character_neth; |
91 inventory_add(&molko.inventory, &item_potion, 100); | 91 inventory_add(&molko.inventory, &item_potion, 100); |
92 molko_teleport("maps/map-world.map", -1, -1); | 92 molko_teleport("maps/map-world.map", -1, -1); |
93 | 93 |
106 } else { | 106 } else { |
107 /* Clear event queue to avoid accidental key presses. */ | 107 /* Clear event queue to avoid accidental key presses. */ |
108 for (union event ev; event_poll(&ev); ) | 108 for (union event ev; event_poll(&ev); ) |
109 continue; | 109 continue; |
110 | 110 |
111 game_switch(molko.panic, 1); | 111 game_push(molko.panic); |
112 game_loop(); | 112 game_loop(); |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
116 void | 116 void |
117 molko_teleport(const char *map, int origin_x, int origin_y) | 117 molko_teleport(const char *map, int origin_x, int origin_y) |
118 { | 118 { |
119 molko.state = MOLKO_STATE_MAP; | 119 molko.state = MOLKO_STATE_MAP; |
120 | 120 |
121 game_switch(state_map_new(map, origin_x, origin_y), 0); | 121 game_push(state_map_new(map, origin_x, origin_y)); |
122 game.inhibit = INHIBIT_NONE; | 122 game.inhibit = INHIBIT_NONE; |
123 } | 123 } |
124 | 124 |
125 void | 125 void |
126 molko_fight(struct battle *bt) | 126 molko_fight(struct battle *bt) |
127 { | 127 { |
128 molko.state = MOLKO_STATE_BATTLE; | 128 molko.state = MOLKO_STATE_BATTLE; |
129 | 129 |
130 game_switch(state_battle_new(bt), 0); | 130 game_push(state_battle_new(bt)); |
131 } | 131 } |
132 | 132 |
133 const char * | 133 const char * |
134 molko_path(const char *file) | 134 molko_path(const char *file) |
135 { | 135 { |