Back to index

gcompris  8.2.2
Defines | Functions | Variables
canal_lock.c File Reference
#include "gcompris/gcompris.h"

Go to the source code of this file.

Defines

#define SOUNDLISTFILE   PACKAGE
#define ANIMATE_SPEED   30
#define CANAL_COLOR   0x0010FFFF
#define LOCK_COLOR   0x8cc679FF
#define LOCK_COLOR_H   0x71A65FFF
#define CANALLOCK_COLOR   0xd1cd0cFF
#define CANALLOCK_COLOR_H   0xf1ed1cFF
#define GROUND_COLOR   0x9b5f5aFF
#define BASE_LINE   400
#define LEFT_CANAL_HEIGHT   100
#define LEFT_CANAL_WIDTH   325
#define RIGHT_CANAL_HEIGHT   200
#define RIGHT_CANAL_WIDTH   325
#define MIDDLE_CANAL_WIDTH   (BOARDWIDTH - RIGHT_CANAL_WIDTH - LEFT_CANAL_WIDTH)
#define LOCK_WIDTH   20
#define LOCK_HEIGHT_MAX   (RIGHT_CANAL_HEIGHT + 40)
#define LOCK_HEIGHT_MIN   20
#define SUBCANAL_BASE_LINE   (BASE_LINE + 80)
#define SUBCANAL_HEIGHT   40
#define CANALLOCK_WIDTH   30
#define CANALLOCK_HEIGHT_MAX   SUBCANAL_HEIGHT
#define CANALLOCK_HEIGHT_MIN   15
#define BOAT_POS_LEFT   1
#define BOAT_POS_MIDDLE   2
#define BOAT_POS_RIGHT   3

Functions

static void start_board (GcomprisBoard *agcomprisBoard)
static void pause_board (gboolean pause)
static void end_board (void)
static gboolean is_our_board (GcomprisBoard *gcomprisBoard)
static void set_level (guint level)
static void game_won (void)
static GnomeCanvasItem * canal_lock_create_item (GnomeCanvasGroup *parent)
static void canal_lock_destroy_all_items (void)
static void canal_lock_next_level (void)
static gint item_event (GnomeCanvasItem *item, GdkEvent *event, gpointer data)
static gboolean animate_step ()
static void update_water ()
static void toggle_lock (GnomeCanvasItem *item)
static void move_boat ()
static void hightlight (GnomeCanvasItem *item, gboolean status)

Variables

static GcomprisBoard * gcomprisBoard = NULL
static gboolean board_paused = TRUE
static int gamewon
static gint timer_id
static gboolean animation
static GnomeCanvasGroup * boardRootItem = NULL
static GnomeCanvasItem * lock_left_item = NULL
static GnomeCanvasItem * lock_right_item = NULL
static GnomeCanvasItem * canallock_left_item = NULL
static GnomeCanvasItem * canallock_right_item = NULL
static GnomeCanvasItem * canal_left_item = NULL
static GnomeCanvasItem * canal_middle_item = NULL
static GnomeCanvasItem * canal_right_item = NULL
static GnomeCanvasItem * tuxboat_item = NULL
static double tuxboat_width
static guint boat_position
static gboolean right_way
static gboolean lock_left_up
static gboolean lock_right_up
static gboolean lock_water_low
static gboolean canallock_left_up
static gboolean canallock_right_up
static double timer_item_x1
static double timer_item_y1
static double timer_item_x2
static double timer_item_y2
static double timer_item_limit_y
static double timer_item_limit_x
static GnomeCanvasItem * timer_item
static gint timer_step_y1
static gint timer_step_x1
static BoardPlugin menu_bp

Define Documentation

#define ANIMATE_SPEED   30

Definition at line 24 of file canal_lock.c.

#define BASE_LINE   400

Definition at line 32 of file canal_lock.c.

#define BOAT_POS_LEFT   1

Definition at line 79 of file canal_lock.c.

#define BOAT_POS_MIDDLE   2

Definition at line 80 of file canal_lock.c.

#define BOAT_POS_RIGHT   3

Definition at line 81 of file canal_lock.c.

#define CANAL_COLOR   0x0010FFFF

Definition at line 26 of file canal_lock.c.

#define CANALLOCK_COLOR   0xd1cd0cFF

