static gint key_press_3D(guint keyval, gchar *commit_str, gchar *preedit_str) { switch (keyval) { case GDK_Left: viewing_direction=TURN_LEFT(viewing_direction); gc_sound_play_ogg ("sounds/grow.wav", NULL); break; case GDK_Right: viewing_direction=TURN_RIGHT(viewing_direction); gc_sound_play_ogg ("sounds/grow.wav", NULL); break; case GDK_Up: one_step(viewing_direction); break; case GDK_Down: viewing_direction=TURN_RIGHT(viewing_direction); viewing_direction=TURN_RIGHT(viewing_direction); gc_sound_play_ogg ("sounds/grow.wav", NULL); break; case GDK_2: case GDK_space: /* Display a warning that you can't move there */ g_object_set (warning_item, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL); twoDdisplay(); return TRUE; case GDK_E: case GDK_e: eye_pos_y+=0.1; if (eye_pos_y>0.9) eye_pos_y=0.9; break; case GDK_X: case GDK_x: eye_pos_y-=0.1; if (eye_pos_y<-0.9) eye_pos_y=-0.9; break; case GDK_D: case GDK_d: eye_pos_x+=0.1; if (eye_pos_x>0.9) eye_pos_x=0.9; break; case GDK_S: case GDK_s: eye_pos_x-=0.1; if (eye_pos_x<-0.9) eye_pos_x=-0.9; break; case GDK_Y: case GDK_y: case GDK_Z: case GDK_z: eye_pos_z+=0.1; break; case GDK_R: case GDK_r: eye_pos_z-=0.1; if (eye_pos_z<-0.9) eye_pos_z=-0.9; break; default: return FALSE; } update_tux(viewing_direction); draw3D(); return TRUE; }
static void movePos(int x1, int y1, int x2,int y2, int richting) { int ret,wall,i,bo=1; ret=1; wall=Maze[x1][y1]; if (wall&richting) { gc_sound_play_ogg ("sounds/brick.wav", NULL); ret=0; } if (ret) { gc_sound_play_ogg ("sounds/prompt.wav", NULL); if (Maze[x2][y2]&SET) { for (i=(ind); i>=0 && bo; i--) { if(position[i][0]==x2 && position[i][1]==y2) { bo=0; move_image(mazegroup,x2,y2,tuxgroup); // draw_rect(mazegroup,x2,y2,"blue"); } else { Maze[position[i][0]][position[i][1]]&=~SET; draw_rect(mazegroup, position[i][0], position[i][1], "red"); draw_combined_rect(mazegroup, position[i-1][0],position[i-1][1], position[i][0],position[i][1], "red"); ind--; } } } else { ind++; position[ind][0]=x2; position[ind][1]=y2; Maze[x2][y2]|=SET; if (position[ind][0]==(breedte-1) && position[ind][1]==(end)) { gamewon = TRUE; twoDdisplay(); gc_bonus_display(gamewon, GC_BONUS_LION); } else { draw_combined_rect(mazegroup, x1, y1, x2, y2, "green"); draw_rect(mazegroup,x1,y1,"green"); move_image(mazegroup,x2,y2,tuxgroup); } } } }
/* Called with items_lock locked */ static void player_win(LettersItem *item) { gc_sound_play_ogg ("sounds/flip.wav", NULL); g_assert(gcomprisBoard!=NULL); gcomprisBoard->sublevel++; gc_score_set(gcomprisBoard->sublevel); g_ptr_array_remove(items,item); g_ptr_array_add(items2del,item); g_object_set (item->rootitem, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); g_timeout_add (500,(GSourceFunc) wordsgame_delete_items, NULL); if(gcomprisBoard->sublevel > gcomprisBoard->number_of_sublevel) { /* Try the next level */ gcomprisBoard->level++; gcomprisBoard->sublevel = 0; if(gcomprisBoard->level>gcomprisBoard->maxlevel) gcomprisBoard->level = gcomprisBoard->maxlevel; wordsgame_next_level_unlocked(); gc_sound_play_ogg ("sounds/bonus.wav", NULL); } else { /* Drop a new item now to speed up the game */ if(items->len==0) { if ((fallSpeed-=INCREMENT_FALLSPEED) < MIN_FALLSPEED) fallSpeed+=INCREMENT_FALLSPEED; if ((speed-=INCREMENT_SPEED) < MIN_SPEED) speed+=INCREMENT_SPEED; if (drop_items_id) { /* Remove pending new item creation to sync the falls */ g_source_remove (drop_items_id); drop_items_id = 0; } if(!drop_items_id) { drop_items_id = g_timeout_add (0, (GSourceFunc) wordsgame_drop_items, NULL); } } } }
/* ==================================== */ static gboolean item_event (GooCanvasItem *item, GooCanvasItem *target, GdkEventButton *event, gpointer data) { if(board_paused) return FALSE; /* 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); } update_lights(); return FALSE; }
/* ===================================================================== * * =====================================================================*/ static gboolean item_event (GooCanvasItem *item, GooCanvasItem *target, GdkEventButton *event, gpointer data) { double x, y; int i, j, clicked; x = event->x; y = event->y; if (!gcomprisBoard || board_paused) return FALSE; //goo_canvas_c2w (gcomprisBoard->canvas, x, y, &x, &y); clicked = -1; for (i=0; i<4; i++) { for (j=0; j<2; j++) { if (x>X[i*2] && x<X[i*2+1] && y>Y[j*2] && y<Y[j*2+1]) { clicked = j*4 + i; } } } if (clicked >= 0) { gc_sound_play_ogg ("sounds/bleep.wav", NULL); board_paused = TRUE; highlight_selected(clicked); gamewon = (clicked == GPOINTER_TO_INT(g_list_nth_data(listColors,0))); ok(); } return FALSE; }
static void check_win() { gint timeout, timeout_tux; if (currentUiMode == UIMODE_SOUND){ timeout = 200; timeout_tux = 500; } else { timeout = 1000; timeout_tux = 2000; } // Check win if (compare_card((gpointer) firstCard, (gpointer) secondCard) == 0) { gc_sound_play_ogg ("sounds/flip.wav", NULL); win_id = g_timeout_add (timeout, (GSourceFunc) hide_card, NULL); lock_user = FALSE; return; } if (currentMode == MODE_TUX){ /* time to tux to play, after a delay */ to_tux = TRUE; g_warning("Now tux will play !"); tux_id = g_timeout_add (timeout_tux, (GSourceFunc) tux_play, NULL); lock_user = FALSE; return; } }
static void launch_dart(double item_x, double item_y) { animate_item_x = item_x; animate_item_y = item_y; animate_item_size = MAX_DART_SIZE; animate_item_distance = targetDefinition[gcomprisBoard->level-1].target_distance/10; gc_sound_play_ogg ("sounds/line_end.wav", NULL); animate_item = goo_canvas_ellipse_new (boardRootItem, (double)item_x, (double)item_y, (double)MAX_DART_SIZE, (double)MAX_DART_SIZE, "fill_color_rgba", 0xFF80FFFF, "stroke-color", "white", "line-width", (double)1, NULL); /* Make sure the target values stay on top */ goo_canvas_item_lower(animate_item, valueRootItem); animate_id = gtk_timeout_add (200, (GtkFunction) animate_items, NULL); if(--number_of_arrow == 0) { request_score(); } }
/* Callback for the bar operations */ static gboolean item_event_help (GooCanvasItem *item, GooCanvasItem *target, GdkEventButton *event, gchar *data) { gc_sound_play_ogg ("sounds/bleep.wav", NULL); if(!strcmp((char *)data, "ok")) { gc_help_stop(); } else if(!strcmp((char *)data, "prerequisite")) { select_item(item_prerequisite, item_prerequisite_text); set_content(prerequisite); } else if(!strcmp((char *)data, "goal")) { select_item(item_goal, item_goal_text); set_content(goal); } else if(!strcmp((char *)data, "manual")) { select_item(item_manual, item_manual_text); set_content(manual); } else if(!strcmp((char *)data, "credit")) { select_item(item_credit, item_credit_text); set_content(credit); } return TRUE; }
/* ===================================================================== * Submarine explosion * =====================================================================*/ static void submarine_explosion() { GdkPixbuf *pixmap = NULL; if (submarine_destroyed) return; submarine_destroyed = TRUE; gamewon = FALSE; gc_sound_play_ogg("sounds/crash.wav", NULL); /* make the submarine die */ setSpeed(speed_ordered = submarine_horizontal_speed = 0.0); setBattery(battery = 0.0); setAir(air = 0.0); regleur = MAX_REGLEUR; weight = 2000.0; /* Stop the frigate */ goo_canvas_item_stop_animation (frigate_item); /* display the boken submarine */ pixmap = gc_pixmap_load("submarine/submarine-broken.png"); g_object_set(submarine_item, "pixbuf", pixmap, NULL); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif ok(); }
/* Toggle the given lock */ static void toggle_lock(GooCanvasItem *item) { 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; gc_sound_play_ogg ("sounds/bleep.wav", NULL); if(item == lock_left_item) { status = lock_left_up; lock_left_up = !lock_left_up; y1 = BASE_LINE - LOCK_HEIGHT_MAX; min = BASE_LINE - 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 = BASE_LINE - LOCK_RHEIGHT_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 = SUBCANAL_BASE_LINE - 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 = SUBCANAL_BASE_LINE - CANALLOCK_HEIGHT_MIN; animate_speed = ANIMATE_SPEED; } timer_item = item; timer_item_limit_y = (status ? min : y1); timer_step_y1 = (status ? 2 : -2); timer_step_x1 = 0; gc_item_focus_remove(tuxboat_item, NULL); timer_id = gtk_timeout_add (animate_speed, (GtkFunction) animate_step, NULL); }
static void sound_callback(gchar *file) { if (! gcomprisBoard) return; if (!playing_sound) return; playing_sound = FALSE; if (currentMode == MODE_TUX){ if (to_tux) { if (firstCard && secondCard){ if (compare_card(firstCard, secondCard)==0){ gc_sound_play_ogg ("sounds/gobble.wav", NULL); win_id = g_timeout_add (1000, (GSourceFunc) hide_card, NULL); tux_id = g_timeout_add (2000, (GSourceFunc) tux_play, NULL); return; } else { to_tux = FALSE; return; } } else { tux_id = g_timeout_add (2000, (GSourceFunc) tux_play, NULL); return; } } } if (firstCard && secondCard) check_win(); }
/* * This is called on a low frequency and is used to drop new items * */ static gboolean gletters_drop_items (gpointer data) { gc_sound_play_ogg ("sounds/level.wav", NULL); gletters_add_new_item(); drop_items_id = g_timeout_add (fallSpeed, gletters_drop_items, NULL); return (FALSE); }
/* * This is called on a low frequency and is used to drop new items * */ static gint wordsgame_drop_items (GtkWidget *widget, gpointer data) { gc_sound_play_ogg ("sounds/level.wav", NULL); wordsgame_add_new_item(); g_source_remove(drop_items_id); drop_items_id = g_timeout_add (fallSpeed,(GSourceFunc) wordsgame_drop_items, NULL); return (FALSE); }
static void twoDdisplay() { gc_sound_play_ogg ("sounds/flip.wav", NULL); gc_set_default_background(goo_canvas_get_root_item(gcomprisBoard->canvas)); if (threedgroup) g_object_set (threedgroup, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); g_object_set (boardRootItem, "visibility", GOO_CANVAS_ITEM_VISIBLE, NULL); threeDactive=FALSE; }
/* ===================================================================== * * =====================================================================*/ static void game_won() { twoDdisplay(); /* Try the next level */ gcomprisBoard->level++; if(gcomprisBoard->level > gcomprisBoard->maxlevel) gcomprisBoard->level = gcomprisBoard->maxlevel; gc_sound_play_ogg ("sounds/bonus.wav", NULL); maze_next_level(); }
static void threeDdisplay() { gc_sound_play_ogg ("sounds/flip.wav", NULL); gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas), "maze/maze-bg.svgz"); g_object_set (boardRootItem, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); threeDactive=TRUE; draw3D(); }
static void player_win() { gc_sound_play_ogg ("sounds/bonus.wav", NULL); /* Try the next level */ if (tux_pairs <= player_pairs) gcomprisBoard->level++; if(gcomprisBoard->level>gcomprisBoard->maxlevel) gcomprisBoard->level = gcomprisBoard->maxlevel; gc_bonus_display((tux_pairs <= player_pairs), GC_BONUS_LION); }
static gint key_press_2D_relative(guint keyval, gchar *commit_str, gchar *preedit_str) { guint richting=0; switch (keyval) { case GDK_Left: viewing_direction=TURN_LEFT(viewing_direction); gc_sound_play_ogg ("sounds/grow.wav", NULL); update_tux(viewing_direction); return TRUE; break; case GDK_Right: viewing_direction=TURN_RIGHT(viewing_direction); gc_sound_play_ogg ("sounds/grow.wav", NULL); update_tux(viewing_direction); return TRUE; break; case GDK_Up: one_step(viewing_direction); break; case GDK_Down: gc_sound_play_ogg ("sounds/grow.wav", NULL); viewing_direction=TURN_RIGHT(viewing_direction); viewing_direction=TURN_RIGHT(viewing_direction); update_tux(viewing_direction); break; default: return FALSE; } richting=viewing_direction; /* run until we come to a fork, (make sure to stop on next level!) */ while (run_fast && (richting=available_direction(richting)) && !gamewon) { one_step(richting); viewing_direction=richting; } return TRUE; }
static gint item_event(GooCanvasItem *item, GdkEvent *event, MenuItems *menuitems) { GcomprisBoard *board; if(board_paused) return FALSE; if(boardRootItem == NULL) return FALSE; board = g_object_get_data (G_OBJECT (item), "board"); if(!menu_displayed) return TRUE; if (strcmp(board->type,"menu")==0) { gchar *path = g_strdup_printf("%s/%s",board->section, board->name); gc_sound_play_ogg ("sounds/bleep.wav", NULL); display_section(path); if (menu_position) g_free(menu_position); menu_position = path; } else if ( ! gc_board_is_demo_only(board) ) { gc_sound_play_ogg ("sounds/level.wav", NULL); gc_board_run_next (board); } return TRUE; }
/* set initial values for the next level */ static void click_on_letter_next_level() { gc_bar_set_level(gcomprisBoard); click_on_letter_destroy_all_items(); gamewon = FALSE; selected_button = NULL; /* Try the next level */ gc_sound_play_ogg("voices/$LOCALE/misc/click_on_letter.ogg", NULL); click_on_letter_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas)); gc_score_set_max(gcomprisBoard->number_of_sublevel); gc_score_set(gcomprisBoard->sublevel); }
/* ==================================== */ static void game_won() { gcomprisBoard->sublevel++; if(gcomprisBoard->sublevel>gcomprisBoard->number_of_sublevel) { /* Try the next level */ gcomprisBoard->sublevel=1; gcomprisBoard->level++; if(gcomprisBoard->level>gcomprisBoard->maxlevel) gcomprisBoard->level = gcomprisBoard->maxlevel; gc_sound_play_ogg ("sounds/bonus.wav", NULL); } superbrain_next_level(); }
/* * Dart animation * */ static void animate_items() { if(board_paused) return; if(!animate_item) return; // Apply the wind move animate_item_x = animate_item_x + wind_speed * sin(ang); animate_item_y = animate_item_y - wind_speed * cos(ang); g_object_set (animate_item, "center-x", (double)animate_item_x, "center-y", (double)animate_item_y, "radius-x", (double)animate_item_size, "radius-y", (double)animate_item_size, NULL); if(animate_item_size>MIN_DART_SIZE) animate_item_size--; if(--animate_item_distance == 0) { gc_sound_play_ogg ("sounds/brick.wav", NULL); // Calc the point for this dart guint points = add_points(animate_item_x, animate_item_y); // Add a tooltip on this dart to let the children // see how we count it g_signal_connect(animate_item, "enter_notify_event", (GtkSignalFunc) tooltip_event, GINT_TO_POINTER(points)); g_signal_connect(animate_item, "leave_notify_event", (GtkSignalFunc) tooltip_event, GINT_TO_POINTER(-1)); gtk_timeout_remove (animate_id); animate_id = 0; animate_item = NULL; // Change the wind for the next target display_windspeed(); } }
static void planegame_cloud_colision(GooCanvasItem *item) { GooCanvasBounds ib, pb; goo_canvas_item_get_bounds(planeitem, &pb); goo_canvas_item_get_bounds(item, &ib); if(ib.x2<0) { goo_canvas_item_remove(item); return; } if( ISIN(ib.x1, ib.y1, pb.x1, pb.y1, pb.x2, pb.y2) || ISIN(ib.x2, ib.y1, pb.x1, pb.y1, pb.x2, pb.y2) || ISIN(ib.x1, ib.y2, pb.x1, pb.y1, pb.x2, pb.y2) || ISIN(ib.x2, ib.y2, pb.x1, pb.y1, pb.x2, pb.y2) ) { gint number = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (item), "cloud_number")); if(plane_target == number) { planegame_speak_number(number); plane_target++; goo_canvas_item_remove(item); if(gcomprisBoard->level==1) gc_score_set(plane_target); if(plane_target == plane_last_target) { /* Try the next level */ gcomprisBoard->level++; if(gcomprisBoard->level>gcomprisBoard->maxlevel) gcomprisBoard->level = gcomprisBoard->maxlevel; planegame_next_level(); gc_sound_play_ogg ("sounds/bonus.wav", NULL); } } } }
/* ===================================================================== * battery_charger_event * =====================================================================*/ static gboolean battery_charger_event(GooCanvasItem *item, GooCanvas *target, GdkEventButton *event, gpointer data) { if(board_paused || !boardRootItem) return FALSE; gc_sound_play_ogg ("sounds/bleep.wav", NULL); if (battery_charging) battery_charging = FALSE; else battery_charging = TRUE; gc_item_rotate_with_center(item, battery_charging ? 180 : 0 , TRIGGER_CENTER_X, TRIGGER_CENTER_Y ); return FALSE; }
/* * This is called to play sound * */ static gint bar_play_sound (GooCanvasItem *item) { int policy = gc_sound_policy_get(); gchar *str; gc_sound_policy_set(PLAY_ONLY_IF_IDLE); GComprisBarFlags flag = GPOINTER_TO_UINT(g_object_get_data(G_OBJECT (item), "flag")); str = g_strdup_printf("voices/$LOCALE/misc/%s.ogg", bar_flags_to_name(flag)); gc_sound_play_ogg(str, NULL); g_free(str); gc_sound_policy_set(policy); sound_play_id = 0; return (FALSE); }
/* ===================================================================== * * =====================================================================*/ static gboolean regleur_chasse_event(GooCanvasItem *item, GooCanvas *target, GdkEventButton *event, gpointer data) { GooCanvasBounds bounds; if(board_paused || !boardRootItem) return FALSE; goo_canvas_item_get_bounds(item, &bounds); gc_sound_play_ogg ("sounds/bleep.wav", NULL); regleur_chasse_open = !regleur_chasse_open; goo_canvas_item_rotate(item, 90.0, bounds.x1 + (bounds.x2 - bounds.x1) / 2, bounds.y1 + (bounds.y2 - bounds.y1) / 2); return FALSE; }
/** Play the audio number given in @level */ void gc_bar_play_level_voice(int level) { /* Play the audio level number */ gchar *number_str = g_strdup_printf("%d", level); if ( level < 10 ) { /* Set the number as unicode */ gchar *level_str = gc_sound_alphabet(number_str); g_free(number_str); number_str = level_str; } gchar *audio_str = g_strdup_printf("voices/$LOCALE/alphabet/%s", number_str); gc_sound_play_ogg("voices/$LOCALE/misc/level.ogg", audio_str, NULL); g_free(number_str); g_free(audio_str); }
/** Play the audio number given in @number */ static void planegame_speak_number(int number) { /* Play the audio level number */ gchar *number_str = g_strdup_printf("%d", number); if ( number < 10 ) { /* Set the number as unicode */ gchar *level_str = gc_sound_alphabet(number_str); g_free(number_str); number_str = level_str; } gchar *audio_str = g_strdup_printf("voices/$LOCALE/alphabet/%s", number_str); gc_sound_play_ogg(audio_str, NULL); g_free(number_str); g_free(audio_str); }
/* ===================================================================== * barre_ar_event * =====================================================================*/ static gboolean barre_ar_event(GooCanvasItem *item, GooCanvas *target, GdkEventButton *event, gpointer data) { int d = GPOINTER_TO_INT(data); if(board_paused || !boardRootItem) return FALSE; gc_sound_play_ogg ("sounds/bleep.wav", NULL); if (d == UP && barre_ar_angle < RUDDER_MAX) { barre_ar_angle += RUDDER_STEP; gc_item_rotate_relative_with_center(barre_ar_item, RUDDER_STEP, RUDDER_CENTER_X, RUDDER_CENTER_Y); } if (d == DOWN && barre_ar_angle > -RUDDER_MAX) { barre_ar_angle -= RUDDER_STEP; gc_item_rotate_relative_with_center( barre_ar_item, -RUDDER_STEP, RUDDER_CENTER_X, RUDDER_CENTER_Y); } return FALSE; }
static void player_win(GooCanvasItem *item) { gletters_destroy_item(item); gc_sound_play_ogg ("sounds/flip.wav", NULL); gcomprisBoard->sublevel++; if(gcomprisBoard->sublevel > gcomprisBoard->number_of_sublevel) { /* Try the next level */ gcomprisBoard->level++; if(gcomprisBoard->level>gcomprisBoard->maxlevel) gcomprisBoard->level = gcomprisBoard->maxlevel; gamewon = TRUE; gletters_destroy_all_items(); gc_bonus_display(gamewon, GC_BONUS_SMILEY); } else { gc_score_set(gcomprisBoard->sublevel); /* Drop a new item now to speed up the game */ if(g_list_length(item_list)==0) { if (drop_items_id) { /* Remove pending new item creation to sync the falls */ g_source_remove (drop_items_id); drop_items_id = 0; } if(!drop_items_id) { drop_items_id = g_timeout_add (0, gletters_drop_items, NULL); } } } }