changeset 390:ae2dcf40c1eb

examples: fix with last game changes
author David Demelier <markand@malikania.fr>
date Wed, 16 Feb 2022 08:56:02 +0100
parents ef4d4a51aeb7
children 9334b420c975
files examples/example-action/main.c examples/example-animation/main.c examples/example-audio/main.c examples/example-battle/main.c examples/example-cursor/main.c examples/example-debug/main.c examples/example-drawable/main.c examples/example-font/main.c examples/example-gridmenu/main.c examples/example-label/main.c examples/example-message/main.c examples/example-notify/main.c examples/example-sprite/main.c examples/example-trace/main.c examples/example-ui/main.c
diffstat 15 files changed, 40 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/examples/example-action/main.c	Wed Feb 16 08:44:21 2022 +0100
+++ b/examples/example-action/main.c	Wed Feb 16 08:56:02 2022 +0100
@@ -57,6 +57,9 @@
 /* This is a stack of modal events. */
 static struct action_stack modal;
 
+/* Maximum number of states. */
+static struct state *states[1];
+
 /*
  * Event object for the chest to click on.
  */
@@ -375,6 +378,7 @@
 	action_stack_add(&events, &chest.event);
 	action_stack_add(&events, &guide.event);
 
+	game_init(states, UTIL_SIZE(states));
 	game_push(&state);
 	game_loop();
 }
--- a/examples/example-animation/main.c	Wed Feb 16 08:44:21 2022 +0100
+++ b/examples/example-animation/main.c	Wed Feb 16 08:56:02 2022 +0100
@@ -45,6 +45,7 @@
 	.flags = LABEL_FLAGS_SHADOW
 };
 
+static struct state *states[1];
 static struct texture numbers;
 static struct animation animation;
 static struct sprite sprite;
@@ -121,6 +122,7 @@
 	sprite_init(&sprite, &numbers, 48, 48);
 	animation_init(&animation, &sprite, 1000);
 
+	game_init(states, UTIL_SIZE(states));
 	game_push(&state);
 	game_loop();
 }
--- a/examples/example-audio/main.c	Wed Feb 16 08:44:21 2022 +0100
+++ b/examples/example-audio/main.c	Wed Feb 16 08:56:02 2022 +0100
@@ -38,6 +38,7 @@
 #define W       1280
 #define H       720
 
+static struct state *states[1];
 static struct music music;
 static struct sound sound;
 
@@ -134,6 +135,7 @@
 		.draw = draw
 	};
 
+	game_init(states, UTIL_SIZE(states));
 	game_push(&state);
 	game_loop();
 
--- a/examples/example-battle/main.c	Wed Feb 16 08:44:21 2022 +0100
+++ b/examples/example-battle/main.c	Wed Feb 16 08:56:02 2022 +0100
@@ -103,6 +103,8 @@
 	},
 };
 
+static struct state *states[2];
+
 static void
 haunted_wood_strat(struct character *ch, struct battle *bt)
 {
@@ -241,7 +243,7 @@
 	struct battle *bt = st->data;
 
 	if (battle_update(bt, ticks))
-		game_push(&empty_state);
+		game_pop();
 }
 
 static void
@@ -270,6 +272,7 @@
 static void
 run(void)
 {
+	game_init(states, UTIL_SIZE(states));
 	game_push(&empty_state);
 	game_loop();
 }
--- a/examples/example-cursor/main.c	Wed Feb 16 08:44:21 2022 +0100
+++ b/examples/example-cursor/main.c	Wed Feb 16 08:56:02 2022 +0100
@@ -35,6 +35,7 @@
 #define W 1280
 #define H 720
 
+static struct state *states[1];
 static char help_text[128];
 static enum window_cursor cursor = WINDOW_CURSOR_ARROW;
 
@@ -122,6 +123,7 @@
 
 	change(cursor);
 
+	game_init(states, UTIL_SIZE(states));
 	game_push(&state);
 	game_loop();
 }
--- a/examples/example-debug/main.c	Wed Feb 16 08:44:21 2022 +0100
+++ b/examples/example-debug/main.c	Wed Feb 16 08:56:02 2022 +0100
@@ -32,6 +32,7 @@
 #define W 1280
 #define H 720
 
+static struct state *states[1];
 static int mouse_x;
 static int mouse_y;
 
@@ -86,6 +87,7 @@
 		.draw = draw
 	};
 
+	game_init(states, UTIL_SIZE(states));
 	game_push(&state);
 	game_loop();
 }
--- a/examples/example-drawable/main.c	Wed Feb 16 08:44:21 2022 +0100
+++ b/examples/example-drawable/main.c	Wed Feb 16 08:56:02 2022 +0100
@@ -53,6 +53,7 @@
 	.flags = LABEL_FLAGS_SHADOW
 };
 