Definition at line 29 of file canal_lock.c.

#define CANALLOCK_COLOR_H   0xf1ed1cFF

Definition at line 30 of file canal_lock.c.

Definition at line 47 of file canal_lock.c.

#define CANALLOCK_HEIGHT_MIN   15

Definition at line 48 of file canal_lock.c.

#define CANALLOCK_WIDTH   30

Definition at line 46 of file canal_lock.c.

#define GROUND_COLOR   0x9b5f5aFF

Definition at line 31 of file canal_lock.c.

#define LEFT_CANAL_HEIGHT   100

Definition at line 33 of file canal_lock.c.

#define LEFT_CANAL_WIDTH   325

Definition at line 34 of file canal_lock.c.

#define LOCK_COLOR   0x8cc679FF

Definition at line 27 of file canal_lock.c.

#define LOCK_COLOR_H   0x71A65FFF

Definition at line 28 of file canal_lock.c.

#define LOCK_HEIGHT_MAX   (RIGHT_CANAL_HEIGHT + 40)

Definition at line 40 of file canal_lock.c.

#define LOCK_HEIGHT_MIN   20

Definition at line 41 of file canal_lock.c.

#define LOCK_WIDTH   20

Definition at line 39 of file canal_lock.c.

Definition at line 37 of file canal_lock.c.

#define RIGHT_CANAL_HEIGHT   200

Definition at line 35 of file canal_lock.c.

#define RIGHT_CANAL_WIDTH   325

Definition at line 36 of file canal_lock.c.

#define SOUNDLISTFILE   PACKAGE

Definition at line 22 of file canal_lock.c.

#define SUBCANAL_BASE_LINE   (BASE_LINE + 80)

Definition at line 43 of file canal_lock.c.

#define SUBCANAL_HEIGHT   40

Definition at line 44 of file canal_lock.c.


Function Documentation

static gboolean animate_step ( void  ) [static]

Definition at line 607 of file canal_lock.c.

