~ml-launchpad/ubuntu/natty/gcompris/fix-for-777349

« back to all changes in this revision

Viewing changes to src/paratrooper-activity/paratrooper.c

  • Committer: Bazaar Package Importer
  • Author(s): Marc Gariepy, Marc Gariepy, Stephane Graber
  • Date: 2010-01-04 17:42:49 UTC
  • mfrom: (1.1.14 upstream)
  • Revision ID: james.westby@ubuntu.com-20100104174249-7bupatd9dtxyhvs4
Tags: 9.0-0ubuntu1
[Marc Gariepy]
* New upstream release (9.0).
* Remove cache.c from POTFILES to avoid FTBFS
* Remove unneeded rm in debian/rules (file no longer exists upstream)

[Stephane Graber]
* Bump Debian standards to 3.8.3
* Add patch system (dpatch)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* gcompris - paratrooper.c
 
2
 *
 
3
 * Copyright (C) 2000, 2008 Bruno Coudoin
 
4
 *
 
5
 *   This program is free software; you can redistribute it and/or modify
 
6
 *   it under the terms of the GNU General Public License as published by
 
7
 *   the Free Software Foundation; either version 3 of the License, or
 
8
 *   (at your option) any later version.
 
9
 *
 
10
 *   This program is distributed in the hope that it will be useful,
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *   GNU General Public License for more details.
 
14
 *
 
15
 *   You should have received a copy of the GNU General Public License
 
16
 *   along with this program; if not, see <http://www.gnu.org/licenses/>.
 
17
 */
 
18
 
 
19
#include "gcompris/gcompris.h"
 
20
 
 
21
#define SOUNDLISTFILE PACKAGE
 
22
 
 
23
static int gamewon;
 
24
 
 
25
static GcomprisBoard *gcomprisBoard = NULL;
 
26
 
 
27
static gint drop_tux_id = 0;
 
28
 
 
29
static GooCanvasItem *boardRootItem = NULL;
 
30
static gint boat_x, boat_y, boat_landarea_y, boat_width;
 
31
 
 
32
static gint plane_x, plane_y;
 
33
static gint planespeed_x;
 
34
static gdouble windspeed;
 
35
 
 
36
static GooCanvasItem *planeitem;
 
37
 
 
38
typedef enum
 
39
{
 
40
  TUX_INPLANE           = 1 << 0,
 
41
  TUX_DROPPING          = 1 << 1,
 
42
  TUX_FLYING            = 1 << 2,
 
43
  TUX_LANDED            = 1 << 3,
 
44
  TUX_CRASHED           = 1 << 4
 
45
} ParaStatus;
 
46
 
 
47
 
 
48
typedef struct {
 
49
  ParaStatus status;
 
50
  double speed;
 
51
  double drift;
 
52
  gboolean speed_override;
 
53
  GooCanvasItem *rootitem;
 
54
  GooCanvasItem *paratrooper;
 
55
  GooCanvasItem *instruct;
 
56
} ParatrooperItem;
 
57
 
 
58
static  ParatrooperItem paratrooperItem;
 
59
 
 
60
 
 
61
static void              start_board (GcomprisBoard *agcomprisBoard);
 
62
static void              pause_board (gboolean pause);
 
63
static void              end_board (void);
 
64
static gboolean          is_our_board (GcomprisBoard *gcomprisBoard);
 
65
static void              set_level (guint level);
 
66
static gint              key_press(guint keyval, gchar *commit_str, gchar *preedit_str);
 
67
 
 
68
static void              paratrooper_create_cloud(GooCanvasItem *parent);
 
69
static gint              paratrooper_drop_clouds (GtkWidget *widget, gpointer data);
 
70
static gint              paratrooper_move_tux (GtkWidget *widget, gpointer data);
 
71
static void              paratrooper_destroy_all_items(void);
 
72
static void              paratrooper_next_level(void);
 
73
static gboolean          item_event (GooCanvasItem  *item,
 
74
                                     GooCanvasItem  *target,
 
75
                                     GdkEventButton *event,
 
76
                                     gpointer data);
 
77
static void              next_state(void);
 
78
 
 
79
 
 
80
static double            speed = 0.0;
 
81
static double            imageZoom = 0.0;
 
82
 
 
83
/* Description of this plugin */
 
84
static BoardPlugin menu_bp =
 
