Secret debugging key
[rfk] / rfk.c
diff --git a/rfk.c b/rfk.c
index 13abae7..976f431 100644 (file)
--- a/rfk.c
+++ b/rfk.c
@@ -18,7 +18,7 @@
 #define ARENA_WIDTH 25
 #define ARENA_HEIGHT 12
 
-const int amount_of_random_stuff = 1;
+const int amount_of_random_stuff = 15;
 
 typedef enum {
   STATE_PROLOGUE,
@@ -56,8 +56,8 @@ description (void)
       r = random() % nki_count;
     }
   while (used[r]);
-
   used[r] = TRUE;
+
   return g_slist_nth_data (nki, r);
 }
 
@@ -184,8 +184,6 @@ ensure_messages_loaded (void)
     }
 
   fclose (nki_file);
-
-  used = g_malloc0 (nki_count);
 }
 
 void
@@ -221,6 +219,10 @@ switch_state (StateOfPlay new_state)
 
 gboolean animation_running = FALSE;
 
+/*
+static gboolean
+love_animation_draw
+*/
 static gboolean
 ending_animation_quit (gpointer data)
 {
@@ -240,6 +242,7 @@ ending_animation_draw (GtkWidget *widget, GdkEventExpose *event, gpointer data)
   static GdkGC *gc = NULL;
 
   const int stepsize = 3;
+  static int love_size = 40;
 
   if (!kitten_x)
     {
@@ -272,30 +275,44 @@ ending_animation_draw (GtkWidget *widget, GdkEventExpose *event, gpointer data)
                   -1, -1,
                   GDK_RGB_DITHER_NONE, 0, 0);
 
-  cycle_count++;
-  robot_x += stepsize;
-  kitten_x -= stepsize;
-
-  if (robot_x+robot_stop >= kitten_x)
+  if (robot_x+robot_stop < kitten_x)
+    {
+      cycle_count++;
+      robot_x += stepsize;
+      kitten_x -= stepsize;
+    }
+  else
     {
+      GdkPixbuf *scaled_love_pic =
+       gdk_pixbuf_scale_simple (love_pic,
+                                love_size,
+                                love_size,
+                                GDK_INTERP_BILINEAR);
+
       gdk_draw_pixbuf (GDK_DRAWABLE(widget->window),
                       gc,
-                      love_pic, 0, 0,
+                      scaled_love_pic, 0, 0,
                       robot_x + gdk_pixbuf_get_width (robot_pic), all_y,
                       -1, -1,
                       GDK_RGB_DITHER_NONE, 0, 0);
 
-      animation_running = FALSE;
-
-      g_timeout_add (2000, ending_animation_quit, NULL);
+      love_size ++;
 
-      gdk_gc_unref (gc);
-      cycle_count = 0;
-      robot_x = 0;
-      robot_stop = 0;
-      kitten_x = 0;
-      all_y = 0;
-      gc = NULL;
+      if (love_size >= gdk_pixbuf_get_width (love_pic))
+       {
+         animation_running = FALSE;
+
+         g_timeout_add (2000, ending_animation_quit, NULL);
+
+         gdk_gc_unref (gc);
+         love_size = 40;
+         cycle_count = 0;
+         robot_x = 0;
+         robot_stop = 0;
+         kitten_x = 0;
+         all_y = 0;
+         gc = NULL;
+       }
     }
 
   return TRUE;
@@ -462,6 +479,12 @@ on_key_pressed (GtkWidget      *widget,
        }
     }
 
+  if (keyval=='d' && event->state & GDK_CONTROL_MASK)
+    {
+      /* secret debugging key */
+      show_message (gtk_label_get_text (GTK_LABEL (kitten)));
+    }
+
   return FALSE;
 }
 
@@ -534,6 +557,9 @@ set_up_board (void)
     {
       /* 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!");