{

  if(!gcomprisBoard)
    return FALSE;

  timer_item_x1 += timer_step_x1;
  timer_item_y1 += timer_step_y1;

  if(GNOME_IS_CANVAS_PIXBUF(timer_item))
    gnome_canvas_item_set(timer_item,
                       "x", timer_item_x1,
                       "y", timer_item_y1,
                       NULL);
  else if(GNOME_IS_CANVAS_RECT(timer_item))
    gnome_canvas_item_set(timer_item,
                       "x1", timer_item_x1,
                       "y1", timer_item_y1,
                       NULL);

  /* Special case for raising/lowering the boat */
  if(boat_position==BOAT_POS_MIDDLE && timer_item==canal_middle_item)
    {
      double item_x1, item_y1, item_x2, item_y2;

      gnome_canvas_item_get_bounds(tuxboat_item, &item_x1, &item_y1,
                               &item_x2, &item_y2);

      gnome_canvas_item_set(tuxboat_item,
                         "y", item_y1 + timer_step_y1,
                         NULL);
    }

  if((timer_item_y1 >= timer_item_limit_y && timer_step_y1 > 0) ||
     (timer_item_y1 <= timer_item_limit_y && timer_step_y1 < 0))
    {
      gtk_timeout_remove (timer_id);
      timer_id = 0;
      animation = FALSE;
      update_water();
    }
  else if((timer_item_x1 >= timer_item_limit_x && timer_step_x1 > 0) ||
     (timer_item_x1 <= timer_item_limit_x && timer_step_x1 < 0))
    {
      gtk_timeout_remove (timer_id);
      timer_id = 0;
      animation = FALSE;
      update_water();
    }

  gnome_canvas_update_now(gcomprisBoard->canvas);

  return TRUE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static GnomeCanvasItem * canal_lock_create_item ( GnomeCanvasGroup *  parent) [static]

Definition at line 258 of file canal_lock.c.

{
  GdkPixbuf *pixmap = NULL;

  boardRootItem = GNOME_CANVAS_GROUP(
                                 gnome_canvas_item_new (gnome_canvas_root(gcomprisBoard->canvas),
                                                     gnome_canvas_group_get_type (),
                                                     "x", (double) 0,
                                                     "y", (double) 0,

                                                     NULL));

  /* The boat */
  pixmap = gc_pixmap_load("gcompris/misc/tuxboat.png");

  tuxboat_item = gnome_canvas_item_new (boardRootItem,
                                   gnome_canvas_pixbuf_get_type (),
                                   "pixbuf",  pixmap,
                                   "x", (double) (LEFT_CANAL_WIDTH - gdk_pixbuf_get_width(pixmap)) / 2,
                                   "y", (double) BASE_LINE - LEFT_CANAL_HEIGHT - gdk_pixbuf_get_height(pixmap)*0.9,
                                   NULL);
  gtk_signal_connect(GTK_OBJECT(tuxboat_item), "event",
                   (GtkSignalFunc) item_event,
                   NULL);
  gtk_signal_connect(GTK_OBJECT(tuxboat_item), "event",
                   (GtkSignalFunc) gc_item_focus_event,
                   NULL);
  tuxboat_width = gdk_pixbuf_get_width(pixmap);
  gdk_pixbuf_unref(pixmap);

  /* This is the ground canal */
  gnome_canvas_item_new (boardRootItem,
                      gnome_canvas_rect_get_type (),
                      "x1", (double) 0,
                      "y1", (double) BASE_LINE,
                      "x2", (double) BOARDWIDTH,
                      "y2", (double) BOARDHEIGHT,
                      "fill_color_rgba", GROUND_COLOR,
                      "width_units", (double) 0,
                      NULL);

  /* This is the left canal */
  canal_left_item = gnome_canvas_item_new (boardRootItem,
                                       gnome_canvas_rect_get_type (),
                                       "x1", (double) 0,
                                       "y1", (double) BASE_LINE - LEFT_CANAL_HEIGHT,
                                       "x2", (double) LEFT_CANAL_WIDTH,
                                       "y2", (double) BASE_LINE,
                                       "fill_color_rgba", CANAL_COLOR,
                                       "width_units", (double) 0,
                                       NULL);

  /* This is the middle canal */
  canal_middle_item = gnome_canvas_item_new (boardRootItem,
                                        gnome_canvas_rect_get_type (),
                                        "x1", (double) LEFT_CANAL_WIDTH,
                                        "y1", (double) BASE_LINE - LEFT_CANAL_HEIGHT,
                                        "x2", (double) LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH,
                                        "y2", (double) BASE_LINE,
                                        "fill_color_rgba", CANAL_COLOR,
                                        "width_units", (double) 0,
                                        NULL);

  /* This is the right canal */
  canal_right_item = gnome_canvas_item_new (boardRootItem,
                                       gnome_canvas_rect_get_type (),
                                       "x1", (double) LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH,
                                       "y1", (double) BASE_LINE - RIGHT_CANAL_HEIGHT,
                                       "x2", (double) LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH + RIGHT_CANAL_WIDTH,
                                       "y2", (double) BASE_LINE,
                                       "fill_color_rgba", CANAL_COLOR,
                                       "width_units", (double) 0,
                                       NULL);

  /* This is the left lock */
  lock_left_item = gnome_canvas_item_new (boardRootItem,
                                     gnome_canvas_rect_get_type (),
                                     "x1", (double) LEFT_CANAL_WIDTH - LOCK_WIDTH / 2,
                                     "y1", (double) BASE_LINE - LOCK_HEIGHT_MAX,
                                     "x2", (double) LEFT_CANAL_WIDTH + LOCK_WIDTH / 2,
                                     "y2", (double) BASE_LINE,
                                     "fill_color_rgba", LOCK_COLOR,
                                     "width_units", (double) 0,
                                     NULL);
  gtk_signal_connect(GTK_OBJECT(lock_left_item), "event",
                   (GtkSignalFunc) item_event,
                   NULL);

  /* This is the right lock */
  lock_right_item = gnome_canvas_item_new (boardRootItem,
                                      gnome_canvas_rect_get_type (),
                                      "x1", (double) LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH - LOCK_WIDTH / 2,
                                      "y1", (double) BASE_LINE - LOCK_HEIGHT_MAX,
                                      "x2", (double) LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH + LOCK_WIDTH / 2,
                                      "y2", (double) BASE_LINE,
                                      "fill_color_rgba", LOCK_COLOR,
                                      "width_units", (double) 0,
                                      NULL);
  gtk_signal_connect(GTK_OBJECT(lock_right_item), "event",
                   (GtkSignalFunc) item_event,
                   NULL);

  /* This is the water conduit under the canal */
  gnome_canvas_item_new (boardRootItem,
                      gnome_canvas_rect_get_type (),
                      "x1", (double) LEFT_CANAL_WIDTH/2,
                      "y1", (double) SUBCANAL_BASE_LINE - SUBCANAL_HEIGHT,
                      "x2", (double) LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH + RIGHT_CANAL_WIDTH / 2 + SUBCANAL_HEIGHT,
                      "y2", (double) SUBCANAL_BASE_LINE,
                      "fill_color_rgba", CANAL_COLOR,
                      "width_units", (double) 0,
                      NULL);

  /* Left conduit */
  gnome_canvas_item_new (boardRootItem,
                      gnome_canvas_rect_get_type (),
                      "x1", (double) LEFT_CANAL_WIDTH/2,
                      "y1", (double) BASE_LINE,
                      "x2", (double) LEFT_CANAL_WIDTH/2 + SUBCANAL_HEIGHT,
                      "y2", (double) SUBCANAL_BASE_LINE,
                      "fill_color_rgba", CANAL_COLOR,
                      "width_units", (double) 0,
                      NULL);

  /* Middle conduit */
  gnome_canvas_item_new (boardRootItem,
                      gnome_canvas_rect_get_type (),
                      "x1", (double) LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH/2 - SUBCANAL_HEIGHT/2,
                      "y1", (double) BASE_LINE,
                      "x2", (double) LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH/2 + SUBCANAL_HEIGHT/2,
                      "y2", (double) SUBCANAL_BASE_LINE,
                      "fill_color_rgba", CANAL_COLOR,
                      "width_units", (double) 0,
                      NULL);

  /* Right conduit */
  gnome_canvas_item_new (boardRootItem,
                      gnome_canvas_rect_get_type (),
                      "x1", (double) LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH + RIGHT_CANAL_WIDTH/2,
                      "y1", (double) BASE_LINE,
                      "x2", (double) LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH + RIGHT_CANAL_WIDTH/2 + SUBCANAL_HEIGHT,
                      "y2", (double) SUBCANAL_BASE_LINE,
                      "fill_color_rgba", CANAL_COLOR,
                      "width_units", (double) 0,
                      NULL);

  /* And to finish, the 2 canal locks */
  canallock_left_item =
    gnome_canvas_item_new (boardRootItem,
                        gnome_canvas_rect_get_type (),
                        "x1", (double) LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH * 0.1,
                        "y1", (double) SUBCANAL_BASE_LINE - SUBCANAL_HEIGHT,
                        "x2", (double) LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH * 0.1 + LOCK_WIDTH / 2,
                        "y2", (double) SUBCANAL_BASE_LINE,
                        "fill_color_rgba", CANALLOCK_COLOR,
                        "width_units", (double) 0,
                        NULL);
  gtk_signal_connect(GTK_OBJECT(canallock_left_item), "event",
                   (GtkSignalFunc) item_event,
                   NULL);

  canallock_right_item =
    gnome_canvas_item_new (boardRootItem,
                        gnome_canvas_rect_get_type (),
                        "x1", (double) LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH * 0.9,
                        "y1", (double) SUBCANAL_BASE_LINE - SUBCANAL_HEIGHT,
                        "x2", (double) LEFT_CANAL_WIDTH + MIDDLE_CANAL_WIDTH * 0.9 + LOCK_WIDTH / 2,
                        "y2", (double) SUBCANAL_BASE_LINE,
                        "fill_color_rgba", CANALLOCK_COLOR,
                        "width_units", (double) 0,
                        NULL);
    gtk_signal_connect(GTK_OBJECT(canallock_right_item), "event",
                   (GtkSignalFunc) item_event,
                   NULL);



  return NULL;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void canal_lock_destroy_all_items ( void  ) [static]

Definition at line 250 of file canal_lock.c.

{
  if(boardRootItem!=NULL)
    gtk_object_destroy (GTK_OBJECT(boardRootItem));

  boardRootItem = NULL;
}

Here is the caller graph for this function:

static void canal_lock_next_level ( void  ) [static]

Definition at line 225 of file canal_lock.c.

{

  gc_set_background(gnome_canvas_root(gcomprisBoard->canvas),
                       "canal_lock/canal_lock_bg.png");

  gc_bar_set_level(gcomprisBoard);

  canal_lock_destroy_all_items();
  gamewon = FALSE;

  /* Original state of the lock */
  boat_position = BOAT_POS_LEFT;
  right_way = TRUE;
  lock_left_up = TRUE;
  lock_right_up = TRUE;
  lock_water_low = TRUE;
  canallock_left_up = TRUE;
  canallock_right_up = TRUE;

  /* Try the next level */
  canal_lock_create_item(gnome_canvas_root(gcomprisBoard->canvas));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void end_board ( void  ) [static]

Definition at line 178 of file canal_lock.c.

{
  // If we don't stop animation, there may be a segfault if leaving while the animation is running
  if (timer_id) {
    gtk_timeout_remove (timer_id);
    timer_id = 0;
  }
  animation = FALSE;

  if(gcomprisBoard!=NULL)
    {
      pause_board(TRUE);
      canal_lock_destroy_all_items();
    }
  gcomprisBoard = NULL;
}

Here is the call graph for this function:

static void game_won ( void  ) [static]

Definition at line 438 of file canal_lock.c.

{
  gcomprisBoard->sublevel++;

  if(gcomprisBoard->sublevel>gcomprisBoard->number_of_sublevel) {
    /* Try the next level */
    gcomprisBoard->sublevel=1;
    gcomprisBoard->level++;
    if(gcomprisBoard->level>gcomprisBoard->maxlevel) { // the current board is finished : bail out
      gc_bonus_end_display(BOARD_FINISHED_RANDOM);
      return;
    }
    gc_sound_play_ogg ("sounds/bonus.ogg", NULL);
  }
  canal_lock_next_level();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void hightlight ( GnomeCanvasItem *  item,
gboolean  status 
) [static]

Definition at line 664 of file canal_lock.c.

{
  guint color = 0;

  /* This is an image, not a rectangle */
  if(item == tuxboat_item)
    return;

  if(item == lock_left_item ||
     item == lock_right_item)
    {
      color   = (status ? LOCK_COLOR_H : LOCK_COLOR);
    }
  else if (item == canallock_left_item ||
          item == canallock_right_item)
    {
      color   = (status ? CANALLOCK_COLOR_H : CANALLOCK_COLOR);
    }


    gnome_canvas_item_set(item,
                       "fill_color_rgba", color,
                       NULL);

}

Here is the call graph for this function:

Here is the caller graph for this function:

static gboolean is_our_board ( GcomprisBoard *  gcomprisBoard) [static]

Definition at line 207 of file canal_lock.c.

{
  if (gcomprisBoard)
    {
      if(g_strcasecmp(gcomprisBoard->type, "canal_lock")==0)
       {
         /* Set the plugin entry */
         gcomprisBoard->plugin=&menu_bp;

         return TRUE;
       }
    }
  return FALSE;
}
static gint item_event ( GnomeCanvasItem *  item,
GdkEvent *  event,
gpointer  data 
) [static]

Definition at line 692 of file canal_lock.c.

{
  double item_x, item_y;
  item_x = event->button.x;
  item_y = event->button.y;
  gnome_canvas_item_w2i(item->parent, &item_x, &item_y);

  if(board_paused)
    return FALSE;

  switch (event->type)
    {
    case GDK_ENTER_NOTIFY:
      hightlight(item, TRUE);
      break;
    case GDK_LEAVE_NOTIFY:
      hightlight(item, FALSE);
      break;
    case GDK_BUTTON_PRESS:

      /* If there is already an animation do nothing */
      if(animation)
       return FALSE;

      if(item == lock_left_item)
       {
         if(lock_water_low && canallock_right_up)
             toggle_lock(item);
         else
           gc_sound_play_ogg ("sounds/crash.ogg", NULL);

       }
      else if(item == lock_right_item)
       {
         if(!lock_water_low && canallock_left_up)
             toggle_lock(item);
         else
           gc_sound_play_ogg ("sounds/crash.ogg", NULL);
       }
      else if(item == canallock_left_item && canallock_right_up)
       {
         if(lock_right_up)
             toggle_lock(item);
         else
           gc_sound_play_ogg ("sounds/crash.ogg", NULL);
       }
      else if(item == canallock_right_item && canallock_left_up)
       {
         if(lock_left_up)
             toggle_lock(item);
         else
           gc_sound_play_ogg ("sounds/crash.ogg", NULL);
       }
      else if(item == tuxboat_item)
       {
         move_boat();
       }
      else
       {
         gc_sound_play_ogg ("sounds/crash.ogg", NULL);
       }
      break;
    default:
      break;
    }
  return FALSE;


  /*
    gamewon = TRUE;
    canal_lock_destroy_all_items();
    gc_bonus_display(gamewon, BONUS_SMILEY);
  */
  return FALSE;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void move_boat ( ) [static]

Definition at line 457 of file canal_lock.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static void pause_board ( gboolean  pause) [static]

Definition at line 141 of file canal_lock.c.

{
  if(gcomprisBoard==NULL)
    return;

  if(gamewon == TRUE && pause == FALSE) /* the game is won */
    {
      game_won();
    }

  board_paused = pause;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void set_level ( guint  level) [static]

Definition at line 196 of file canal_lock.c.

{

  if(gcomprisBoard!=NULL)
    {
      gcomprisBoard->level=level;
      gcomprisBoard->sublevel=1;
      canal_lock_next_level();
    }
}

Here is the call graph for this function:

static void start_board ( GcomprisBoard *  agcomprisBoard) [static]

Definition at line 156 of file canal_lock.c.

{

  if(agcomprisBoard!=NULL)
    {
      gcomprisBoard=agcomprisBoard;
      gcomprisBoard->level=1;
      gcomprisBoard->maxlevel=2;
      gcomprisBoard->sublevel=1;
      gcomprisBoard->number_of_sublevel=1; /* Go to next level after this number of 'play' */

      canal_lock_next_level();

      gc_bar_set(0);

      animation = FALSE;

      gamewon = FALSE;
      pause_board(FALSE);
    }
}

Here is the call graph for this function:

static void toggle_lock ( GnomeCanvasItem *  item) [static]

Definition at line 547 of file canal_lock.c.

{
  gboolean status = TRUE;
  double y1 = 0;
  gint min = 0;
  guint animate_speed = 0;

  /* If there is already an animation do nothing else set animation to avoid deadlock */
  if(animation)
    return;
  animation = TRUE;

  gnome_canvas_item_get_bounds(item, &timer_item_x1, &timer_item_y1,
                            &timer_item_x2, &timer_item_y2);

  if(item == lock_left_item)
    {
      status = lock_left_up;
      lock_left_up = !lock_left_up;
      y1 = BASE_LINE - LOCK_HEIGHT_MAX;
      min = LOCK_HEIGHT_MIN;
      animate_speed = ANIMATE_SPEED;
    }
  else if(item == lock_right_item)
    {
      status = lock_right_up;
      lock_right_up = !lock_right_up;
      y1 = BASE_LINE - LOCK_HEIGHT_MAX;
      min = LOCK_HEIGHT_MIN;
      animate_speed = ANIMATE_SPEED;
    }
  else if(item == canallock_left_item)
    {
      status = canallock_left_up;
      canallock_left_up = !canallock_left_up;
      y1 = SUBCANAL_BASE_LINE - SUBCANAL_HEIGHT;
      min = CANALLOCK_HEIGHT_MIN;
      animate_speed = ANIMATE_SPEED;
    }
  else if(item == canallock_right_item)
    {
      status = canallock_right_up;
      canallock_right_up = !canallock_right_up;
      y1 = SUBCANAL_BASE_LINE - SUBCANAL_HEIGHT;
      min = CANALLOCK_HEIGHT_MIN;
      animate_speed = ANIMATE_SPEED;
    }

  timer_item = item;
  timer_item_limit_y = (status ? timer_item_y2 - min :
                     y1);
  timer_step_y1 = (status ? 2 : -2);
  timer_step_x1 = 0;

  timer_id = gtk_timeout_add (animate_speed, (GtkFunction) animate_step, NULL);

}

Here is the call graph for this function:

Here is the caller graph for this function:

static void update_water ( ) [static]

Definition at line 508 of file canal_lock.c.

{
  gboolean status = TRUE;
  double y1 = 0;
  gint min = LEFT_CANAL_HEIGHT;

  /* If there is already an animation do nothing else set animation to avoid deadlock */
  if(animation)
    return;
  animation = TRUE;

  if((!canallock_left_up && !lock_water_low) ||
     (!canallock_right_up && lock_water_low))
    {
      status = !lock_water_low;
      lock_water_low = !lock_water_low;
      y1 = BASE_LINE - RIGHT_CANAL_HEIGHT;
    }
  else
    {
      /* The water level is correct */
      animation = FALSE;
      return;
    }

  gnome_canvas_item_get_bounds(canal_middle_item, &timer_item_x1, &timer_item_y1,
                            &timer_item_x2, &timer_item_y2);

  timer_item = canal_middle_item;
  timer_item_limit_y = (status ? timer_item_y2 - min :
                     y1);
  timer_step_y1 = (status ? 2 : -2);
  timer_step_x1 = 0;

  timer_id = gtk_timeout_add (ANIMATE_SPEED, (GtkFunction) animate_step, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

gboolean animation [static]

Definition at line 62 of file canal_lock.c.

gboolean board_paused = TRUE [static]

Definition at line 51 of file canal_lock.c.

GnomeCanvasGroup* boardRootItem = NULL [static]

Definition at line 64 of file canal_lock.c.

guint boat_position [static]

Definition at line 83 of file canal_lock.c.

GnomeCanvasItem* canal_left_item = NULL [static]

Definition at line 72 of file canal_lock.c.

GnomeCanvasItem* canal_middle_item = NULL [static]

Definition at line 73 of file canal_lock.c.

GnomeCanvasItem* canal_right_item = NULL [static]

Definition at line 74 of file canal_lock.c.

GnomeCanvasItem* canallock_left_item = NULL [static]

Definition at line 69 of file canal_lock.c.

gboolean canallock_left_up [static]

Definition at line 88 of file canal_lock.c.

GnomeCanvasItem* canallock_right_item = NULL [static]

Definition at line 70 of file canal_lock.c.

gboolean canallock_right_up [static]

Definition at line 89 of file canal_lock.c.

int gamewon [static]

Definition at line 58 of file canal_lock.c.

GcomprisBoard* gcomprisBoard = NULL [static]

Definition at line 50 of file canal_lock.c.

GnomeCanvasItem* lock_left_item = NULL [static]

Definition at line 66 of file canal_lock.c.

gboolean lock_left_up [static]

Definition at line 85 of file canal_lock.c.

GnomeCanvasItem* lock_right_item = NULL [static]

Definition at line 67 of file canal_lock.c.

gboolean lock_right_up [static]

Definition at line 86 of file canal_lock.c.

gboolean lock_water_low [static]

Definition at line 87 of file canal_lock.c.

BoardPlugin menu_bp [static]
Initial value:
  {
    NULL,
    NULL,
    "Operate a canal lock",
    "Tux is in trouble in his ship. He needs to take it through a lock",
    "Bruno Coudoin <bruno.coudoin@free.fr>",
    NULL,
    NULL,
    NULL,
    NULL,
    start_board,
    pause_board,
    end_board,
    is_our_board,
    NULL,
    NULL,
    set_level,
    NULL,
    NULL,
    NULL,
    NULL
  }

Definition at line 105 of file canal_lock.c.

gboolean right_way [static]

Definition at line 84 of file canal_lock.c.

gint timer_id [static]

Definition at line 61 of file canal_lock.c.

GnomeCanvasItem* timer_item [static]

Definition at line 93 of file canal_lock.c.

double timer_item_limit_x [static]

Definition at line 92 of file canal_lock.c.

double timer_item_limit_y [static]

Definition at line 92 of file canal_lock.c.

double timer_item_x1 [static]

Definition at line 91 of file canal_lock.c.

double timer_item_x2 [static]

Definition at line 91 of file canal_lock.c.

double timer_item_y1 [static]

Definition at line 91 of file canal_lock.c.

double timer_item_y2 [static]

Definition at line 91 of file canal_lock.c.

gint timer_step_x1 [static]

Definition at line 94 of file canal_lock.c.

gint timer_step_y1 [static]

Definition at line 94 of file canal_lock.c.

GnomeCanvasItem* tuxboat_item = NULL [static]

Definition at line 76 of file canal_lock.c.

double tuxboat_width [static]

Definition at line 77 of file canal_lock.c.