Esempio n. 1
0
static void start_frigate_anim()
{
  GdkPixbuf *pixmap;
  int w;
  if (frigate_item)
    stop_frigate_anim();

  // the antisubmarine warfare frigate
  pixmap = gc_pixmap_load("submarine/asw_frigate.png");
  w = gdk_pixbuf_get_width(pixmap);

  frigate_item = goo_canvas_image_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
				       pixmap,
				       0,
				       0,
				       NULL);
  goo_canvas_item_translate(frigate_item, BOARDWIDTH, 6);
  goo_canvas_item_animate(frigate_item,
			  -w,
			  2.0,
			  1,
			  0,
			  TRUE,
			  100*1000,
			  100,
			  GOO_CANVAS_ANIMATE_RESTART);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif
}
Esempio n. 2
0
static void
start_animation_clicked (GtkWidget *button, gpointer data)
{
  /* Absolute. */
  goo_canvas_item_set_simple_transform (ellipse1, 100, 100, 1, 0);
  goo_canvas_item_animate (ellipse1, 500, 100, 2, 720, TRUE, 2000, 40,
			   GOO_CANVAS_ANIMATE_BOUNCE);

  goo_canvas_item_set_simple_transform (rect1, 100, 200, 1, 0);
  goo_canvas_item_animate (rect1, 100, 200, 1, 350, TRUE, 40 * 36, 40,
			   GOO_CANVAS_ANIMATE_RESTART);

  goo_canvas_item_set_simple_transform (rect3, 200, 200, 1, 0);
  goo_canvas_item_animate (rect3, 200, 200, 3, 0, TRUE, 400, 40,
			   GOO_CANVAS_ANIMATE_BOUNCE);

  /* Relative. */
  goo_canvas_item_set_simple_transform (ellipse2, 100, 400, 1, 0);
  goo_canvas_item_animate (ellipse2, 400, 0, 2, 720, FALSE, 2000, 40,
			   GOO_CANVAS_ANIMATE_BOUNCE);

  goo_canvas_item_set_simple_transform (rect2, 100, 500, 1, 0);
  goo_canvas_item_animate (rect2, 0, 0, 1, 350, FALSE, 40 * 36, 40,
			   GOO_CANVAS_ANIMATE_RESTART);

  goo_canvas_item_set_simple_transform (rect4, 200, 500, 1, 0);
  goo_canvas_item_animate (rect4, 0, 0, 3, 0, FALSE, 400, 40,
			   GOO_CANVAS_ANIMATE_BOUNCE);
}
Esempio n. 3
0
static void
on_animation_finished (GooCanvasItem *item,
		       gboolean       stopped,
		       gpointer       data)
{
  g_print ("Animation finished stopped: %i\n", stopped);

#if 0
  /* Test starting another animation. */
  goo_canvas_item_animate (ellipse1, 500, 200, 2, 720, TRUE, 2000, 40,
			   GOO_CANVAS_ANIMATE_BOUNCE);
#endif
}
Esempio n. 4
0
static VALUE
rg_animate(VALUE self, VALUE x, VALUE y, VALUE scale,
                           VALUE degrees, VALUE absolute, VALUE duration,
                           VALUE step_time, VALUE type)
{
    goo_canvas_item_animate(SELF(self),
                            NUM2DBL(x),
                            NUM2DBL(y),
                            NUM2DBL(scale),
                            NUM2DBL(degrees),
                            RTEST(absolute),
                            NUM2INT(duration),
                            NUM2INT(step_time),
                            rbgobj_get_enum(type, GOO_TYPE_CANVAS_ANIMATE_TYPE));
    return self;
}
Esempio n. 5
0
static GooCanvasItem *planegame_create_item(GooCanvasItem *parent)
{
    RsvgHandle *svg_handle;
    RsvgDimensionData dimension;
    GooCanvasItem *itemgroup;
    GooCanvasItem *item;
    char *number = NULL;
    int i, min;
    guint y;

    /* Random cloud number */
    if(g_random_int()%2==0)
    {
        /* Put the target */
        i = plane_target;
    }
    else
    {
        min = MAX(1, plane_target - 1);
        i   = min + g_random_int()%(plane_target - min + 3);
    }
    number = g_strdup_printf("%d", i);

    itemgroup = goo_canvas_group_new (parent, NULL);

    g_object_set_data (G_OBJECT (itemgroup),
                       "cloud_number", GINT_TO_POINTER (i));

    svg_handle = gc_rsvg_load("planegame/cloud.svgz");
    rsvg_handle_get_dimensions(svg_handle, &dimension);

    y = (g_random_int()%(BOARDHEIGHT - 40 -
                         (guint)(dimension.height * imageZoom)));

    goo_canvas_item_translate(itemgroup,
                              BOARDWIDTH,
                              y);

    item = goo_canvas_svg_new (itemgroup,
                               svg_handle,
                               NULL);
    goo_canvas_item_scale(item, imageZoom, imageZoom);

    g_object_unref(svg_handle);

    g_object_set_data (G_OBJECT (item),
                       "cloud_number", GINT_TO_POINTER (i));

    item = goo_canvas_text_new (itemgroup,
                                number,
                                dimension.width*imageZoom/2,
                                dimension.height*imageZoom/2,
                                -1,
                                GTK_ANCHOR_CENTER,
                                "font", gc_skin_font_board_big,
                                "fill-color", "red",
                                NULL);

    g_object_set_data (G_OBJECT (item),
                       "cloud_number", GINT_TO_POINTER (i));

    goo_canvas_item_animate(itemgroup,
                            -dimension.width*imageZoom,
                            y,
                            1.0,
                            0,
                            TRUE,
                            40*BOARDWIDTH,
                            40,
                            GOO_CANVAS_ANIMATE_FREEZE);

    /* The plane is always on top */
    goo_canvas_item_raise(itemgroup, NULL);
    goo_canvas_item_raise(planeitem, NULL);

    g_free (number);

    return (itemgroup);
}
Esempio n. 6
0
/* =====================================================================
 *
 * =====================================================================*/