85
{
 
86
   NULL,
 
87
   NULL,
 
88
   "Parachutist",
 
89
   "Direct the parachutist to help him or her land safely",
 
90
   "Bruno Coudoin <bruno.coudoin@free.fr>",
 
91
   NULL,
 
92
   NULL,
 
93
   NULL,
 
94
   NULL,
 
95
   start_board,
 
96
   pause_board,
 
97
   end_board,
 
98
   is_our_board,
 
99
   key_press,
 
100
   NULL,
 
101
   set_level,
 
102
   NULL,
 
103
   NULL,
 
104
   NULL,
 
105
   NULL
 
106
};
 
107
 
 
108
/*
 
109
 * Main entry point mandatory for each Gcompris's game
 
110
 * ---------------------------------------------------
 
111
 *
 
112
 */
 
113
 
 
114
GET_BPLUGIN_INFO(paratrooper)
 
115
 
 
116
/*
 
117
 * in : boolean TRUE = PAUSE : FALSE = CONTINUE
 
118
 *
 
119
 */
 
120
static void pause_board (gboolean pause)
 
121
{
 
122
  if(gcomprisBoard==NULL)
 
123
    return;
 
124
 
 
125
  if(pause)
 
126
    {
 
127
      if (drop_tux_id) {
 
128
        gtk_timeout_remove (drop_tux_id);
 
129
        drop_tux_id = 0;
 
130
      }
 
131
    }
 
132
  else
 
133
    {
 
134
      if(gamewon == TRUE) /* the game is won */
 
135
        {
 
136
          gcomprisBoard->level++;
 
137
          if(gcomprisBoard->level>gcomprisBoard->maxlevel)
 
138
            gcomprisBoard->level = gcomprisBoard->maxlevel;
 
139
        }
 
140
 
 
141
      // Unpause code
 
142
      if(paratrooperItem.status!=TUX_INPLANE && paratrooperItem.status!=TUX_LANDED) {
 
143
        drop_tux_id = gtk_timeout_add (1000, (GtkFunction) paratrooper_move_tux, NULL);
 
144
      }
 
145
 
 
146
      if(gamewon == TRUE) /* the game is won */
 
147
          paratrooper_next_level();
 
148
    }
 
149
}
 
150
 
 
151
/*
 
152
 */
 
153
static void start_board (GcomprisBoard *agcomprisBoard)
 
154
{
 
155
 
 
156
  if(agcomprisBoard!=NULL)
 
157
    {
 
158
      gcomprisBoard=agcomprisBoard;
 
159
 
 
160
      /* disable im_context */
 
161
      gcomprisBoard->disable_im_context = TRUE;
 
162
 
 
163
      gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas),
 
164
                        "paratrooper/scenery3_background.png");
 
165
 
 
166
 
 
167
      /* set initial values for this level */
 
168
      gcomprisBoard->level = 1;
 
169
      gcomprisBoard->maxlevel = 6;
 
170
      gc_bar_set(GC_BAR_LEVEL);
 
171
      gc_bar_location(BOARDWIDTH-200, -1, 0.9);
 
172
 
 
173
      /* Init of paratrooper struct */
 
174
      paratrooperItem.rootitem = NULL;
 
175
 
 
176
      paratrooper_next_level();
 
177
 
 
178
      pause_board(FALSE);
 
179
 
 
180
    }
 
181
 
 
182
}
 
183
 
 
184
static void
 
185
end_board ()
 
186
{
 
187
 
 
188
  if(gcomprisBoard!=NULL)
 
189
    {
 
190
      pause_board(TRUE);
 
191
      paratrooper_destroy_all_items();
 
192
      gcomprisBoard->level = 1;       // Restart this game to zero
 
193
    }
 
194
  gcomprisBoard = NULL;
 
195
}
 
196
 
 
197
static void
 
198
set_level (guint level)
 
199
{
 
200
 
 
201
  if(gcomprisBoard!=NULL)
 
202
    {
 
203
      gcomprisBoard->level=level;
 
204
      paratrooper_next_level();
 
205
    }
 
206
}
 
207
 
 
208
static gint key_press(guint keyval, gchar *commit_str, gchar *preedit_str)
 
