+ if (current_state==STATE_PLAYING)
+ {
+ /* end of the game; clean up */
+
+ for (x=0; x < ARENA_WIDTH; x++)
+ for (y=0; y < ARENA_HEIGHT; y++)
+ if (arena[x][y])
+ {
+ gtk_container_remove (GTK_CONTAINER (state_widget[STATE_PLAYING]),
+ arena[x][y]);
+ arena[x][y] = NULL;
+ }
+
+ g_object_unref (robot);
+ g_object_unref (kitten);
+ }
+ else
+ {
+ /* make everything new */
+
+ g_free (used);
+ used = g_malloc0 (nki_count * sizeof(gboolean));
+
+ robot = gtk_label_new ("#");
+ g_object_ref (robot);
+ kitten = random_character ("You found kitten! Way to go, robot!");
+ g_object_ref (kitten);
+
+ place_in_arena_randomly (robot);
+ place_in_arena_randomly (kitten);
+
+ if (nki_count < amount_of_random_stuff)
+ {
+ /* sanity check failed */
+ show_message ("There are too few non-kitten items to play a meaningful game.");
+ exit (EXIT_FAILURE);
+ }
+
+ for (x=0; x < amount_of_random_stuff; x++)
+ place_in_arena_randomly (random_character (description ()));
+
+ for (x=0; x < ARENA_WIDTH; x++)
+ for (y=0; y < ARENA_HEIGHT; y++)
+ if (!arena[x][y])
+ place_in_arena_at_xy (gtk_label_new (NULL), x, y);
+ }
+}
+
+static void
+set_up_widgets (void)
+{
+ GtkWidget *middle = gtk_hbox_new (FALSE, 0);
+ GtkWidget *buttons = gtk_hbox_new (TRUE, 0);
+ GtkWidget *explain = NULL, *help_button, *play_button, *intro;
+ const char *explanation =
+ "In this game, you are robot (#). "
+ "Your job is to find kitten. This task is complicated "
+ "by the existence of various things which are not kitten. "
+ "Robot must touch items to determine if they are kitten or "
+ "not. The game ends when robotfindskitten. You may move "
+ "robot about by tapping on any side of robot, or with the "
+ "arrow keys.";
+ GKeyFile *desktop = g_key_file_new ();
+ gchar *version;
+ guint x, y;
+
+ /* The window */