b93ac342da93c81e80e99fcca4132508c8a6a978
[rfk] / rfk.c
1 /*  robotfindskitten for maemo
2  *  original by Leonard Richardson, 1997
3  *  ported to maemo by Thomas Thurman, 2009
4  *  suggestions welcome
5  *  Compile with:
6  *  gcc -Wall -g rfk.c -o rfk `pkg-config --cflags --libs gtk+-2.0 hildon-1`
7  */
8
9 #include <gtk/gtk.h>
10 #include <stdlib.h>
11 #include <glib.h>
12 #include <hildon/hildon.h>
13
14 #define ARENA_WIDTH 25
15 #define ARENA_HEIGHT 12
16
17 const int amount_of_random_stuff = 15;
18
19 const char *explanation =
20   "In this game, you are robot (#). "
21   "Your job is to find kitten. This task is complicated "
22   "by the existence of various things which are not kitten. "
23   "Robot must touch items to determine if they are kitten or "
24   "not. The game ends when robotfindskitten. You may move "
25   "robot about by tapping on any side of robot, or with the "
26   "cursor keys.";
27
28 static char* messages[] =
29   {
30     "\"I pity the fool who mistakes me for kitten!\", sez Mr. T.",
31     "That's just an old tin can.",
32     "It's an altar to the horse god.",
33     "A box of dancing mechanical pencils. They dance! They sing!",
34     "It's an old Duke Ellington record.",
35     "A box of fumigation pellets.",
36     "A digital clock. It's stuck at 2:17 PM.",
37     "That's just a charred human corpse.",
38     "I don't know what that is, but it's not kitten.",
39     "An empty shopping bag. Paper or plastic?",
40     "Could it be... a big ugly bowling trophy?",
41     "A coat hanger hovers in thin air. Odd.",
42     "Not kitten, just a packet of Kool-Aid(tm).",
43     "A freshly-baked pumpkin pie.",
44     "A lone, forgotten comma, sits here, sobbing.",
45     "ONE HUNDRED THOUSAND CARPET FIBERS!!!!!",
46     "It's Richard Nixon's nose!",
47     "It's Lucy Ricardo. \"Aaaah, Ricky!\", she says.",
48     "You stumble upon Bill Gates' stand-up act.",
49     "Just an autographed copy of the Kama Sutra.",
50     "It's the Will Rogers Highway. Who was Will Rogers, anyway?",
51     "It's another robot, more advanced in design than you but strangely immobile.",
52     "Leonard Richardson is here, asking people to lick him.",
53     "It's a stupid mask, fashioned after a beagle.",
54     "Your State Farm Insurance(tm) representative!",
55     "It's the local draft board.",
56     "Seven 1/4\" screws and a piece of plastic.",
57     "An 80286 machine.",
58     "One of those stupid \"Homes of the Stars\" maps.",
59     "A signpost saying \"TO KITTEN\". It points in no particular direction.",
60     "A hammock stretched between a tree and a volleyball pole.",
61     "A Texas Instruments of Destruction calculator.",
62     "It's a dark, amphorous blob of matter.",
63     "Just a pincushion.",
64     "It's a mighty zombie talking about some love and prosperity.",
65     "\"Dear robot, you may have already won our 10 MILLION DOLLAR prize...\"",
66     "It's just an object.",
67     "A mere collection of pixels.",
68     "A badly dented high-hat cymbal lies on its side here.",
69     "A marijuana brownie.",
70     "A plush Chewbacca.",
71     "Daily hunger conditioner from Australasia",
72     "Just some stuff.",
73     "Why are you touching this when you should be finding kitten?",
74     "A glorious fan of peacock feathers.",
75     "It's some compromising photos of Babar the Elephant.",
76     "A copy of the Weekly World News. Watch out for the chambered nautilus!",
77     "It's the proverbial wet blanket.",
78     "A \"Get Out of Jail Free\" card.",
79     "An incredibly expensive \"Mad About You\" collector plate.",
80     "Paul Moyer's necktie.",
81     "A haircut and a real job. Now you know where to get one!",
82     "An automated robot-hater. It frowns disapprovingly at you.",
83     "An automated robot-liker. It smiles at you.",
84     "It's a black hole. Don't fall in!",
85     "Just a big brick wall.",
86     "You found kitten! No, just kidding.",
87     "Heart of Darkness brand pistachio nuts.",
88     "A smoking branding iron shaped like a 24-pin connector.",
89     "It's a Java applet.",
90     "An abandoned used-car lot.",
91     "A shameless plug for Maemo.",
92     "A shameless plug for the UCLA Linux Users Group: http://linux.ucla.edu/",
93     "A can of Spam Lite.",
94     "This is another fine mess you've gotten us into, Stanley.",
95     "It's scenery for \"Waiting for Godot\".",
96     "This grain elevator towers high above you.",
97     "A Mentos wrapper.",
98     "It's the constellation Pisces.",
99     "It's a fly on the wall. Hi, fly!",
100     "This kind of looks like kitten, but it's not.",
101     "It's a banana! Oh, joy!",
102     "A helicopter has crashed here.",
103     "Carlos Tarango stands here, doing his best impression of Pat Smear.",
104     "A patch of mushrooms grows here.",
105     "A patch of grape jelly grows here.",
106     "A spindle, and a grindle, and a bucka-wacka-woom!",
107     "A geyser sprays water high into the air.",
108     "A toenail? What good is a toenail?",
109     "You've found the fish! Not that it does you much good in this game.",
110     "A Buttertonsils bar.",
111     "One of the few remaining discoes.",
112     "Ah, the uniform of a Revolutionary-era minuteman.",
113     "A punch bowl, filled with punch and lemon slices.",
114     "It's nothing but a G-thang, baby.",
115     "IT'S ALIVE! AH HA HA HA HA!",
116     "This was no boating accident!",
117     "Wait! This isn't the poker chip! You've been tricked! DAMN YOU, MENDEZ!",
118     "A livery stable! Get your livery!",
119     "It's a perpetual immobility machine.",
120     "\"On this spot in 1962, Henry Winkler was sick.\"",
121     "There's nothing here; it's just an optical illusion.",
122     "The World's Biggest Motzah Ball!",
123     "A tribe of cannibals lives here. They eat Malt-O-Meal for breakfast, you know.",
124     "This appears to be a rather large stack of trashy romance novels.",
125     "Look out! Exclamation points!",
126     "A herd of wild coffee mugs slumbers here.",
127     "It's a limbo bar! How low can you go?",
128     "It's the horizon. Now THAT'S weird.",
129     "A vase full of artificial flowers is stuck to the floor here.",
130     "A large snake bars your way.",
131     "A pair of saloon-style doors swing slowly back and forth here.",
132     "It's an ordinary bust of Beethoven... but why is it painted green?",
133     "It's TV's lovable wisecracking Crow! \"Bite me!\", he says.",
134     "Hey, look, it's war. What is it good for? Absolutely nothing. Say it again.",
135     "It's the amazing self-referential thing that's not kitten.",
136     "A flamboyant feather boa. Now you can dress up like Carol Channing!",
137     "\"Sure hope we get some rain soon,\" says Farmer Joe.",
138     "\"How in heck can I wash my neck if it ain't gonna rain no more?\" asks Farmer Al.",
139     "\"Topsoil's all gone, ma,\" weeps Lil' Greg.",
140     "This is a large brown bear. Oddly enough, it's currently peeing in the woods.",
141     "A team of arctic explorers is camped here.",
142     "This object here appears to be Louis Farrakhan's bow tie.",
143     "This is the world-famous Chain of Jockstraps.",
144     "A trash compactor, compacting away.",
145     "This toaster strudel is riddled with bullet holes!",
146     "It's a hologram of a crashed helicopter.",
147     "This is a television. On screen you see a robot strangely similar to yourself.",
148     "This balogna has a first name, it's R-A-N-C-I-D.",
149     "A salmon hatchery? Look again. It's merely a single salmon.",
150     "It's a rim shot. Ba-da-boom!",
151     "It's creepy and it's kooky, mysterious and spooky. It's also somewhat ooky.",
152     "This is an anagram.",
153     "This object is like an analogy.",
154     "It's a symbol. You see in it a model for all symbols everywhere.",
155     "The object pushes back at you.",
156     "A traffic signal. It appears to have been recently vandalized.",
157     "\"There is no kitten!\" cackles the old crone. You are shocked by her blasphemy.",
158     "This is a Lagrange point. Don't come too close now.",
159     "The dirty old tramp bemoans the loss of his harmonica.",
160     "Look, it's Fanny the Irishman!",
161     "What in blazes is this?",
162     "It's the instruction manual for a previous version of this game.",
163     "A brain cell. Oddly enough, it seems to be functioning.",
164     "Tea and/or crumpets.",
165     "This jukebox has nothing but Cliff Richards albums in it.",
166     "It's a Quaker Oatmeal tube, converted into a drum.",
167     "This is a remote control. Being a robot, you keep a wide berth.",
168     "It's a roll of industrial-strength copper wire.",
169     "Oh boy! Grub! Er, grubs.",
170     "A puddle of mud, where the mudskippers play.",
171     "Plenty of nothing.",
172     "Look at that, it's the Crudmobile.",
173     "Just Walter Mattheau and Jack Lemmon.",
174     "Two crepes, two crepes in a box.",
175     "An autographed copy of \"Primary Colors\", by Anonymous.",
176     "Another rabbit? That's three today!",
177     "It's a segmentation fault. Core dumped, by the way.",
178     "A historical marker showing the actual location of /dev/null.",
179     "Thar's Mobius Dick, the convoluted whale. Arrr!",
180     "It's a charcoal briquette, smoking away.",
181     "A pizza, melting in the sun.",
182     "It's a \"HOME ALONE 2: Lost in New York\" novelty cup.",
183     "A stack of 7 inch floppies wobbles precariously.",
184     "It's nothing but a corrupted floppy. Coaster anyone?",
185     "A section of glowing phosphor cells sings a song of radiation to you.",
186     "This TRS-80 III is eerily silent.",
187     "A toilet bowl occupies this space.",
188     "This peg-leg is stuck in a knothole!",
189     "It's a solitary vaccuum tube.",
190     "This corroded robot is clutching a mitten.",
191     "\"Hi, I'm Anson Williams, TV's 'Potsy'.\"",
192     "This subwoofer was blown out in 1974.",
193     "Three half-pennies and a wooden nickel.",
194     "It's the missing chapter to \"A Clockwork Orange\".",
195     "It's a burrito stand flyer. \"Taqueria El Ranchito\".",
196     "This smiling family is happy because they eat LARD.",
197     "Roger Avery, persona un famoso de los Estados Unidos.",
198     "Ne'er but a potted plant.",
199     "A parrot, kipping on its back.",
200     "A forgotten telephone switchboard.",
201     "A forgotten telephone switchboard operator.",
202     "It's an automated robot-disdainer. It pretends you're not there.",
203     "It's a portable hole. A sign reads: \"Closed for the winter\".",
204     "Just a moldy loaf of bread.",
205     "A little glass tub of Carmex. ($.89) Too bad you have no lips.",
206     "A Swiss-Army knife. All of its appendages are out. (toothpick lost)",
207     "It's a zen simulation, trapped within an ASCII character.",
208     "It's a copy of \"The Rubaiyat of Spike Schudy\".",
209     "It's \"War and Peace\" (unabridged, very small print).",
210     "A willing, ripe tomato bemoans your inability to digest fruit.",
211     "A robot comedian. You feel amused.",
212     "It's KITT, the talking car.",
213     "Here's Pete Peterson. His batteries seem to have long gone dead.",
214     "\"Blup, blup, blup\", says the mud pot.",
215     "More grist for the mill.",
216     "Grind 'em up, spit 'em out, they're twigs.",
217     "The boom box cranks out an old Ethel Merman tune.",
218     "It's \"Finding kitten\", published by O'Reilly and Associates.",
219     "Pumpkin pie spice.",
220     "It's the Bass-Matic '76! Mmm, that's good bass!",
221     "\"Lend us a fiver 'til Thursday\", pleas Andy Capp.",
222     "It's a tape of '70s rock. All original hits! All original artists!",
223     "You've found the fabled America Online disk graveyard!",
224     "Empty jewelboxes litter the landscape.",
225     "It's the astounding meta-object.",
226     "Ed McMahon stands here, lost in thought. Seeing you, he bellows, \"YES SIR!\"",
227     "...thingy???",
228     "It's 1000 secrets the government doesn't want you to know!",
229     "The letters O and R.",
230     "A magical... magic thing.",
231     "It's a moment of silence.",
232     "It's Sirhan-Sirhan, looking guilty.",
233     "It's \"Chicken Soup for the Kitten-seeking Soulless Robot.\"",
234     "It is a set of wind-up chatter teeth.",
235     "It is a cloud shaped like an ox.",
236     "You see a snowflake here, melting slowly.",
237     "It's a big block of ice. Something seems to be frozen inside it.",
238     "Vladimir Lenin's casket rests here.",
239     "It's a copy of \"Zen and The Art of Robot Maintenance\".",
240     "This invisible box contains a pantomime horse.",
241     "A mason jar lies here open. It's label reads: \"do not open!\".",
242     "A train of thought chugs through here.",
243     "This jar of pickles expired in 1957.",
244     "Someone's identity disk lies here.",
245     "\"Yes!\" says the bit.",
246     "\"No!\" says the bit.",
247     "A dodecahedron bars your way.",
248     "Mr. Hooper is here, surfing.",
249     "It's a big smoking fish.",
250     "You have new mail in /var/spool/robot",
251     "Just a monitor with the blue element burnt out.",
252     "A pile of coaxial plumbing lies here.",
253     "It's a rotten old shoe.",
254     "It's a hundred-dollar bill.",
255     "It's a Dvorak keyboard.",
256     "It's a cardboard box full of 8-tracks.",
257     "Just a broken hard drive containg the archives of Nerth Pork.",
258     "A broken metronome sits here, it's needle off to one side.",
259     "A sign reads: \"Go home!\"",
260     "A sign reads: \"No robots allowed!\"",
261     "It's the handheld robotfindskitten game, by Tiger.",
262     "This particular monstrosity appears to be ENIAC.",
263     "This is a tasty-looking banana creme pie.",
264     "A wireframe model of a hot dog rotates in space here.",
265     "Just the empty husk of a locust.",
266     "You disturb a murder of crows.",
267     "It's a copy of the robotfindskitten EULA.",
268     "It's Death.",
269     "It's an autographed copy of \"Secondary Colors,\" by Bob Ross.",
270     "It is a marzipan dreadnought that appears to have melted and stuck.",
271     "It's a DVD of \"Crouching Monkey, Hidden Kitten\", region encoded for the moon.",
272     "It's Kieran Hervold.  Damn dyslexia!"
273     "A non-descript box of crackers.",
274     "Carbonated Water, High Fructose Corn Syrup, Color, Phosphoric Acid, Flavors, Caffeine.",
275     "\"Move along! Nothing to see here!\"",
276     "It's the embalmed corpse of Vladimir Lenin.",
277     "A coupon for one free steak-fish at your local family diner.",
278     "A set of keys to a 2001 Rolls Royce. Worthless."
279   };
280
281 GtkWidget *arena[ARENA_WIDTH][ARENA_HEIGHT];
282 GtkWidget *table, *window, *robot, *kitten;
283 int robot_x, robot_y;
284 gboolean used[G_N_ELEMENTS (messages)] = { 0, };
285
286 GdkPixbuf *robot_pic, *love_pic, *kitten_pic;
287 GtkWidget *animation_area;
288
289 const GdkColor black = { 0, };
290
291 /****************************************************************/
292 /* Random object descriptions.                                  */
293 /****************************************************************/
294
295 char *
296 description (void)
297 {
298   int r;
299    
300   do
301     {
302       r = random() % G_N_ELEMENTS (messages);
303     }
304   while (used[r]);
305
306   used[r] = TRUE;
307   return messages[r];
308         
309 }
310
311 /****************************************************************/
312 /* Placing objects.                                             */
313 /****************************************************************/
314
315 void
316 place_in_arena_at_xy (GtkWidget *item, int x, int y)
317 {
318   arena[x][y] = item;
319
320   gtk_table_attach_defaults (GTK_TABLE (table),
321                              item,
322                              x, x+1,
323                              y, y+1);
324
325   if (item==robot)
326     {
327       robot_x = x;
328       robot_y = y;
329     }
330 }
331
332 void
333 place_in_arena_randomly (GtkWidget *item)
334 {
335   int x, y;
336    
337   do
338     {
339       x = random() % ARENA_WIDTH;
340       y = random() % ARENA_HEIGHT;
341     }
342   while (arena[x][y]);
343
344   place_in_arena_at_xy (item, x, y);
345 }
346
347 /****************************************************************/
348 /* Labels representing things the robot might find.             */
349 /****************************************************************/
350
351 GtkWidget *
352 random_character (gchar *description)
353 {
354   gchar character[2] = { random() % ('~'-'!') + '!', 0 };
355   gchar *escaped_character = g_markup_escape_text (character, -1);
356   gchar *markup = g_strdup_printf ("<span color=\"#%02x%02x%02x\">%s</span>",
357                                    (int) (random() % 0x7F)+0x80,
358                                    (int) (random() % 0x7F)+0x80,
359                                    (int) (random() % 0x7F)+0x80,
360                                    escaped_character);
361   GtkWidget *result = gtk_label_new (NULL);
362   gtk_label_set_markup (GTK_LABEL (result), markup);
363   g_free (markup);
364   g_free (escaped_character);
365
366   g_object_set_data (G_OBJECT (result), "examine", description);
367
368   return result;
369 }
370
371 /****************************************************************/
372 /* Talking back to the user.                                    */
373 /****************************************************************/
374
375 void
376 show_message (const char *message)
377 {
378   HildonNote* note = HILDON_NOTE
379     (hildon_note_new_information (GTK_WINDOW (window),
380                                   message));
381   gtk_dialog_run (GTK_DIALOG (note));
382   gtk_widget_destroy (GTK_WIDGET (note));
383 }
384
385 /****************************************************************/
386 /* The ending animation.                                        */
387 /****************************************************************/
388
389 static gboolean
390 ending_animation_quit (gpointer data)
391 {
392   gtk_main_quit ();
393   return FALSE;
394 }
395
396 static gboolean
397 ending_animation_draw (GtkWidget *widget, GdkEventExpose *event, gpointer data)
398 {
399   /* We only run through once, so just make it static. */
400   static int cycle_count = 0;
401
402   static int robot_x = 0;
403   static int robot_stop = 0;
404   static int kitten_x = 0;
405   static int all_y = 0;
406
407   const int stepsize = 3;
408
409   if (!kitten_x)
410     {
411       all_y = (event->area.height - gdk_pixbuf_get_height (love_pic)) / 2;
412
413       robot_stop = gdk_pixbuf_get_width (robot_pic) + gdk_pixbuf_get_width (love_pic);
414       kitten_x = event->area.width - (cycle_count*stepsize + gdk_pixbuf_get_width (kitten_pic));
415     }
416
417   gdk_gc_set_foreground (widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
418                          &black);
419
420   gdk_draw_rectangle (GDK_DRAWABLE(widget->window),
421                       widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
422                       TRUE,
423                       0, 0, event->area.width, event->area.height);
424
425   gdk_draw_pixbuf (GDK_DRAWABLE(widget->window),
426                    widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
427                    robot_pic, 0, 0,
428                    robot_x, all_y,
429                    -1, -1,
430                    GDK_RGB_DITHER_NONE, 0, 0);
431
432   gdk_draw_pixbuf (GDK_DRAWABLE(widget->window),
433                    widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
434                    kitten_pic, 0, 0,
435                    kitten_x, all_y,
436                    -1, -1,
437                    GDK_RGB_DITHER_NONE, 0, 0);
438
439   cycle_count++;
440   robot_x += stepsize;
441   kitten_x -= stepsize;
442
443   if (robot_x+robot_stop >= kitten_x)
444     {
445       gdk_draw_pixbuf (GDK_DRAWABLE(widget->window),
446                        widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
447                        love_pic, 0, 0,
448                        robot_x + gdk_pixbuf_get_width (robot_pic), all_y,
449                        -1, -1,
450                        GDK_RGB_DITHER_NONE, 0, 0);
451
452       g_object_unref (love_pic);
453       love_pic = NULL;
454
455       g_timeout_add (2000, ending_animation_quit, NULL);
456     }
457
458   return TRUE;
459 }
460
461 static gboolean
462 ending_animation_step (gpointer data)
463 {
464   if (love_pic)
465     {
466       gdk_window_invalidate_rect (animation_area->window,
467                                   NULL, TRUE);
468
469       return TRUE;
470     }
471   else
472     return FALSE;
473 }
474
475 static void
476 ending_animation ()
477 {
478   robot_pic = gdk_pixbuf_new_from_file ("/usr/share/pixmaps/rfk-robot.png", NULL);
479   love_pic = gdk_pixbuf_new_from_file ("/usr/share/pixmaps/rfk-love.png", NULL);
480   kitten_pic = gdk_pixbuf_new_from_file ("/usr/share/pixmaps/rfk-kitten.png", NULL);
481   animation_area =  gtk_drawing_area_new ();
482
483   gtk_container_remove (GTK_CONTAINER (window), GTK_WIDGET (table));
484   gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (animation_area));
485   gtk_widget_show_all (window);
486
487   g_signal_connect (G_OBJECT (animation_area),
488                     "expose_event", G_CALLBACK (ending_animation_draw), NULL);
489   g_timeout_add (10, ending_animation_step, NULL);
490 }
491
492 /****************************************************************/
493 /* Moving the robot.  Way to go, robot!                         */
494 /****************************************************************/
495
496 void
497 move_robot (int dx, int dy)
498 {
499   GtkWidget *new_space;
500   const char *found;
501
502   if (robot_x+dx<0 ||
503       robot_y+dy<0 ||
504       robot_x+dx>=ARENA_WIDTH ||
505       robot_y+dy>=ARENA_HEIGHT)
506     return;
507
508   new_space = arena[robot_x+dx][robot_y+dy];
509   found = g_object_get_data (G_OBJECT (new_space), "examine");
510
511   if (found && *found)
512     {
513       show_message (found);
514
515       if (new_space == kitten)
516         {
517           ending_animation ();
518         }
519     }
520   else
521     {
522       g_object_ref (new_space);
523
524       gtk_container_remove (GTK_CONTAINER (table), robot);
525       gtk_container_remove (GTK_CONTAINER (table), new_space);
526
527       place_in_arena_at_xy (new_space, robot_x, robot_y);
528       place_in_arena_at_xy (robot, robot_x+dx, robot_y+dy);
529
530       g_object_unref (new_space);
531     }
532 }
533
534 /****************************************************************/
535 /* Event handlers.                                              */
536 /****************************************************************/
537
538 gboolean
539 on_window_clicked (GtkWidget      *widget,
540                    GdkEventButton *event,
541                    gpointer        user_data)
542 {
543   int rx, ry;
544   gboolean w1, w2;
545
546   rx = (robot->allocation.x+robot->allocation.width/2);
547   ry = (robot->allocation.y+robot->allocation.height/2);
548
549   w1 = (event->x - rx) > (event->y - ry);
550   w2 = (rx - event->x) > (event->y - ry);
551         
552   if (w1)
553     {
554       if (w2)
555         move_robot (0, -1);
556       else
557         move_robot (1, 0);
558     }
559   else
560     {
561       if (w2)
562         move_robot (-1, 0);
563       else
564         move_robot (0, 1);
565     }
566
567   return TRUE;
568 }
569
570 gboolean
571 on_key_pressed (GtkWidget      *widget,
572                 GdkEventKey    *event,
573                 gpointer        user_data)
574 {
575
576   switch (event->keyval) {
577
578   case GDK_Up:    case 'k': move_robot ( 0, -1); break;
579   case GDK_Down:  case 'j': move_robot ( 0,  1); break;
580   case GDK_Left:  case 'h': move_robot (-1,  0); break;
581   case GDK_Right: case 'l': move_robot ( 1,  0); break;
582
583   }
584
585   return FALSE;
586 }
587
588 /****************************************************************/
589 /* Let's kick the whole thing off...                            */
590 /****************************************************************/
591
592 int
593 main (gint argc,
594       gchar **argv)
595 {
596   int x, y;
597
598   gtk_init (&argc, &argv);
599   srandom (time(0));
600
601   window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
602   gtk_window_set_title (GTK_WINDOW (window), "robot finds kitten");
603   gtk_widget_modify_bg (window, GTK_STATE_NORMAL, &black);
604   g_signal_connect (G_OBJECT (window), "button-press-event", G_CALLBACK (on_window_clicked), NULL);
605   g_signal_connect (G_OBJECT (window), "key-press-event", G_CALLBACK (on_key_pressed), NULL);
606   g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (gtk_main_quit), NULL);
607         
608   table = gtk_table_new (ARENA_HEIGHT, ARENA_WIDTH, TRUE);
609   gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (table));
610
611   robot = gtk_label_new ("#");
612   g_object_ref (robot);
613   kitten = random_character ("You found kitten!  Way to go, robot!");
614
615   place_in_arena_randomly (robot);
616   place_in_arena_randomly (kitten);
617
618   for (x=0; x < amount_of_random_stuff; x++)
619     place_in_arena_randomly (random_character (description ()));
620
621   for (x=0; x < ARENA_WIDTH; x++)
622     for (y=0; y < ARENA_HEIGHT; y++)
623       if (!arena[x][y])
624         place_in_arena_at_xy (gtk_label_new (NULL), x, y);
625
626   gtk_widget_show_all (window);
627
628   gdk_window_set_events (GTK_WIDGET (window)->window,
629                          gdk_window_get_events(GTK_WIDGET (window)->window) | GDK_BUTTON_PRESS_MASK);
630
631         
632   show_message (explanation);
633
634   gtk_main ();
635
636   return 0;
637 }