static GooCanvasItem *submarine_create_item(GooCanvasItem *parent) {
  GdkPixbuf *pixmap = NULL;
  GooCanvasItem *item = NULL;
  char s12[12];
  int i;

  GooCanvasItem *rootItem = goo_canvas_group_new (parent, NULL);

  pixmap = gc_pixmap_load("submarine/submarine.png");
  submarine_width = gdk_pixbuf_get_width(pixmap);
  submarine_height = gdk_pixbuf_get_height(pixmap);
  submarine_item = goo_canvas_image_new (rootItem,
					 pixmap,
					 0,
					 0,
					 NULL);

#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif


  pixmap = gc_pixmap_load("submarine/vanne.svg");
  ballast_ar_purge_item = goo_canvas_image_new (rootItem,
						pixmap,
						PURGE_AR + schema_x,
						schema_y -1.0,
						 NULL);
  g_signal_connect(ballast_ar_purge_item, "button-press-event",
		   (GCallback) ballast_ar_purge_event, NULL);

  ballast_av_purge_item = goo_canvas_image_new (rootItem,
						pixmap,
						PURGE_AV + schema_x,
						schema_y -1.0,
						NULL);
  g_signal_connect(ballast_av_purge_item, "button-press-event",
		   (GCallback) ballast_av_purge_event, NULL);

  regleur_purge_item = goo_canvas_image_new (rootItem,
					     pixmap,
					     REGLEUR + schema_x,
					     schema_y -2.0,
					     NULL);
  g_signal_connect(regleur_purge_item, "button-press-event",
		   (GCallback) regleur_purge_event, NULL);

  item = goo_canvas_image_new (rootItem,
			       pixmap,
			       schema_x + CHASSE_BALLAST_AV_X,
			       schema_y +  CHASSE_BALLAST_AV_Y,
			       NULL);
  g_signal_connect(item, "button-press-event",
		   (GCallback) ballast_av_chasse_event, NULL);

  item = goo_canvas_image_new (rootItem,
			       pixmap,
			       schema_x + CHASSE_BALLAST_AR_X,
			       schema_y +  CHASSE_BALLAST_AR_Y,
			       NULL);
  g_signal_connect(item, "button-press-event",
		   (GCallback) ballast_ar_chasse_event, NULL);

  regleur_chasse_item = goo_canvas_image_new (rootItem,
					      pixmap,
					      schema_x + CHASSE_REGLEUR_X,
					      schema_y + CHASSE_REGLEUR_Y,
					      NULL);
  g_signal_connect(regleur_chasse_item, "button-press-event",
		   (GCallback) regleur_chasse_event, NULL);

#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif

  // DEPTH RUDDERS
  pixmap = gc_pixmap_load("submarine/rudder.png");
  barre_av_item = goo_canvas_image_new (rootItem,
					pixmap,
					schema_x + BARRE_AV_X,
					schema_y + BARRE_AV_Y,
					 NULL);
  barre_ar_item = goo_canvas_image_new (rootItem,
					pixmap,
					schema_x + BARRE_AR_X,
					schema_y + BARRE_AR_Y,
					 NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif

  // displays the speed on the engine
  sprintf(s12,"%d",(int)submarine_horizontal_speed);
  speed_item_back = goo_canvas_text_new (rootItem,
					 s12,
					 (gdouble) schema_x + ENGINE_UP_X - ENGINE_DOWN_X +1,
					 (gdouble) schema_y + ENGINE_UP_Y + 10 + 1,
					 -1,
					 GTK_ANCHOR_CENTER,
					 "font", gc_skin_font_board_title_bold,
					 "alignment", PANGO_ALIGN_CENTER,
					 "fill-color", TEXT_COLOR_BACK,
					 NULL);
  speed_item_front = goo_canvas_text_new (rootItem,
					  s12,
					  (gdouble) schema_x + ENGINE_UP_X - ENGINE_DOWN_X,
					  (gdouble) schema_y + ENGINE_UP_Y + 10,
					  -1,
					  GTK_ANCHOR_CENTER,
					  "font", gc_skin_font_board_title_bold,
					  "alignment", PANGO_ALIGN_CENTER,
					  "fill-color", TEXT_COLOR_FRONT,
					  NULL);

  // displays the ballast_av_air value
  ballast_av_air_item_rect = goo_canvas_rect_new (rootItem,
						  schema_x + BALLAST_AV_AIR_X1,
						  schema_y + BALLAST_AV_AIR_Y1
						  + BALLAST_AV_AIR_H,
						  BALLAST_AV_AIR_W,
						  BALLAST_AV_AIR_H,
						  "fill-color", "blue",
						  "line-width", 0.0,
						  NULL);

  sprintf(s12,"%d",(int)ballast_av_air);
  ballast_av_air_item_back = goo_canvas_text_new (rootItem,
						  s12,
						  (gdouble) schema_x + BALLAST_AV_AIR_TEXT_X + 1,
						  (gdouble) schema_y + BALLAST_AV_AIR_TEXT_Y + 1,
						  -1,
						  GTK_ANCHOR_CENTER,
						  "font", gc_skin_font_board_title_bold,
						  "fill-color", TEXT_COLOR_BACK,
						  NULL);
  ballast_av_air_item_front = goo_canvas_text_new (rootItem,
						   s12,
						   (gdouble) schema_x + BALLAST_AV_AIR_TEXT_X,
						   (gdouble) schema_y + BALLAST_AV_AIR_TEXT_Y,
						   -1,
						   GTK_ANCHOR_CENTER,
						   "font", gc_skin_font_board_title_bold,
						   "fill-color", TEXT_COLOR_FRONT,
						   NULL);
  setBallastAV(ballast_av_air);

  // displays the ballast_ar_air value
  ballast_ar_air_item_rect = goo_canvas_rect_new (rootItem,
						  schema_x + BALLAST_AR_AIR_X1,
						  schema_y + BALLAST_AR_AIR_Y1
						  + BALLAST_AR_AIR_H,
						  BALLAST_AR_AIR_W,
						  BALLAST_AR_AIR_H,
						  "fill-color", "blue",
						  "line-width", 0.0,
						  NULL);

  sprintf(s12,"%d",(int)ballast_ar_air);
  ballast_ar_air_item_back = goo_canvas_text_new (rootItem,
						  s12,
						  (gdouble) schema_x + BALLAST_AR_AIR_TEXT_X + 1,
						  (gdouble) schema_y + BALLAST_AR_AIR_TEXT_Y + 1,
						  -1,
						  GTK_ANCHOR_CENTER,
						  "font", gc_skin_font_board_title_bold,
						  "fill-color", TEXT_COLOR_BACK,
						  NULL);
  ballast_ar_air_item_front = goo_canvas_text_new (rootItem,
						   s12,
						   (gdouble) schema_x + BALLAST_AR_AIR_TEXT_X,
						   (gdouble) schema_y + BALLAST_AR_AIR_TEXT_Y,
						   -1,
						   GTK_ANCHOR_CENTER,
						   "font", gc_skin_font_board_title_bold,
						   "fill-color", TEXT_COLOR_FRONT,
						   NULL);
  setBallastAR(ballast_ar_air);

  // displays the remaining air value
  sprintf(s12,"%d", (int)air);
  air_item_back = goo_canvas_text_new (rootItem,
				       s12,
				       (gdouble) schema_x + AIR_X +1,
				       (gdouble) schema_y + AIR_Y + 1,
				       -1,
				       GTK_ANCHOR_CENTER,
				       "font", gc_skin_font_board_title_bold,
				       "fill-color", TEXT_COLOR_BACK,
				       NULL);
  air_item_front = goo_canvas_text_new (rootItem,
					s12,
					(gdouble) schema_x + AIR_X,
					(gdouble) schema_y + AIR_Y,
					-1,
					GTK_ANCHOR_CENTER,
					"font", gc_skin_font_board_title_bold,
					"fill-color", TEXT_COLOR_FRONT,
					NULL);

  // displays the remaining battery value
  sprintf(s12,"%d", (int)battery);
  battery_item_back = goo_canvas_text_new (rootItem,
					   s12,
					   (gdouble) schema_x + BATTERY_X +1,
					   (gdouble) schema_y + BATTERY_Y + 1,
					   -1,
					   GTK_ANCHOR_CENTER,
					   "font", gc_skin_font_board_title_bold,
					   "alignment", PANGO_ALIGN_CENTER,
					   "fill-color", TEXT_COLOR_BACK,
					   NULL);
  battery_item_front = goo_canvas_text_new (rootItem,
					    s12,
					    (gdouble) schema_x + BATTERY_X,
					    (gdouble) schema_y + BATTERY_Y,
					    -1,
					    GTK_ANCHOR_CENTER,
					    "font", gc_skin_font_board_title_bold,
					    "alignment", PANGO_ALIGN_CENTER,
					    "fill-color", TEXT_COLOR_FRONT,
					    NULL);

  // displays the remaining regleur value
  regleur_item_rect = goo_canvas_rect_new (rootItem,
					   schema_x + REGLEUR_X1,
					   schema_y + REGLEUR_Y1 + REGLEUR_H,
					   REGLEUR_W,
					   REGLEUR_H,
					   "fill-color", "blue",
					   "line-width", 0.0,
					   NULL);

  sprintf(s12,"%d", (int)regleur);
  regleur_item_back = goo_canvas_text_new (rootItem,
					   s12,
					   (gdouble) schema_x + REGLEUR_TEXT_X +1,
					   (gdouble) schema_y + REGLEUR_TEXT_Y + 1,
					   -1,
					   GTK_ANCHOR_CENTER,
					   "font", gc_skin_font_board_title_bold,
					   "fill-color", TEXT_COLOR_BACK,
					   NULL);
  regleur_item_front = goo_canvas_text_new (rootItem,
					    s12,
					    (gdouble) schema_x + REGLEUR_TEXT_X,
					    (gdouble) schema_y + REGLEUR_TEXT_Y,
					    -1,
					    GTK_ANCHOR_CENTER,
					    "font", gc_skin_font_board_title_bold,
					    "fill-color", TEXT_COLOR_FRONT,
					    NULL);
  setRegleur(regleur);

  // displays an alert when some parameters are bad
  pixmap = gc_pixmap_load("submarine/alert_submarine.png");
  alert_submarine = goo_canvas_image_new (rootItem,
					  pixmap,
					  ALERT_SUBMARINE_X,
					  ALERT_SUBMARINE_Y,
					  NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif
  g_object_set (alert_submarine,
		"visibility", GOO_CANVAS_ITEM_INVISIBLE,
		NULL);

  // when the submarine makes some bubbles ...
  pixmap = gc_pixmap_load("submarine/bubbling.png");

  for (i=0; i<3; i++) {
    bubbling[i] = goo_canvas_image_new (rootItem,
					pixmap,
					0,
					0,
					NULL);
    g_object_set (bubbling[i],
		  "visibility", GOO_CANVAS_ITEM_INVISIBLE,
		  NULL);
  }
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif

  // whale item
  switch(gcomprisBoard->level)
    {
    case 1:
      whale_x = 50;
      whale_y = MAX_DEPTH - 100;
      break;
    case 2:
      whale_x = 150;
      whale_y = MAX_DEPTH - 100;
      break;
    case 3:
      whale_x = 250;
      whale_y = MAX_DEPTH - 100;
      break;
    default:
      whale_x = 380;
      whale_y = MAX_DEPTH - 100;
      break;
    }

  pixmap = gc_pixmap_load("submarine/whale.png");
  whale = goo_canvas_image_new (rootItem,
				pixmap,
				whale_x,
				whale_y,
				NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif

  //  whale being hit
  pixmap = gc_pixmap_load("submarine/whale_hit.png");
  big_explosion = goo_canvas_image_new (rootItem,
					pixmap,
					whale_x,
					whale_y,
					NULL);
  g_object_set (big_explosion,
		"visibility", GOO_CANVAS_ITEM_INVISIBLE,
		NULL);

#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif

  // treasure item
  pixmap = gc_pixmap_load("submarine/crown.png");
  treasure_x = (BOARDWIDTH*3)/4;
  treasure_y = MAX_DEPTH;
  treasure = goo_canvas_image_new (rootItem,
				   pixmap,
				   0,
				   0,
				   NULL);
  goo_canvas_item_translate(treasure, treasure_x, 0);
  goo_canvas_item_animate(treasure,
			  treasure_x,
			  treasure_y,
			  0.6,
			  0,
			  TRUE,
			  6*1000,
			  40,
			  GOO_CANVAS_ANIMATE_FREEZE);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif

  // the triggers for air compressor and battery charger
  pixmap = gc_pixmap_load("submarine/manette.png");
  air_compressor_item = goo_canvas_image_new (rootItem,
					      pixmap,
					      schema_x + AIR_TRIGGER_X,
					      schema_y + AIR_TRIGGER_Y,
					      NULL);
  battery_charger_item = goo_canvas_image_new (rootItem,
					       pixmap,
					       schema_x + BATTERY_TRIGGER_X,
					       schema_y + BATTERY_TRIGGER_Y,
					       NULL);
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
  gdk_pixbuf_unref(pixmap);
#else
  g_object_unref(pixmap);
#endif

  g_signal_connect(air_compressor_item, "button-press-event",
		   (GCallback) air_compressor_event, NULL);
  g_signal_connect(battery_charger_item, "button-press-event",
		   (GCallback) battery_charger_event, NULL);

  /*
   * Set the right wall
   * ------------------
   */

  switch(gcomprisBoard->level)
    {
    case 1:
      gate_top_y = 80;
      gate_bottom_y = schema_y - 100;
      break;
    case 2:
      gate_top_y = 100;
      gate_bottom_y = schema_y - 120;
      break;
    default:
      gate_top_y = 120;
      gate_bottom_y = schema_y - 120;
      break;
    }

  /* At startup, the gate is closed */
  gate_top_current_y = gate_bottom_y;
  top_gate_item = goo_canvas_rect_new (rootItem,
				       BOARDWIDTH - 25,
				       40,
				       27,
				       gate_top_current_y - 40,
				       "fill_color_rgba", 0x989677FF,
				       "stroke-color", "black",
				       "line-width", 2.0,
				       NULL);

  goo_canvas_rect_new (rootItem,
		       BOARDWIDTH - 25,
		       gate_bottom_y,
		       27,
		       schema_y - gate_bottom_y,
		       "fill_color_rgba", 0x989677FF,
		       "stroke-color", "black",
		       "line-width", 2.0,
		       NULL);


  timer_id = g_timeout_add(UPDATE_DELAY, update_timeout, NULL);
  timer_slow_id = g_timeout_add(UPDATE_DELAY_SLOW, update_timeout_slow, NULL);
  timer_very_slow_id = g_timeout_add(UPDATE_DELAY_VERY_SLOW, update_timeout_very_slow, NULL);

  return rootItem;
}
Esempio n. 7
0
/* =====================================================================
 *
 * =====================================================================*/
static GooCanvasItem *submarine_create_item(GooCanvasItem *parent) {
  GdkPixbuf *pixmap = NULL;
  char s12[12];
  int i, w, h;

  boardRootItem = \
    goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas),
			  NULL);

  pixmap = gc_pixmap_load("submarine/submarine.png");
  submarine_width = gdk_pixbuf_get_width(pixmap);
  submarine_height = gdk_pixbuf_get_height(pixmap);
  submarine_item = goo_canvas_image_new (boardRootItem,
					 pixmap,
					 0,//SUBMARINE_INITIAL_X,
					 0,//SUBMARINE_INITIAL_DEPTH + SURFACE_IN_BACKGROUND - submarine_height,
					 NULL);

  gdk_pixbuf_unref(pixmap);


  pixmap = gc_pixmap_load("submarine/sub_schema.png");

  w = gdk_pixbuf_get_width(pixmap);
  h = gdk_pixbuf_get_height(pixmap);

  schema_x = (BOARDWIDTH - w)/2 ;
  schema_y = BOARDHEIGHT - h;
  goo_canvas_image_new (boardRootItem,
			pixmap,
			schema_x,
			schema_y,
			NULL);

  gdk_pixbuf_unref(pixmap);

  pixmap = gc_pixmap_load("submarine/vanne.png");

  ballast_ar_purge_item = goo_canvas_image_new (boardRootItem,
						pixmap,
						PURGE_AR + schema_x,
						schema_y -1.0,
						 NULL);
  g_signal_connect(ballast_ar_purge_item, "button-press-event",
		   (GtkSignalFunc) ballast_ar_purge_event, NULL);

  ballast_av_purge_item = goo_canvas_image_new (boardRootItem,
						pixmap,
						PURGE_AV + schema_x,
						schema_y -1.0,
						NULL);
  g_signal_connect(ballast_av_purge_item, "button-press-event",  (GtkSignalFunc) ballast_av_purge_event, NULL);

  regleur_purge_item = goo_canvas_image_new (boardRootItem,
					     pixmap,
					     REGLEUR + schema_x,
					     schema_y -2.0,
					     NULL);
  g_signal_connect(regleur_purge_item, "button-press-event",  (GtkSignalFunc) regleur_purge_event, NULL);

  ballast_av_chasse_item = goo_canvas_image_new (boardRootItem,
						 pixmap,
						 schema_x + CHASSE_BALLAST_AV_X,
						 schema_y +  CHASSE_BALLAST_AV_Y,
						 NULL);
  g_signal_connect(ballast_av_chasse_item, "button-press-event",  (GtkSignalFunc) ballast_av_chasse_event, NULL);

  ballast_ar_chasse_item = goo_canvas_image_new (boardRootItem,
						 pixmap,
						 schema_x + CHASSE_BALLAST_AR_X,
						 schema_y +  CHASSE_BALLAST_AR_Y,
						  NULL);
  g_signal_connect(ballast_ar_chasse_item, "button-press-event",
		   (GtkSignalFunc) ballast_ar_chasse_event, NULL);

  regleur_chasse_item = goo_canvas_image_new (boardRootItem,
					      pixmap,
					      schema_x + CHASSE_REGLEUR_X,
					      schema_y + CHASSE_REGLEUR_Y,
					      NULL);
  g_signal_connect(regleur_chasse_item, "button-press-event",
		   (GtkSignalFunc) regleur_chasse_event, NULL);

  gdk_pixbuf_unref(pixmap);

  // DEPTH RUDDERS
  pixmap = gc_pixmap_load("submarine/rudder.png");
  w = gdk_pixbuf_get_width(pixmap);
  h = gdk_pixbuf_get_height(pixmap);
  barre_av_item = goo_canvas_image_new (boardRootItem,
					pixmap,
					schema_x + BARRE_AV_X,
					schema_y + BARRE_AV_Y,
					 NULL);
  barre_ar_item = goo_canvas_image_new (boardRootItem,
					pixmap,
					schema_x + BARRE_AR_X,
					schema_y + BARRE_AR_Y,
					 NULL);
  gdk_pixbuf_unref(pixmap);

#define COMMAND_OFFSET 20.0
  pixmap = gc_pixmap_load("submarine/up.png");
  int w2 = gdk_pixbuf_get_width(pixmap);
  barre_av_up_item = goo_canvas_image_new (boardRootItem,
					   pixmap,
					   schema_x + BARRE_AV_X + w - w2,
					   schema_y + BARRE_AV_Y - COMMAND_OFFSET,
					    NULL);
  barre_ar_up_item = goo_canvas_image_new (boardRootItem,
					   pixmap,
					   schema_x + BARRE_AR_X + w - w2,
					   schema_y + BARRE_AR_Y - COMMAND_OFFSET,
					   NULL);
  engine_up_item = goo_canvas_image_new (boardRootItem,
					 pixmap,
					 schema_x + ENGINE_UP_X,
					 schema_y + ENGINE_UP_Y,
					 NULL);
  gdk_pixbuf_unref(pixmap);

  pixmap = gc_pixmap_load("submarine/down.png");
  barre_av_down_item = goo_canvas_image_new (boardRootItem,
					     pixmap,
					     schema_x + BARRE_AV_X + w - w2,
					     schema_y + BARRE_AV_Y + COMMAND_OFFSET,
					     NULL);
  barre_ar_down_item = goo_canvas_image_new (boardRootItem,
					     pixmap,
					     schema_x + BARRE_AR_X + w - w2,
					     schema_y + BARRE_AR_Y + COMMAND_OFFSET,
					     NULL);
  engine_down_item = goo_canvas_image_new (boardRootItem,
					   pixmap,
					   schema_x + ENGINE_DOWN_X,
					   schema_y + ENGINE_DOWN_Y,
					   NULL);
  gdk_pixbuf_unref(pixmap);

  g_signal_connect(barre_av_up_item, "button-press-event",
		     (GtkSignalFunc) barre_av_event, GINT_TO_POINTER(UP));
  g_signal_connect(barre_ar_up_item, "button-press-event",
		     (GtkSignalFunc) barre_ar_event, GINT_TO_POINTER(UP));
  g_signal_connect(barre_av_down_item, "button-press-event",
		     (GtkSignalFunc) barre_av_event, GINT_TO_POINTER(DOWN));
  g_signal_connect(barre_ar_down_item, "button-press-event",
		     (GtkSignalFunc) barre_ar_event, GINT_TO_POINTER(DOWN));
  g_signal_connect(engine_up_item, "button-press-event",
		     (GtkSignalFunc) engine_event, GINT_TO_POINTER(UP));
  g_signal_connect(engine_down_item, "button-press-event",
		     (GtkSignalFunc) engine_event, GINT_TO_POINTER(DOWN));

  // displays the speed on the engine
  sprintf(s12,"%d",(int)submarine_horizontal_speed);
  speed_item_back = goo_canvas_text_new (boardRootItem,
					 s12,
					 (gdouble) schema_x + ENGINE_UP_X - ENGINE_DOWN_X +1,
					 (gdouble) schema_y + ENGINE_UP_Y + 10 + 1,
					 -1,
					 GTK_ANCHOR_CENTER,
					 "font", gc_skin_font_board_title_bold,
					 "alignment", PANGO_ALIGN_CENTER,
					 "fill-color", TEXT_COLOR_BACK,
					 NULL);
  speed_item_front = goo_canvas_text_new (boardRootItem,
					  s12,
					  (gdouble) schema_x + ENGINE_UP_X - ENGINE_DOWN_X,
					  (gdouble) schema_y + ENGINE_UP_Y + 10,
					  -1,
					  GTK_ANCHOR_CENTER,
					  "font", gc_skin_font_board_title_bold,
					  "alignment", PANGO_ALIGN_CENTER,
					  "fill-color", TEXT_COLOR_FRONT,
					  NULL);

  // displays the ballast_av_air value
  ballast_av_air_item_rect = goo_canvas_rect_new (boardRootItem,
						  schema_x + BALLAST_AV_AIR_X1,
						  schema_y + BALLAST_AV_AIR_Y1
						  + BALLAST_AV_AIR_H,
						  BALLAST_AV_AIR_W,
						  BALLAST_AV_AIR_H,
						  "fill-color", "blue",
						  "line-width", 0.0,
						  NULL);

  sprintf(s12,"%d",(int)ballast_av_air);
  ballast_av_air_item_back = goo_canvas_text_new (boardRootItem,
						  s12,
						  (gdouble) schema_x + BALLAST_AV_AIR_TEXT_X + 1,
						  (gdouble) schema_y + BALLAST_AV_AIR_TEXT_Y + 1,
						  -1,
						  GTK_ANCHOR_CENTER,
						  "font", gc_skin_font_board_title_bold,
						  "fill-color", TEXT_COLOR_BACK,
						  NULL);
  ballast_av_air_item_front = goo_canvas_text_new (boardRootItem,
						   s12,
						   (gdouble) schema_x + BALLAST_AV_AIR_TEXT_X,
						   (gdouble) schema_y + BALLAST_AV_AIR_TEXT_Y,
						   -1,
						   GTK_ANCHOR_CENTER,
						   "font", gc_skin_font_board_title_bold,
						   "fill-color", TEXT_COLOR_FRONT,
						   NULL);
  setBallastAV(ballast_av_air);

  // displays the ballast_ar_air value
  ballast_ar_air_item_rect = goo_canvas_rect_new (boardRootItem,
						  schema_x + BALLAST_AR_AIR_X1,
						  schema_y + BALLAST_AR_AIR_Y1
						  + BALLAST_AR_AIR_H,
						  BALLAST_AR_AIR_W,
						  BALLAST_AR_AIR_H,
						  "fill-color", "blue",
						  "line-width", 0.0,
						  NULL);

  sprintf(s12,"%d",(int)ballast_ar_air);
  ballast_ar_air_item_back = goo_canvas_text_new (boardRootItem,
						  s12,
						  (gdouble) schema_x + BALLAST_AR_AIR_TEXT_X + 1,
						  (gdouble) schema_y + BALLAST_AR_AIR_TEXT_Y + 1,
						  -1,
						  GTK_ANCHOR_CENTER,
						  "font", gc_skin_font_board_title_bold,
						  "fill-color", TEXT_COLOR_BACK,
						  NULL);
  ballast_ar_air_item_front = goo_canvas_text_new (boardRootItem,
						   s12,
						   (gdouble) schema_x + BALLAST_AR_AIR_TEXT_X,
						   (gdouble) schema_y + BALLAST_AR_AIR_TEXT_Y,
						   -1,
						   GTK_ANCHOR_CENTER,
						   "font", gc_skin_font_board_title_bold,
						   "fill-color", TEXT_COLOR_FRONT,
						   NULL);
    setBallastAR(ballast_ar_air);

  // displays the remaining air value
  sprintf(s12,"%d", (int)air);
  air_item_back = goo_canvas_text_new (boardRootItem,
				       s12,
				       (gdouble) schema_x + AIR_X +1,
				       (gdouble) schema_y + AIR_Y + 1,
				       -1,
				       GTK_ANCHOR_CENTER,
				       "font", gc_skin_font_board_title_bold,
				       "fill-color", TEXT_COLOR_BACK,
				       NULL);
  air_item_front = goo_canvas_text_new (boardRootItem,
					s12,
					(gdouble) schema_x + AIR_X,
					(gdouble) schema_y + AIR_Y,
					-1,
					GTK_ANCHOR_CENTER,
					"font", gc_skin_font_board_title_bold,
					"fill-color", TEXT_COLOR_FRONT,
					NULL);

  // displays the remaining battery value
  sprintf(s12,"%d", (int)battery);
  battery_item_back = goo_canvas_text_new (boardRootItem,
					   s12,
					   (gdouble) schema_x + BATTERY_X +1,
					   (gdouble) schema_y + BATTERY_Y + 1,
					   -1,
					   GTK_ANCHOR_CENTER,
					   "font", gc_skin_font_board_title_bold,
					   "alignment", PANGO_ALIGN_CENTER,
					   "fill-color", TEXT_COLOR_BACK,
					   NULL);
  battery_item_front = goo_canvas_text_new (boardRootItem,
					    s12,
					    (gdouble) schema_x + BATTERY_X,
					    (gdouble) schema_y + BATTERY_Y,
					    -1,
					    GTK_ANCHOR_CENTER,
					    "font", gc_skin_font_board_title_bold,
					    "alignment", PANGO_ALIGN_CENTER,
					    "fill-color", TEXT_COLOR_FRONT,
					    NULL);

  // displays the remaining regleur value
  regleur_item_rect = goo_canvas_rect_new (boardRootItem,
					   schema_x + REGLEUR_X1,
					   schema_y + REGLEUR_Y1 + REGLEUR_H,
					   REGLEUR_W,
					   REGLEUR_H,
					   "fill-color", "blue",
					   "line-width", 0.0,
					   NULL);

  sprintf(s12,"%d", (int)regleur);
  regleur_item_back = goo_canvas_text_new (boardRootItem,
					   s12,
					   (gdouble) schema_x + REGLEUR_TEXT_X +1,
					   (gdouble) schema_y + REGLEUR_TEXT_Y + 1,
					   -1,
					   GTK_ANCHOR_CENTER,
					   "font", gc_skin_font_board_title_bold,
					   "fill-color", TEXT_COLOR_BACK,
					   NULL);
  regleur_item_front = goo_canvas_text_new (boardRootItem,
					    s12,
					    (gdouble) schema_x + REGLEUR_TEXT_X,
					    (gdouble) schema_y + REGLEUR_TEXT_Y,
					    -1,
					    GTK_ANCHOR_CENTER,
					    "font", gc_skin_font_board_title_bold,
					    "fill-color", TEXT_COLOR_FRONT,
					    NULL);
  setRegleur(regleur);

  // displays an alert when some parameters are bad
  pixmap = gc_pixmap_load("submarine/alert_submarine.png");
  w = gdk_pixbuf_get_width(pixmap);
  h = gdk_pixbuf_get_height(pixmap);
  alert_submarine = goo_canvas_image_new (boardRootItem,
					  pixmap,
					  ALERT_SUBMARINE_X,
					  ALERT_SUBMARINE_Y,
					  NULL);
  gdk_pixbuf_unref(pixmap);
  g_object_set (alert_submarine,
		"visibility", GOO_CANVAS_ITEM_INVISIBLE,
		NULL);

  // when the submarine makes some bubbles ...
  pixmap = gc_pixmap_load("submarine/bubbling.png");

  for (i=0; i<3; i++) {
    bubbling[i] = goo_canvas_image_new (boardRootItem,
					pixmap,
					0,
					0,
					NULL);
    g_object_set (bubbling[i],
		  "visibility", GOO_CANVAS_ITEM_INVISIBLE,
		  NULL);
  }
  gdk_pixbuf_unref(pixmap);

  // whale item
  pixmap = gc_pixmap_load("submarine/whale.png");
  whale_x = g_random_int_range((int)(BOARDWIDTH/4),
			       (int)(BOARDWIDTH/2));
  whale_y = g_random_int_range((int)(SURFACE_IN_BACKGROUND + gdk_pixbuf_get_height(pixmap)*2),
			       (int)MAX_DEPTH);
  whale = goo_canvas_image_new (boardRootItem,
				pixmap,
				whale_x,
				whale_y,
				NULL);
  gdk_pixbuf_unref(pixmap);

  //  whale being hit
  pixmap = gc_pixmap_load("submarine/whale_hit.png");
  big_explosion = goo_canvas_image_new (boardRootItem,
					pixmap,
					whale_x,
					whale_y,
					NULL);
  g_object_set (big_explosion,
		"visibility", GOO_CANVAS_ITEM_INVISIBLE,
		NULL);

  gdk_pixbuf_unref(pixmap);

  // treasure item
  pixmap = gc_pixmap_load("submarine/crown.png");
  treasure_x = (BOARDWIDTH*3)/4;
  treasure_y = MAX_DEPTH;
  treasure = goo_canvas_image_new (boardRootItem,
				   pixmap,
				   0,
				   0,
				   NULL);
  goo_canvas_item_translate(treasure, treasure_x, 0);
  goo_canvas_item_animate(treasure,
			  treasure_x,
			  treasure_y,
			  0.6,
			  0,
			  TRUE,
			  6*1000,
			  40,
			  GOO_CANVAS_ANIMATE_FREEZE);
  gdk_pixbuf_unref(pixmap);

  // the triggers for air compressor and battery charger
  pixmap = gc_pixmap_load("submarine/manette.png");
  air_compressor_item = goo_canvas_image_new (boardRootItem,
					      pixmap,
					      schema_x + AIR_TRIGGER_X,
					      schema_y + AIR_TRIGGER_Y,
					      NULL);
  battery_charger_item = goo_canvas_image_new (boardRootItem,
					       pixmap,
					       schema_x + BATTERY_TRIGGER_X,
					       schema_y + BATTERY_TRIGGER_Y,
					       NULL);
  gdk_pixbuf_unref(pixmap);

  g_signal_connect(air_compressor_item, "button-press-event",
		   (GtkSignalFunc) air_compressor_event, NULL);
  g_signal_connect(battery_charger_item, "button-press-event",
		   (GtkSignalFunc) battery_charger_event, NULL);

  // the antisubmarine warfare frigate
  pixmap = gc_pixmap_load("submarine/asw_frigate.png");
  w = gdk_pixbuf_get_width(pixmap);
  frigate_item = goo_canvas_image_new (boardRootItem,
				       pixmap,
				       0,
				       0,
				       NULL);
  goo_canvas_item_translate(frigate_item, BOARDWIDTH, 2);
  goo_canvas_item_animate(frigate_item,
			  -w,
			  2.0,
			  1,
			  0,
			  TRUE,
			  30*1000,
			  40,
			  GOO_CANVAS_ANIMATE_RESTART);
  gdk_pixbuf_unref(pixmap);


  /*
   * Set the right wall
   * ------------------
   */

  switch(gcomprisBoard->level)
    {
    case 1:
      gate_top_y = 80;
      gate_bottom_y = schema_y - 100;
      break;
    case 2:
      gate_top_y = 100;
      gate_bottom_y = schema_y - 120;
      break;
    default:
      gate_top_y = 120;
      gate_bottom_y = schema_y - 120;
      break;
    }

  /* At startup, the gate is closed */
  gate_top_current_y = gate_bottom_y;
  top_gate_item = goo_canvas_rect_new (boardRootItem,
				       BOARDWIDTH - 25,
				       40,
				       27,
				       gate_top_current_y - 40,
				       "fill_color_rgba", 0x989677FF,
				       "stroke-color", "black",
				       "line-width", 2.0,
				       NULL);

  goo_canvas_rect_new (boardRootItem,
		       BOARDWIDTH - 25,
		       gate_bottom_y,
		       27,
		       schema_y - gate_bottom_y,
		       "fill_color_rgba", 0x989677FF,
		       "stroke-color", "black",
		       "line-width", 2.0,
		       NULL);


  timer_id = g_timeout_add(UPDATE_DELAY, update_timeout, NULL);
  timer_slow_id = g_timeout_add(UPDATE_DELAY_SLOW, update_timeout_slow, NULL);
  timer_very_slow_id = g_timeout_add(UPDATE_DELAY_VERY_SLOW, update_timeout_very_slow, NULL);

  return NULL;
}