209
{
 
210
 
 
211
  if(!gcomprisBoard)
 
212
    return FALSE;
 
213
 
 
214
 
 
215
  /* Add some filter for control and shift key */
 
216
  switch (keyval)
 
217
    {
 
218
      /* Avoid all this keys to be interpreted by this game */
 
219
    case 0:
 
220
    case GDK_Shift_L:
 
221
    case GDK_Shift_R:
 
222
    case GDK_Control_L:
 
223
    case GDK_Control_R:
 
224
    case GDK_Caps_Lock:
 
225
    case GDK_Shift_Lock:
 
226
    case GDK_Meta_L:
 
227
    case GDK_Meta_R:
 
228
    case GDK_Alt_L:
 
229
    case GDK_Alt_R:
 
230
    case GDK_Super_L:
 
231
    case GDK_Super_R:
 
232
    case GDK_Hyper_L:
 
233
    case GDK_Hyper_R:
 
234
    case GDK_Num_Lock:
 
235
      return FALSE;
 
236
    case GDK_KP_Enter:
 
237
    case GDK_Return:
 
238
      return TRUE;
 
239
    case GDK_Right:
 
240
      break;
 
241
    case GDK_Left:
 
242
      break;
 
243
    case GDK_Up:
 
244
      paratrooperItem.speed_override = 1;
 
245
      if(paratrooperItem.status == TUX_FLYING && paratrooperItem.speed >= 3)
 
246
        paratrooperItem.speed--;
 
247
      return TRUE;
 
248
    case GDK_Down:
 
249
      paratrooperItem.speed_override = 1;
 
250
      if(paratrooperItem.status == TUX_FLYING && paratrooperItem.speed <= 6)
 
251
        paratrooperItem.speed++;
 
252
      return TRUE;
 
253
    }
 
254
 
 
255
  next_state();
 
256
 
 
257
  return TRUE;
 
258
}
 
259
 
 
260
static gboolean
 
261
is_our_board (GcomprisBoard *gcomprisBoard)
 
262
{
 
263
  if (gcomprisBoard)
 
264
    {
 
265
      if(g_strcasecmp(gcomprisBoard->type, "paratrooper")==0)
 
266
        {
 
267
          /* Set the plugin entry */
 
268
          gcomprisBoard->plugin=&menu_bp;
 
269
 
 
270
          return TRUE;
 
271
        }
 
272
    }
 
273
  return FALSE;
 
274
}
 
275
 
 
276
/*-------------------------------------------------------------------------------*/
 
277
/*-------------------------------------------------------------------------------*/
 
278
/*-------------------------------------------------------------------------------*/
 
279
/*-------------------------------------------------------------------------------*/
 
280
 
 
281
/* set initial values for the next level */
 
282
static void paratrooper_next_level()
 
283
{
 
284
  RsvgHandle *svg_handle;
 
285
  RsvgDimensionData rsvg_dimension;
 
286
  GooCanvasItem *item;
 
287
  GooCanvasItem *planeroot;
 
288
  GooCanvasBounds bounds;
 
289
 
 
290
  gamewon = FALSE;
 
291
 
 
292
  gc_bar_set_level(gcomprisBoard);
 
293
 
 
294
  paratrooper_destroy_all_items();
 
295
 
 
296
  boardRootItem = \
 
297
    goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
 
298
                          NULL);
 
299
 
 
300
  /* Try the next level */
 
301
  speed=10+(30/(gcomprisBoard->level));
 
302
  gcomprisBoard->number_of_sublevel=0;
 
303
  /* Make the images tend to 0.5 ratio */
 
304
  imageZoom=0.4+(0.2 * (2 - (gcomprisBoard->level-1) % 3));
 
305
 
 
306
  /* Setup and Display the plane */
 
307
  svg_handle = gc_rsvg_load("paratrooper/tuxplane.svgz");
 
308
  rsvg_handle_get_dimensions (svg_handle, &rsvg_dimension);
 
309
 
 
310
  planeroot = \
 
311
    goo_canvas_group_new (boardRootItem,
 
312
                          NULL);
 
313
  planespeed_x = 4 + gcomprisBoard->level;
 
314
 
 
315
  plane_x = -rsvg_dimension.width;
 
316
  plane_y = 10;
 
317
  planeitem = goo_canvas_svg_new (planeroot,
 
318
                                svg_handle,
 
319
                                NULL);
 
320
 
 
321
  goo_canvas_item_set_simple_transform(planeitem,
 
322
                                       plane_x,
 
323
                                       plane_y,
 
324
                                       imageZoom,
 
325
                                       0);
 
326
  goo_canvas_item_animate(planeroot,
 
327
                          BOARDWIDTH + rsvg_dimension.width,
 
328
                          plane_y,
 
329
                          1,
 
330
                          0,
 
331
                          FALSE,
 
332
                          BOARDWIDTH * speed,
 
333
                          speed*1.5,
 
334
                          GOO_CANVAS_ANIMATE_RESTART);
 
