Back to index

gcompris  8.2.2
Defines | Enumerations | Functions
bonus.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define TIME_CLICK_TO_BONUS   800

Enumerations

enum  BonusList {
  BONUS_RANDOM, BONUS_SMILEY, BONUS_FLOWER, BONUS_TUX,
  BONUS_GNU, BONUS_LAST
}
enum  BoardFinishedList {
  BOARD_FINISHED_RANDOM, BOARD_FINISHED_TUXPLANE, BOARD_FINISHED_TUXLOCO, BOARD_FINISHED_TOOMANYERRORS,
  BOARD_FINISHED_LAST
}
enum  BonusStatusList { BOARD_LOOSE, BOARD_WIN, BOARD_DRAW }

Functions

void gc_bonus_display (BonusStatusList, BonusList)
void gc_bonus_end_display (BoardFinishedList)

Define Documentation

#define TIME_CLICK_TO_BONUS   800

Definition at line 28 of file bonus.h.


Enumeration Type Documentation

Enumerator:
BOARD_FINISHED_RANDOM 
BOARD_FINISHED_TUXPLANE 
BOARD_FINISHED_TUXLOCO 
BOARD_FINISHED_TOOMANYERRORS 
BOARD_FINISHED_LAST 

Definition at line 42 of file bonus.h.

enum BonusList
Enumerator:
BONUS_RANDOM 
BONUS_SMILEY 
BONUS_FLOWER 
BONUS_TUX 
BONUS_GNU 
BONUS_LAST 

Definition at line 32 of file bonus.h.

Enumerator:
BOARD_LOOSE 
BOARD_WIN 
BOARD_DRAW 

Definition at line 51 of file bonus.h.


Function Documentation

Definition at line 213 of file bonus.c.

{
  gchar *absolute_file;

  g_assert(bonus_id < BONUS_LAST);

  gc_bar_hide(TRUE);

  if (bonus_display_running)
    return;
  else
    bonus_display_running = TRUE;
  
  if(gamewon == BOARD_WIN || gamewon == BOARD_DRAW) {
    absolute_file = gc_file_find_absolute(greetingsList[RAND(0, NUMBER_OF_GREETINGS-1)]);

    if (absolute_file)
      {
       gc_sound_play_ogg(absolute_file, NULL);
       g_free(absolute_file);
      }
    else
      gc_sound_play_ogg("sounds/wahoo.ogg", NULL);

  } else {
    absolute_file = gc_file_find_absolute(loosingList[RAND(0, NUMBER_OF_LOOSING-1)]);

    if (absolute_file)
      {
       gc_sound_play_ogg(absolute_file, NULL);
       g_free(absolute_file);
      }
    else
      gc_sound_play_ogg("sounds/crash.ogg", NULL);
  }

  /* First pause the board */
  gc_board_pause(TRUE);

  if(bonus_id==BONUS_RANDOM)
    bonus_id = RAND(1, BONUS_LAST-2);

  switch(bonus_id) {
  case BONUS_SMILEY :
    bonus_image("smiley",gamewon);
    break;
  case BONUS_FLOWER :
    bonus_image("flower",gamewon);
    break;
  case BONUS_TUX :
    bonus_image("tux",gamewon);
    break;
  case BONUS_GNU :
    bonus_image("gnu",gamewon);
    break;
  default :
    bonus_image("smiley",gamewon);
    break;
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 114 of file bonus.c.

                                             {
  GcomprisBoard *gcomprisBoard = gc_board_get_current();

  int x,y;
  GdkPixbuf *pixmap_door1 = NULL,*pixmap_door2 = NULL,*pixmap_tuxplane = NULL;
  char * str = NULL;

  g_assert(type < BOARD_FINISHED_LAST);

  gc_bar_hide(TRUE);

  if (gc_bonus_end_display_running)
    return;
  else
    gc_bonus_end_display_running = TRUE;

  /* First pause the board */
  gc_board_pause(TRUE);

  /* WARNING: I remove 1 to the BOARD_FINISHED_LAST because RANDOM is for GOOD end only */
  if(type==BOARD_FINISHED_RANDOM)
    type = RAND(1,BOARD_FINISHED_LAST-2);

  /* Record the end of board */
  gc_log_end (gcomprisBoard, GCOMPRIS_LOG_STATUS_COMPLETED);

  switch (type) {
       case BOARD_FINISHED_TUXPLANE :
              str = g_strdup_printf("gcompris/misc/tuxplane.png");
              break;
       case BOARD_FINISHED_TUXLOCO :
              str = g_strdup_printf("gcompris/misc/tuxloco.png");
              break;
       case BOARD_FINISHED_TOOMANYERRORS :
              str = g_strdup_printf("gcompris/misc/toomanyerrors.png");
              break;
       default :
              str = g_strdup_printf("gcompris/misc/tuxplane.png");
              break;
  }

  pixmap_door1 = gc_pixmap_load("gcompris/misc/door1.png");
  pixmap_door2 = gc_pixmap_load("gcompris/misc/door2.png");
  pixmap_tuxplane = gc_pixmap_load(str);
  g_free(str);

  g_assert(gcomprisBoard != NULL);

  x = gcomprisBoard->width - OFFSET - gdk_pixbuf_get_width(pixmap_door1);
  y = OFFSET;
  left_door_limit = x + gdk_pixbuf_get_width(pixmap_door1);

  door1_item = gnome_canvas_item_new (gnome_canvas_root(gcomprisBoard->canvas),
                                  gnome_canvas_pixbuf_get_type (),
                                  "pixbuf", pixmap_door1,
                                  "x", (double) x,
                                  "y", (double) y,
                                  "width", (double) gdk_pixbuf_get_width(pixmap_door1),
                                  "height", (double) gdk_pixbuf_get_height(pixmap_door1),
                                  "width_set", TRUE,
                                  "height_set", TRUE,
                                  NULL);

  x = OFFSET;
  y = (gcomprisBoard->height - gdk_pixbuf_get_height(pixmap_tuxplane)) /2;
  tuxplane_item = gnome_canvas_item_new (gnome_canvas_root(gcomprisBoard->canvas),
                                  gnome_canvas_pixbuf_get_type (),
                                  "pixbuf", pixmap_tuxplane,
                                  "x", (double) x,
                                  "y", (double) y,
                                  "width", (double) gdk_pixbuf_get_width(pixmap_tuxplane),
                                  "height", (double) gdk_pixbuf_get_height(pixmap_tuxplane),
                                  "width_set", TRUE,
                                  "height_set", TRUE,
                                  NULL);

  x = gcomprisBoard->width - OFFSET - gdk_pixbuf_get_width(pixmap_door2);
  y = OFFSET;
  door2_item = gnome_canvas_item_new (gnome_canvas_root(gcomprisBoard->canvas),
                                  gnome_canvas_pixbuf_get_type (),
                                  "pixbuf", pixmap_door2,
                                  "x", (double) x,
                                  "y", (double) y,
                                  "width", (double) gdk_pixbuf_get_width(pixmap_door2),
                                  "height", (double) gdk_pixbuf_get_height(pixmap_door2),
                                  "width_set", TRUE,
                                  "height_set", TRUE,
                                  NULL);

  gdk_pixbuf_unref(pixmap_door1);
  gdk_pixbuf_unref(pixmap_door2);
  gdk_pixbuf_unref(pixmap_tuxplane);

  gc_bonus_end_display_id = gtk_timeout_add (TUX_TIME_STEP, (GtkFunction) end_gc_bonus_end_display, NULL);

}

Here is the call graph for this function:

Here is the caller graph for this function: