Back to index

gcompris  8.2.2
paratrooper.c
Go to the documentation of this file.
00001 /* gcompris - paratrooper.c
00002  *
00003  * Time-stamp: <2006/08/21 23:34:30 bruno>
00004  *
00005  * Copyright (C) 2000 Bruno Coudoin
00006  *
00007  *   This program is free software; you can redistribute it and/or modify
00008  *   it under the terms of the GNU General Public License as published by
00009  *   the Free Software Foundation; either version 2 of the License, or
00010  *   (at your option) any later version.
00011  *
00012  *   This program is distributed in the hope that it will be useful,
00013  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  *   GNU General Public License for more details.
00016  *
00017  *   You should have received a copy of the GNU General Public License
00018  *   along with this program; if not, write to the Free Software
00019  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  */
00021 
00022 #include "gcompris/gcompris.h"
00023 
00024 #define SOUNDLISTFILE PACKAGE
00025 
00026 static int gamewon;
00027 
00028 static GList *item_list = NULL;
00029 static GList *item2del_list = NULL;
00030 
00031 static GcomprisBoard *gcomprisBoard = NULL;
00032 
00033 static gint dummy_id = 0;
00034 static gint drop_tux_id = 0;
00035 
00036 static GnomeCanvasItem *boatitem = NULL;
00037 static gint boat_x, boat_y, boat_landarea_y, boat_length;
00038 
00039 static GnomeCanvasItem *planeitem = NULL;
00040 static gint plane_x, plane_y;
00041 static gint planespeed_x, planespeed_y, windspeed;
00042 
00043 typedef struct {
00044   gint number;
00045   GnomeCanvasItem *rootitem;
00046 } CloudItem;
00047 
00048 
00049 typedef enum
00050 {
00051   TUX_INPLANE        = 1 << 0,
00052   TUX_DROPPING              = 1 << 1,
00053   TUX_FLYING         = 1 << 2,
00054   TUX_LANDED         = 1 << 3,
00055   TUX_CRASHED        = 1 << 4
00056 } ParaStatus;
00057 
00058 
00059 typedef struct {
00060   ParaStatus status;
00061   gint speed;
00062   gint x;
00063   gint y;
00064   GnomeCanvasItem *rootitem;
00065   GnomeCanvasItem *paratrooper;
00066   GnomeCanvasItem *parachute;
00067 } ParatrooperItem;
00068 
00069 static  ParatrooperItem          paratrooperItem;
00070 
00071 
00072 /* default gnome pixmap directory in which this game tales the icon */
00073 static char *pixmapsdir = "gcompris/misc/";
00074 
00075 static void           start_board (GcomprisBoard *agcomprisBoard);
00076 static void           pause_board (gboolean pause);
00077 static void           end_board (void);
00078 static gboolean              is_our_board (GcomprisBoard *gcomprisBoard);
00079 static void           set_level (guint level);
00080 static gint           key_press(guint keyval, gchar *commit_str, gchar *preedit_str);
00081 
00082 static GnomeCanvasItem      *paratrooper_create_cloud(GnomeCanvasGroup *parent);
00083 static gint           paratrooper_drop_clouds (GtkWidget *widget, gpointer data);
00084 static gint           paratrooper_move_items (GtkWidget *widget, gpointer data);
00085 static gint           paratrooper_move_tux (GtkWidget *widget, gpointer data);
00086 static void           paratrooper_destroy_item(CloudItem *clouditem);
00087 static void           paratrooper_destroy_items(void);
00088 static void           paratrooper_destroy_all_items(void);
00089 static void           paratrooper_next_level(void);
00090 static gint           item_event(GnomeCanvasItem *item, GdkEvent *event, void *data);
00091 static void           next_state(void);
00092 
00093 
00094 static  double               speed = 0.0;
00095 static  double               imageZoom = 0.0;
00096 
00097 /* Description of this plugin */
00098 static BoardPlugin menu_bp =
00099 {
00100    NULL,
00101    NULL,
00102    "Parachutist",
00103    "Direct the parachutist to help him or her land safely",
00104    "Bruno Coudoin <bruno.coudoin@free.fr>",
00105    NULL,
00106    NULL,
00107    NULL,
00108    NULL,
00109    start_board,
00110    pause_board,
00111    end_board,
00112    is_our_board,
00113    key_press,
00114    NULL,
00115    set_level,
00116    NULL,
00117    NULL,
00118    NULL,
00119    NULL
00120 };
00121 
00122 /*
00123  * Main entry point mandatory for each Gcompris's game
00124  * ---------------------------------------------------
00125  *
00126  */
00127 
00128 GET_BPLUGIN_INFO(paratrooper)
00129 
00130 /*
00131  * in : boolean TRUE = PAUSE : FALSE = CONTINUE
00132  *
00133  */
00134 static void pause_board (gboolean pause)
00135 {
00136   if(gcomprisBoard==NULL)
00137     return;
00138 
00139   if(pause)
00140     {
00141       if (dummy_id) {
00142        gtk_timeout_remove (dummy_id);
00143        dummy_id = 0;
00144       }
00145       if (drop_tux_id) {
00146        gtk_timeout_remove (drop_tux_id);
00147        drop_tux_id = 0;
00148       }
00149     }
00150   else
00151     {
00152       if(gamewon == TRUE) /* the game is won */
00153        {
00154          gcomprisBoard->level++;
00155          if(gcomprisBoard->level>gcomprisBoard->maxlevel) { // the current board is finished : bail out
00156            gc_bonus_end_display(BOARD_FINISHED_RANDOM);
00157            return;
00158          }
00159          printf("paratrooper pause start next level\n");
00160        }
00161 
00162       // Unpause code
00163       if(!dummy_id) {
00164        dummy_id = gtk_timeout_add (1000, (GtkFunction) paratrooper_move_items, NULL);
00165       }
00166       if(paratrooperItem.status!=TUX_INPLANE && paratrooperItem.status!=TUX_LANDED) {
00167        drop_tux_id = gtk_timeout_add (1000, (GtkFunction) paratrooper_move_tux, NULL);
00168       }
00169 
00170       if(gamewon == TRUE) /* the game is won */
00171          paratrooper_next_level();
00172     }
00173 }
00174 
00175 /*
00176  */
00177 static void start_board (GcomprisBoard *agcomprisBoard)
00178 {
00179 
00180   if(agcomprisBoard!=NULL)
00181     {
00182       gcomprisBoard=agcomprisBoard;
00183 
00184       /* disable im_context */
00185       gcomprisBoard->disable_im_context = TRUE;
00186 
00187       gc_set_background(gnome_canvas_root(gcomprisBoard->canvas), "images/scenery3_background.png");
00188 
00189 
00190       /* set initial values for this level */
00191       gcomprisBoard->level = 1;
00192       gcomprisBoard->maxlevel = 6;
00193       gc_bar_set(GC_BAR_LEVEL);
00194 
00195       /* Init of paratrooper struct */
00196       paratrooperItem.rootitem = NULL;
00197 
00198       paratrooper_next_level();
00199 
00200       pause_board(FALSE);
00201 
00202     }
00203 
00204 }
00205 
00206 static void
00207 end_board ()
00208 {
00209 
00210   if(gcomprisBoard!=NULL)
00211     {
00212       pause_board(TRUE);
00213       paratrooper_destroy_all_items();
00214       gcomprisBoard->level = 1;       // Restart this game to zero
00215     }
00216   gcomprisBoard = NULL;
00217 }
00218 
00219 static void
00220 set_level (guint level)
00221 {
00222 
00223   if(gcomprisBoard!=NULL)
00224     {
00225       gcomprisBoard->level=level;
00226       paratrooper_next_level();
00227     }
00228 }
00229 
00230 static gint key_press(guint keyval, gchar *commit_str, gchar *preedit_str)
00231 {
00232 
00233   if(!gcomprisBoard)
00234     return FALSE;
00235 
00236 
00237   /* Add some filter for control and shift key */
00238   switch (keyval)
00239     {
00240       /* Avoid all this keys to be interpreted by this game */
00241     case GDK_Shift_L:
00242     case GDK_Shift_R:
00243     case GDK_Control_L:
00244     case GDK_Control_R:
00245     case GDK_Caps_Lock:
00246     case GDK_Shift_Lock:
00247     case GDK_Meta_L:
00248     case GDK_Meta_R:
00249     case GDK_Alt_L:
00250     case GDK_Alt_R:
00251     case GDK_Super_L:
00252     case GDK_Super_R:
00253     case GDK_Hyper_L:
00254     case GDK_Hyper_R:
00255     case GDK_Num_Lock:
00256       return FALSE; 
00257     case GDK_KP_Enter:
00258     case GDK_Return:
00259       return TRUE;
00260     case GDK_Right:
00261       break;
00262     case GDK_Left:
00263       break;
00264     case GDK_Up:
00265       if(paratrooperItem.speed >= 3)
00266        paratrooperItem.speed--;
00267       return TRUE;
00268     case GDK_Down:
00269       if(paratrooperItem.speed <= 6)
00270       paratrooperItem.speed++;
00271       return TRUE;
00272     }
00273 
00274   next_state();
00275 
00276   return TRUE;
00277 }
00278 
00279 static gboolean
00280 is_our_board (GcomprisBoard *gcomprisBoard)
00281 {
00282   if (gcomprisBoard)
00283     {
00284       if(g_strcasecmp(gcomprisBoard->type, "paratrooper")==0)
00285        {
00286          /* Set the plugin entry */
00287          gcomprisBoard->plugin=&menu_bp;
00288 
00289          return TRUE;
00290        }
00291     }
00292   return FALSE;
00293 }
00294 
00295 /*-------------------------------------------------------------------------------*/
00296 /*-------------------------------------------------------------------------------*/
00297 /*-------------------------------------------------------------------------------*/
00298 /*-------------------------------------------------------------------------------*/
00299 
00300 /* set initial values for the next level */
00301 static void paratrooper_next_level() 
00302 {
00303   GdkPixbuf *pixmap = NULL;
00304   char *str = NULL;
00305 
00306   gamewon = FALSE;
00307 
00308   gc_bar_set_level(gcomprisBoard);
00309 
00310   paratrooper_destroy_all_items();
00311 
00312   /* Try the next level */
00313   speed=100+(30/(gcomprisBoard->level));
00314   gcomprisBoard->number_of_sublevel=0;
00315   /* Make the images tend to 0.5 ratio */
00316   imageZoom=0.4+(0.4/(gcomprisBoard->level));
00317 
00318   /* Setup and Display the plane */
00319   planespeed_y = 0;
00320   planespeed_x = 4 + gcomprisBoard->level;
00321   str = g_strdup_printf("%s%s", pixmapsdir, "tuxplane.png");
00322   pixmap = gc_pixmap_load(str);
00323   plane_x = 0;
00324   plane_y = 40;
00325   planeitem = gnome_canvas_item_new (gnome_canvas_root(gcomprisBoard->canvas),
00326                                  gnome_canvas_pixbuf_get_type (),
00327                                  "pixbuf", pixmap, 
00328                                  "x", (double) plane_x,
00329                                  "y", (double) plane_y,
00330                                  "width", (double) gdk_pixbuf_get_width(pixmap)*imageZoom,
00331                                  "height", (double) gdk_pixbuf_get_height(pixmap)*imageZoom,
00332                                  "width_set", TRUE, 
00333                                  "height_set", TRUE,
00334                                  NULL);
00335   gtk_signal_connect(GTK_OBJECT(planeitem), "event",
00336                    (GtkSignalFunc) item_event,
00337                    NULL);
00338   gdk_pixbuf_unref(pixmap);
00339  
00340   windspeed = (3 + rand()%gcomprisBoard->level);
00341   if(rand()%2==0)
00342     windspeed *= -1;
00343 
00344   /* Drop a cloud */
00345   gtk_timeout_add (200,
00346                  (GtkFunction) paratrooper_drop_clouds, NULL);
00347 
00348   /* Display the target */
00349   g_free(str);
00350   str = g_strdup_printf("%s%s", pixmapsdir, "fishingboat.png");
00351   pixmap = gc_pixmap_load(str);
00352   boat_x = 350;
00353   boat_y = gcomprisBoard->height-100;
00354   boat_landarea_y = boat_y+20;
00355   boat_length = gdk_pixbuf_get_width(pixmap)*imageZoom;
00356   boatitem = gnome_canvas_item_new (gnome_canvas_root(gcomprisBoard->canvas),
00357                                 gnome_canvas_pixbuf_get_type (),
00358                                 "pixbuf", pixmap, 
00359                                 "x", (double) boat_x,
00360                                 "y", (double) boat_y,
00361                                 "width", (double) gdk_pixbuf_get_width(pixmap)*imageZoom,
00362                                 "height", (double) gdk_pixbuf_get_height(pixmap),
00363                                 "width_set", TRUE, 
00364                                 "height_set", TRUE,
00365                                 NULL);
00366   gdk_pixbuf_unref(pixmap);
00367 
00368   /* Prepare the parachute */
00369   if (drop_tux_id) {
00370     gtk_timeout_remove (drop_tux_id);
00371     drop_tux_id = 0;
00372   }
00373 
00374   paratrooperItem.status    = TUX_INPLANE;
00375   paratrooperItem.x         = 0;
00376   paratrooperItem.y         = 60;
00377   paratrooperItem.speed            = 3;
00378 
00379   paratrooperItem.rootitem = \
00380     gnome_canvas_item_new (gnome_canvas_root(gcomprisBoard->canvas),
00381                         gnome_canvas_group_get_type (),
00382                         "x", (double)paratrooperItem.x,
00383                         "y", (double)paratrooperItem.y,
00384                         NULL);
00385 
00386   g_free(str);
00387   str = g_strdup_printf("%s%s", pixmapsdir, "minitux.png");
00388   pixmap = gc_pixmap_load(str);
00389 
00390   paratrooperItem.paratrooper = gnome_canvas_item_new (GNOME_CANVAS_GROUP(paratrooperItem.rootitem),
00391                                                  gnome_canvas_pixbuf_get_type (),
00392                                                  "pixbuf", pixmap, 
00393                                                  "x", (double) -gdk_pixbuf_get_width(pixmap)/2,
00394                                                  "y", (double) -gdk_pixbuf_get_height(pixmap)/2,
00395                                                  "width", (double) gdk_pixbuf_get_width(pixmap),
00396                                                  "height", (double) gdk_pixbuf_get_height(pixmap),
00397                                                  NULL);
00398   gnome_canvas_item_hide(paratrooperItem.paratrooper);
00399   gdk_pixbuf_unref(pixmap);
00400   gtk_signal_connect(GTK_OBJECT(paratrooperItem.paratrooper), "event",
00401                    (GtkSignalFunc) item_event,
00402                    NULL);
00403 
00404   g_free(str);
00405   str = g_strdup_printf("%s%s", pixmapsdir, "parachute.png");
00406   pixmap = gc_pixmap_load(str);
00407 
00408   paratrooperItem.parachute = gnome_canvas_item_new (GNOME_CANVAS_GROUP(paratrooperItem.rootitem),
00409                                                gnome_canvas_pixbuf_get_type (),
00410                                                "pixbuf", pixmap, 
00411                                                "x", (double) -gdk_pixbuf_get_width(pixmap)/2,
00412                                                "y", (double) -(gdk_pixbuf_get_height(pixmap)/2)-60,
00413                                                "width", (double) gdk_pixbuf_get_width(pixmap),
00414                                                "height", (double) gdk_pixbuf_get_height(pixmap),
00415                                                NULL);
00416   gnome_canvas_item_hide(paratrooperItem.parachute);
00417   gdk_pixbuf_unref(pixmap);
00418 
00419   g_free (str);
00420 
00421 }
00422 
00423 
00424 /* Move the plane */
00425 static void paratrooper_move_plane(GnomeCanvasItem *item)
00426 {
00427 
00428   if(plane_x>gcomprisBoard->width && planespeed_x>0)
00429     {
00430       double x1, y1, x2, y2;
00431       gnome_canvas_item_get_bounds    (item,
00432                                    &x1,
00433                                    &y1,
00434                                    &x2,
00435                                    &y2);
00436       gnome_canvas_item_move(item, (double)-gcomprisBoard->width-(x2-x1), (double)planespeed_y);
00437       plane_x = plane_x - gcomprisBoard->width - (x2-x1);
00438 
00439       if(paratrooperItem.status!=TUX_INPLANE)
00440        gnome_canvas_item_hide(item);
00441     } 
00442 
00443   gnome_canvas_item_move(item, (double)planespeed_x, (double)planespeed_y);
00444   plane_x+=planespeed_x;
00445   plane_y+=planespeed_y;
00446 }
00447 
00448 static void paratrooper_move_cloud(CloudItem *clouditem)
00449 {
00450   double x1, y1, x2, y2;
00451   GnomeCanvasItem *item = clouditem->rootitem;
00452 
00453   gnome_canvas_item_move(item, windspeed, 0.0);
00454 
00455   gnome_canvas_item_get_bounds    (item,
00456                                &x1,
00457                                &y1,
00458                                &x2,
00459                                &y2);
00460 
00461   /* Manage the wrapping for the cloud */  
00462   if(windspeed<0 && x2<0)
00463     {
00464       gnome_canvas_item_move(item, gcomprisBoard->width, 0.0);
00465     }
00466   else if(windspeed>0 && x1>gcomprisBoard->width)
00467     {
00468       gnome_canvas_item_move(item, -gcomprisBoard->width, 0.0);
00469     }
00470 }
00471 
00472 static void paratrooper_destroy_item(CloudItem *clouditem)
00473 {
00474   GnomeCanvasItem *item = clouditem->rootitem;
00475 
00476   item_list = g_list_remove (item_list, clouditem);
00477   item2del_list = g_list_remove (item2del_list, clouditem);
00478   gtk_object_destroy (GTK_OBJECT(item));
00479 
00480   g_free(clouditem);
00481 }
00482 
00483 /* Destroy items that falls out of the canvas */
00484 static void paratrooper_destroy_items()
00485 {
00486   CloudItem *clouditem;
00487 
00488   while(g_list_length(item2del_list)>0) 
00489     {
00490       clouditem = g_list_nth_data(item2del_list, 0);
00491       paratrooper_destroy_item(clouditem);
00492     }
00493 }
00494 
00495 /* Destroy all the items */
00496 static void paratrooper_destroy_all_items()
00497 {
00498   CloudItem *clouditem;
00499 
00500   while(g_list_length(item_list)>0) 
00501     {
00502       clouditem = g_list_nth_data(item_list, 0);
00503       paratrooper_destroy_item(clouditem);
00504     }
00505 
00506   if(planeitem)
00507     {
00508       gtk_object_destroy (GTK_OBJECT(planeitem));
00509       planeitem = NULL;
00510     }
00511 
00512   if(boatitem)
00513     {
00514       gtk_object_destroy (GTK_OBJECT(boatitem));
00515       boatitem = NULL;
00516     }
00517 
00518   if(paratrooperItem.rootitem)
00519     {
00520       gtk_object_destroy (GTK_OBJECT(paratrooperItem.rootitem));
00521       paratrooperItem.rootitem = NULL;
00522     }
00523 }
00524 
00525 /*
00526  * This does the moves of the game items on the play canvas
00527  *
00528  */
00529 static gint paratrooper_move_items (GtkWidget *widget, gpointer data)
00530 {
00531   g_list_foreach (item_list, (GFunc) paratrooper_move_cloud, NULL);
00532 
00533   /* Destroy items that falls out of the canvas */
00534   paratrooper_destroy_items();
00535 
00536   /* move the plane */
00537   paratrooper_move_plane(planeitem);
00538 
00539   dummy_id = gtk_timeout_add (speed,
00540                            (GtkFunction) paratrooper_move_items, NULL);
00541 
00542   return(FALSE);
00543 }
00544 
00545 /*
00546  * This does the moves of the game's paratropper
00547  *
00548  */
00549 static gint paratrooper_move_tux (GtkWidget *widget, gpointer data)
00550 {
00551   gint offset;
00552 
00553   /* Manage the wrapping */
00554   if(paratrooperItem.x<0) {
00555     paratrooperItem.x+=gcomprisBoard->width;
00556     gnome_canvas_item_move(paratrooperItem.rootitem, gcomprisBoard->width, 0);
00557   }
00558   if(paratrooperItem.x>gcomprisBoard->width) {
00559     paratrooperItem.x-=gcomprisBoard->width;
00560     gnome_canvas_item_move(paratrooperItem.rootitem, -gcomprisBoard->width, 0);
00561   }
00562 
00563   offset = ( windspeed<0 ? -1 : 1 );
00564   gnome_canvas_item_move(paratrooperItem.rootitem, offset, paratrooperItem.speed);
00565   paratrooperItem.y += paratrooperItem.speed;
00566   paratrooperItem.x += offset;
00567 
00568   /* Check we reached the target */
00569   if(paratrooperItem.y>boat_landarea_y)
00570     {
00571       if(paratrooperItem.x>boat_x && paratrooperItem.x<boat_x+boat_length &&
00572         paratrooperItem.status==TUX_FLYING)
00573        {
00574          gnome_canvas_item_hide(paratrooperItem.parachute);
00575          paratrooperItem.status = TUX_LANDED;
00576          gc_sound_play_ogg ("sounds/bonus.ogg", NULL);
00577          next_state();
00578        }
00579       else
00580        {
00581          if(paratrooperItem.y<gcomprisBoard->height-20)
00582            drop_tux_id = gtk_timeout_add (150,
00583                                       (GtkFunction) paratrooper_move_tux, NULL);
00584          else
00585            {
00586              gnome_canvas_item_hide(paratrooperItem.parachute);
00587              paratrooperItem.status = TUX_CRASHED;
00588              gc_sound_play_ogg ("sounds/crash.ogg", NULL);
00589              next_state();
00590            }
00591        }
00592     }
00593   else
00594     {
00595       drop_tux_id = gtk_timeout_add (150,
00596                                  (GtkFunction) paratrooper_move_tux, NULL);
00597     }
00598 
00599   return(FALSE);
00600 }
00601 
00602 static GnomeCanvasItem *paratrooper_create_cloud(GnomeCanvasGroup *parent)
00603 {
00604   GdkPixbuf *pixmap = NULL;
00605   GnomeCanvasItem *itemgroup;
00606   char *str = NULL;
00607   int x;
00608   CloudItem *clouditem;
00609 
00610 
00611   str = g_strdup_printf("%s%s", pixmapsdir, "cloud.png");
00612   pixmap = gc_pixmap_load(str);
00613 
00614   if(windspeed>0)
00615     x = 0;
00616   else
00617     x = gcomprisBoard->width;
00618 
00619   itemgroup = \
00620     gnome_canvas_item_new (parent,
00621                         gnome_canvas_group_get_type (),
00622                         "x", (double) x,
00623                         "y", (double)(rand()%(gcomprisBoard->height-200-
00624                                            (guint)(gdk_pixbuf_get_height(pixmap)*
00625                                                   imageZoom))),
00626                         NULL);
00627 
00628 
00629   gnome_canvas_item_new (GNOME_CANVAS_GROUP(itemgroup),
00630                       gnome_canvas_pixbuf_get_type (),
00631                       "pixbuf", pixmap, 
00632                       "x", (double) -gdk_pixbuf_get_width(pixmap)*imageZoom/2,
00633                       "y", (double) -gdk_pixbuf_get_height(pixmap)*imageZoom/2,
00634                       "width", (double) gdk_pixbuf_get_width(pixmap)*imageZoom,
00635                       "height", (double) gdk_pixbuf_get_height(pixmap)*imageZoom,
00636                       "width_set", TRUE, 
00637                       "height_set", TRUE,
00638                       NULL);
00639   gdk_pixbuf_unref(pixmap);
00640 
00641 
00642   /* The plane is always on top */
00643   gnome_canvas_item_raise_to_top(planeitem);
00644 
00645   clouditem = g_malloc(sizeof(CloudItem));
00646   clouditem->rootitem = itemgroup;
00647 
00648   item_list = g_list_append (item_list, clouditem);
00649 
00650   g_free (str);
00651 
00652   return (itemgroup);
00653 }
00654 
00655 static void paratrooper_add_new_item() 
00656 {
00657   paratrooper_create_cloud(gnome_canvas_root(gcomprisBoard->canvas));
00658 }
00659 
00660 /*
00661  * This is called on a low frequency and is used to drop new items
00662  *
00663  */
00664 static gint paratrooper_drop_clouds (GtkWidget *widget, gpointer data)
00665 {
00666   paratrooper_add_new_item();
00667 
00668   return (FALSE);
00669 }
00670 
00671 
00672 
00673 /*
00674  * This is the state machine of the paratrooper
00675  */
00676 void next_state()
00677 {
00678 
00679   switch(paratrooperItem.status)
00680     {
00681     case TUX_INPLANE:
00682       gnome_canvas_item_move(paratrooperItem.rootitem, plane_x+100, 0);
00683       paratrooperItem.x += plane_x+100;
00684       gnome_canvas_item_show(paratrooperItem.paratrooper);
00685       paratrooperItem.status = TUX_DROPPING;
00686       drop_tux_id = gtk_timeout_add (10, (GtkFunction) paratrooper_move_tux, NULL);
00687       break;
00688     case TUX_DROPPING:
00689       gnome_canvas_item_lower_to_bottom(paratrooperItem.parachute);
00690       gnome_canvas_item_show(paratrooperItem.parachute);
00691       paratrooperItem.speed /= 3;
00692       paratrooperItem.status = TUX_FLYING;
00693       break;
00694     case TUX_LANDED:
00695       gamewon = TRUE;
00696       gc_bonus_display(gamewon, BONUS_TUX);
00697       break;
00698     case TUX_CRASHED:
00699       /* Restart */
00700       gnome_canvas_item_move(paratrooperItem.rootitem, -paratrooperItem.x, -paratrooperItem.y+60);
00701       paratrooperItem.status       = TUX_INPLANE;
00702       paratrooperItem.x            = 0;
00703       paratrooperItem.y            = 60;
00704       paratrooperItem.speed = 3;
00705       gnome_canvas_item_hide(paratrooperItem.paratrooper);
00706       gnome_canvas_item_show(planeitem);
00707       break;
00708     default:
00709       break;
00710     }
00711 }
00712 
00713 static gint
00714 item_event(GnomeCanvasItem *item, GdkEvent *event, void *data)
00715 {
00716 
00717   if(!gcomprisBoard)
00718     return FALSE;
00719 
00720    switch (event->type) 
00721      {
00722      case GDK_BUTTON_PRESS:
00723        next_state();
00724        break;
00725 
00726      default:
00727        break;
00728      }
00729          
00730    return FALSE;
00731  }