335
 
 
336
  g_signal_connect(planeitem, "button-press-event",
 
337
                     (GtkSignalFunc) item_event,
 
338
                     NULL);
 
339
  gc_item_focus_init(planeitem, NULL);
 
340
  g_object_unref(svg_handle);
 
341
 
 
342
  windspeed = (3 + rand() % (100 * gcomprisBoard->level) / 100);
 
343
  if(rand()%2==0)
 
344
    windspeed *= -1;
 
345
  if (gcomprisBoard->level >= 4)
 
346
    windspeed *= 2;
 
347
 
 
348
  /* Drop a cloud */
 
349
  gtk_timeout_add (200,
 
350
                   (GtkFunction) paratrooper_drop_clouds, NULL);
 
351
 
 
352
  /* Display the target */
 
353
  svg_handle = gc_rsvg_load("paratrooper/fishingboat.svgz");
 
354
  rsvg_handle_get_dimensions (svg_handle, &rsvg_dimension);
 
355
  boat_x = (BOARDWIDTH - rsvg_dimension.width) / 2;
 
356
  boat_y = BOARDHEIGHT - 100;
 
357
  boat_landarea_y = boat_y + 20;
 
358
  item = \
 
359
    goo_canvas_svg_new (boardRootItem,
 
360
                      svg_handle,
 
361
                      NULL);
 
362
  goo_canvas_item_translate(item,
 
363
                            -rsvg_dimension.width/2,
 
364
                            boat_y - 50);
 
365
 
 
366
  goo_canvas_item_get_bounds(item, &bounds);
 
367
  boat_width = bounds.x2 - bounds.x1;
 
368
 
 
369
  goo_canvas_item_animate(item,
 
370
                          boat_x,
 
371
                          boat_y,
 
372
                          1,
 
373
                          0,
 
374
                          TRUE,
 
375
                          BOARDWIDTH/2 * 30,
 
376
                          40*2,
 
377
                          GOO_CANVAS_ANIMATE_FREEZE);
 
378
 
 
379
  g_object_unref(svg_handle);
 
380
 
 
381
  /* Prepare the parachute */
 
382
  if (drop_tux_id) {
 
383
    gtk_timeout_remove (drop_tux_id);
 
384
    drop_tux_id = 0;
 
385
  }
 
386
 
 
387
  paratrooperItem.status        = TUX_INPLANE;
 
388
  paratrooperItem.speed         = 3;
 
389
 
 
390
  paratrooperItem.rootitem = \
 
391
    goo_canvas_group_new (boardRootItem,
 
392
                          NULL);
 
393
 
 
394
  paratrooperItem.paratrooper = \
 
395
    goo_canvas_svg_new (paratrooperItem.rootitem,
 
396
                      NULL,
 
397
                      NULL);
 
398
 
 
399
  g_object_set (paratrooperItem.paratrooper, "visibility",
 
400
                GOO_CANVAS_ITEM_INVISIBLE, NULL);
 
401
 
 
402
  g_signal_connect(paratrooperItem.paratrooper, "button-press-event",
 
403
                     (GtkSignalFunc) item_event,
 
404
                     NULL);
 
405
 
 
406
  paratrooperItem.instruct = \
 
407
    goo_canvas_text_new (boardRootItem,
 
408
                         _("Control fall speed with up and down arrow keys."),
 
409
                         (double) BOARDWIDTH / 2.0,
 
410
                         (double) 130,
 
411
                         -1,
 
412
                         GTK_ANCHOR_CENTER,
 
413
                         "font", gc_skin_font_board_medium,
 
414
                         "fill_color_rgba", gc_skin_color_title,
 
415
                         NULL);
 
416
  g_object_set (paratrooperItem.instruct, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
 
417
}
 
418
 
 
419
 
 
420
/* Destroy all the items */
 
421
static void paratrooper_destroy_all_items()
 
422
{
 
423
  if(boardRootItem)
 
424
    goo_canvas_item_remove(boardRootItem);
 
425
  boardRootItem = NULL;
 
426
}
 
427
 
 
428
/*
 
429
 * This does the moves of the game's paratropper
 
430
 *
 
431
 */
 
432
static gint
 
433
paratrooper_move_tux (GtkWidget *widget, gpointer data)
 