+static struct state *states[1];
 static struct drawable_stack stack;
 
 /*
@@ -179,6 +180,7 @@
 		.draw = draw
 	};
 
+	game_init(states, UTIL_SIZE(states));
 	game_push(&state);
 	game_loop();
 }
--- a/examples/example-font/main.c	Wed Feb 16 08:44:21 2022 +0100
+++ b/examples/example-font/main.c	Wed Feb 16 08:56:02 2022 +0100
@@ -46,6 +46,7 @@
 	0xc7cfccff,     /* Christian Grey. */
 };
 
+static struct state *states[1];
 static int ci = 0;
 static enum font_style style = FONT_STYLE_ANTIALIASED;
 
@@ -120,6 +121,7 @@
 		.draw = draw
 	};
 
+	game_init(states, UTIL_SIZE(states));
 	game_push(&state);
 	game_loop();
 }
--- a/examples/example-gridmenu/main.c	Wed Feb 16 08:44:21 2022 +0100
+++ b/examples/example-gridmenu/main.c	Wed Feb 16 08:56:02 2022 +0100
@@ -36,6 +36,8 @@
 #define W       (1280)
 #define H       (720)
 
+static struct state *states[1];
+
 static void
 init(void)
 {
@@ -123,6 +125,7 @@
 	/* Need to repaint at least once. */
 	gridmenu_repaint(&menu);
 
+	game_init(states, UTIL_SIZE(states));
 	game_push(&state);
 	game_loop();
 }
--- a/examples/example-label/main.c	Wed Feb 16 08:44:21 2022 +0100
+++ b/examples/example-label/main.c	Wed Feb 16 08:56:02 2022 +0100
@@ -101,6 +101,8 @@
 	.text = "This one follows your mouse and is not aligned."
 };
 
+static struct state *states[1];
+
 static void
 init(void)
 {
@@ -167,6 +169,7 @@
 		.draw = draw
 	};
 
+	game_init(states, UTIL_SIZE(states));
 	game_push(&state);
 	game_loop();
 }
--- a/examples/example-message/main.c	Wed Feb 16 08:44:21 2022 +0100
+++ b/examples/example-message/main.c	Wed Feb 16 08:56:02 2022 +0100
@@ -43,6 +43,8 @@
 #define MX      ((W / 2) - (MW / 2))
 #define MY      (100)
 
+static struct state *states[1];
+
 static void
 init(void)
 {
@@ -102,6 +104,7 @@
 
 	message_start(msg);
 
+	game_init(states, UTIL_SIZE(states));
 	game_push(&state);
 	game_loop();
 }
--- a/examples/example-notify/main.c	Wed Feb 16 08:44:21 2022 +0100
+++ b/examples/example-notify/main.c	Wed Feb 16 08:56:02 2022 +0100
@@ -26,6 +26,7 @@
 #include <core/panic.h>
 #include <core/state.h>
 #include <core/texture.h>
+#include <core/util.h>
 #include <core/window.h>
 
 #include <ui/notify.h>
@@ -45,6 +46,7 @@
 	.flags = LABEL_FLAGS_SHADOW
 };
 static struct texture icon;
+static struct state *states[1];
 
 static void
 init(void)
@@ -104,6 +106,7 @@
 		.draw = draw
 	};
 
+	game_init(states, UTIL_SIZE(states));
 	game_push(&state);
 	game_loop();
 }
--- a/examples/example-sprite/main.c	Wed Feb 16 08:44:21 2022 +0100
+++ b/examples/example-sprite/main.c	Wed Feb 16 08:56:02 2022 +0100
@@ -47,6 +47,7 @@
 static struct texture texture;
 static struct sprite sprite;
 static unsigned int row, column;
+static struct state *states[1];
 
 static struct label help = {
 	.x = 10,
@@ -137,6 +138,7 @@
 
 	changed();
 
+	game_init(states, UTIL_SIZE(states));
 	game_push(&state);
 	game_loop();
 }
--- a/examples/example-trace/main.c	Wed Feb 16 08:44:21 2022 +0100
+++ b/examples/example-trace/main.c	Wed Feb 16 08:56:02 2022 +0100
@@ -35,6 +35,8 @@
 #define W 1280
 #define H 720
 
+static struct state *states[1];
+
 static void
 init(void)
 {
@@ -101,6 +103,7 @@
 		.draw = draw
 	};
 
+	game_init(states, UTIL_SIZE(states));
 	game_push(&state);
 	game_loop();
 }
--- a/examples/example-ui/main.c	Wed Feb 16 08:44:21 2022 +0100
+++ b/examples/example-ui/main.c	Wed Feb 16 08:56:02 2022 +0100
@@ -127,6 +127,8 @@
 	}
 };
 
+static struct state *states[1];
+
 static void
 init(void)
 {
@@ -299,6 +301,7 @@
 	prepare();
 	resize();
 
+	game_init(states, UTIL_SIZE(states));
 	game_push(&state);
 	game_loop();
 }