434
{
 
435
  double offset;
 
436
  GooCanvasBounds bounds;
 
437
  guint center;
 
438
 
 
439
  goo_canvas_item_get_bounds(paratrooperItem.paratrooper, &bounds);
 
440
 
 
441
  center = bounds.x1 + (bounds.x2 - bounds.x1) / 2;
 
442
 
 
443
  /* Manage the wrapping */
 
444
  if(center < 0) {
 
445
    goo_canvas_item_translate(paratrooperItem.rootitem,
 
446
                              BOARDWIDTH,
 
447
                              0);
 
448
  }
 
449
  if(center > BOARDWIDTH) {
 
450
    goo_canvas_item_translate(paratrooperItem.rootitem,
 
451
                              -BOARDWIDTH,
 
452
                              0);
 
453
  }
 
454
 
 
455
  offset = (windspeed / 2 + 15 * paratrooperItem.drift) / 16;
 
456
  paratrooperItem.drift = offset;
 
457
 
 
458
  if (paratrooperItem.status == TUX_DROPPING && gcomprisBoard->level >= 4)
 
459
    paratrooperItem.speed *= 1.05;
 
460
 
 
461
  if (paratrooperItem.status == TUX_FLYING && paratrooperItem.speed > 3 &&
 
462
      !paratrooperItem.speed_override)
 
463
    paratrooperItem.speed /= 1.2;
 
464
 
 
465
  goo_canvas_item_translate(paratrooperItem.rootitem,
 
466
                            offset, paratrooperItem.speed);
 
467
 
 
468
  /* Check we reached the target */
 
469
  if(bounds.y2 > boat_landarea_y)
 
470
    {
 
471
      if( center > boat_x &&
 
472
          center < boat_x + boat_width &&
 
473
          paratrooperItem.status == TUX_FLYING)
 
474
        {
 
475
          paratrooperItem.status = TUX_LANDED;
 
476
          next_state();
 
477
        }
 
478
      else
 
479
        {
 
480
          if(bounds.y2 < BOARDHEIGHT - 20)
 
481
            drop_tux_id = gtk_timeout_add (150,
 
482
                                           (GtkFunction) paratrooper_move_tux,
 
483
                                           NULL);
 
484
          else
 
485
            {
 
486
              paratrooperItem.status = TUX_CRASHED;
 
487
              next_state();
 
488
            }
 
489
        }
 
490
    }
 
491
  else
 
492
    {
 
493
      drop_tux_id = gtk_timeout_add (150,
 
494
                                     (GtkFunction) paratrooper_move_tux, NULL);
 
495
    }
 
496
 
 
497
  return(FALSE);
 
498
}
 
499
 
 
500
static void
 
501
paratrooper_create_cloud(GooCanvasItem *parent)
 
502
{
 
503
  RsvgHandle *svg_handle = NULL;
 
504
  GooCanvasItem *item;
 
505
  GooCanvasItem *root;
 
506
  int x, y;
 
507
  int x_end;
 
508
  RsvgDimensionData rsvg_dimension;
 
509
 
 
510
  svg_handle = gc_rsvg_load("paratrooper/cloud.svgz");
 
511
  rsvg_handle_get_dimensions (svg_handle, &rsvg_dimension);
 
512
 
 
513
  if(windspeed>0)
 
514
    {
 
515
      x = 0;
 
516
      x_end = BOARDWIDTH;
 
517
    }
 
518
  else
 
519
    {
 
520
      x = BOARDWIDTH - rsvg_dimension.width * imageZoom;
 
521
      x_end = 0;
 
522
    }
 
523
 
 
524
  y = 60;
 
525
 
 
526
  root = \
 
527
    goo_canvas_group_new (parent,
 
528
                          NULL);
 
529
 
 
530
  item = goo_canvas_svg_new (root,
 
531
                           svg_handle,
 
532
                           NULL);
 
533
 
 
534
  goo_canvas_item_scale(item,
 
535
                        imageZoom, imageZoom);
 
536
 
 
537
  goo_canvas_item_translate(root, x, y);
 
538
 
 
539
  goo_canvas_item_animate(root,
 
540
                          x_end,
 
541
                          y,
 
542
                          1,
 
543
                          0,
 
544
                          TRUE,
 
545
                          BOARDWIDTH * (80 / ABS(windspeed)),
 
546
                          40,
 
547
                          GOO_CANVAS_ANIMATE_RESTART);
 
548
  g_object_unref(svg_handle);
 
549
 
 
550
  /* The plane is always on top */
 
551
  goo_canvas_item_raise(planeitem, NULL);
 
552
}
 
553
 
 
554
/*
 
555
 * This is called on a low frequency and is used to drop new items
 
556
 *
 
557
 */
 
558
static gint paratrooper_drop_clouds (GtkWidget *widget, gpointer data)
 
559
{
 
560
  paratrooper_create_cloud(boardRootItem);
 
561
 
 
562
  return (FALSE);
 
563
}
 
564
 
 
565
 
 
566
 
 
567
/*
 
568
 * This is the state machine of the paratrooper
 
569
 */
 
570
void next_state()
 
571
{
 
572
  GooCanvasBounds bounds;
 
573
 
 
574
  switch(paratrooperItem.status)
 
575
    {
 
576
    case TUX_INPLANE:
 
577
      {
 
578
        RsvgHandle *svg_handle;
 
579
 
 
580
        gc_sound_play_ogg ("sounds/tuxok.wav", NULL);
 
581
 
 
582
        svg_handle = gc_rsvg_load("paratrooper/minitux.svgz");
 
583
        g_object_set (paratrooperItem.paratrooper,
 
584
                      "svg-handle", svg_handle,
 
585
                      NULL);
 
586
        g_object_unref(svg_handle);
 
587
        gc_item_focus_init(paratrooperItem.paratrooper, NULL);
 
588
 
 
589
        goo_canvas_item_get_bounds(planeitem, &bounds);
 
590
 
 
591
        g_object_set (paratrooperItem.paratrooper, "visibility",
 
592
                      GOO_CANVAS_ITEM_VISIBLE, NULL);
 
593
        paratrooperItem.status = TUX_DROPPING;
 
594
        paratrooperItem.drift = planespeed_x;
 
595
 
 
596
        goo_canvas_item_translate(paratrooperItem.rootitem,
 
597
                                  (bounds.x1 > 0 ? bounds.x1 : 0),
 
598
                                  bounds.y2);
 
599
        drop_tux_id = \
 
600
          gtk_timeout_add (10, (GtkFunction) paratrooper_move_tux, NULL);
 
601
 
 
602
        gc_item_focus_remove(planeitem, NULL);
 
603
      }
 
604
      break;
 
605
 
 
606
    case TUX_DROPPING:
 
607
      {
 
608
        RsvgHandle *svg_handle;
 
609
 
 
610
        gc_sound_play_ogg ("sounds/eraser2.wav", NULL);
 
611
 
 
612
        svg_handle = gc_rsvg_load("paratrooper/parachute.svgz");
 
613
 
 
614
        g_object_set (paratrooperItem.paratrooper,
 
615
                      "svg-handle", svg_handle,
 
616
                      NULL);
 
617
 
 
618
        gc_item_focus_remove(paratrooperItem.paratrooper, NULL);
 
619
        g_object_unref(svg_handle);
 
620
 
 
621
        paratrooperItem.status = TUX_FLYING;
 
622
        paratrooperItem.speed_override = 0;
 
623
        if (gcomprisBoard->level >= 2) {
 
624
          goo_canvas_item_raise (paratrooperItem.instruct, NULL);
 
625
          g_object_set (paratrooperItem.instruct, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);
 
626
        }
 
627
      }
 
628
      break;
 
629
 
 
630
    case TUX_LANDED:
 
631
      gc_sound_play_ogg ("sounds/tuxok.wav", NULL);
 
632
      g_object_set (paratrooperItem.instruct, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
 
633
      gamewon = TRUE;
 
634
      gc_bonus_display(gamewon, GC_BONUS_TUX);
 
635
      break;
 
636
 
 
637
    case TUX_CRASHED:
 
638
      /* Restart */
 
639
      gc_sound_play_ogg ("sounds/bubble.wav", NULL);
 
640
      g_object_set (paratrooperItem.instruct, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
 
641
      goo_canvas_item_set_transform(paratrooperItem.rootitem, NULL);
 
642
      paratrooperItem.status    = TUX_INPLANE;
 
643
      paratrooperItem.speed     = 3;
 
644
      g_object_set (paratrooperItem.paratrooper, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL);
 
645
      g_object_set (planeitem, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL);
 
646
      gc_item_focus_init(planeitem, NULL);
 
647
      break;
 
648
 
 
649
    default:
 
650
      break;
 
651
    }
 
652
}
 
653
 
 
654
static gboolean
 
655
item_event (GooCanvasItem  *item,
 
656
            GooCanvasItem  *target,
 
657
            GdkEventButton *event,
 
658
            gpointer data)
 
659
{
 
660
 
 
661
  if(!gcomprisBoard)
 
662
    return FALSE;
 
663
 
 
664
  next_state();
 
665
  return FALSE;
 
666
}