/* Called with items_lock locked */ static void wordsgame_next_level_unlocked() { gcomprisBoard->number_of_sublevel = 10 + ((gcomprisBoard->level-1) * 5); gc_score_start(SCORESTYLE_NOTE, BOARDWIDTH - 195, BOARDHEIGHT - 30, gcomprisBoard->number_of_sublevel); gc_bar_set_level(gcomprisBoard); gc_score_set(gcomprisBoard->sublevel); wordsgame_destroy_all_items(); if (preedit_text){ goo_canvas_item_remove(preedit_text); preedit_text=NULL; } gc_im_reset(); items=g_ptr_array_new(); items2del=g_ptr_array_new(); /* Increase speed only after 5 levels */ if(gcomprisBoard->level > 5) { gint temp = fallSpeed-gcomprisBoard->level*200; if (temp > MIN_FALLSPEED) fallSpeed=temp; } pause_board(FALSE); }
/* ===================================================================== * set initial values for the next level * =====================================================================*/ static void submarine_next_level() { gamewon = FALSE; ballast_av_purge_open = ballast_ar_purge_open = regleur_purge_open = FALSE; ballast_av_chasse_open = ballast_ar_chasse_open = regleur_chasse_open = FALSE; air_charging = battery_charging = FALSE; barre_av_angle = barre_ar_angle = 0.0; depth = SUBMARINE_INITIAL_DEPTH; submarine_horizontal_speed = speed_ordered = 0.0; submarine_x = SUBMARINE_INITIAL_X; weight = WEIGHT_INITIAL; regleur = REGLEUR_INITIAL; air = AIR_INITIAL; battery = BATTERY_INITIAL; ballast_av_air = ballast_ar_air = MAX_BALLAST/10.0; assiette = 0.0; submarine_destroyed = FALSE; treasure_captured = FALSE; submarine_destroy_all_items(); /* Try the next level */ boardRootItem = submarine_create_item(backgroundRootItem); start_frigate_anim(); gc_bar_set_level(gcomprisBoard); }
/* set initial values for the next level */ static void imageid_next_level() { gc_bar_set_level(gcomprisBoard); imageid_destroy_all_items(); selected_button = NULL; gamewon = FALSE; destroy_board_list(); init_xml(gcomprisBoard->level); gcomprisBoard->number_of_sublevel = g_list_length(board_list); gc_score_end(); gc_score_start(SCORESTYLE_NOTE, BOARDWIDTH - 195, BOARDHEIGHT - 30, gcomprisBoard->number_of_sublevel); gc_score_set(gcomprisBoard->sublevel); /* Try the next level */ imageid_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas)); }
/* set initial values for the next level */ static void target_next_level() { gc_bar_set_level(gcomprisBoard); target_destroy_all_items(); gamewon = FALSE; /* Try the next level */ target_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas)); }
/* set initial values for the next level */ static void fifteen_next_level() { gc_set_default_background(goo_canvas_get_root_item(gcomprisBoard->canvas)); gc_bar_set_level(gcomprisBoard); fifteen_destroy_all_items(); gamewon = FALSE; /* Create the level */ fifteen_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas)); }
/* 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); }
/* ===================================================================== * set initial values for the next level * =====================================================================*/ static void colors_next_level() { gchar *str = NULL; int i, list_length; GList * list = NULL; int * item; colors_destroy_all_items(); gamewon = FALSE; gc_score_set(gcomprisBoard->sublevel); gc_bar_set_level(gcomprisBoard); /* initialize board only once*/ if (gcomprisBoard->sublevel == 1) { errors = MAX_ERRORS; // we generate a list of color indexes in a random order while (g_list_length(listColors) > 0) listColors = g_list_remove(listColors, g_list_nth_data(listColors,0)); for (i=0; i<LAST_COLOR; i++) list = g_list_append(list, GINT_TO_POINTER(i)); while((list_length = g_list_length(list))) { i = list_length == 1 ? 0 : g_random_int_range(0,g_list_length(list)-1); item = g_list_nth_data(list, i); listColors = g_list_append(listColors, item); list = g_list_remove(list, item); } /* set background */ str = g_strdup_printf("%s/%s", gcomprisBoard->boarddir, backgroundFile); g_warning("background = %s\n", str); gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas), str); g_free(str); } colors_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas)); /* show text of color to find */ color_item = goo_canvas_text_new (boardRootItem, colors[GPOINTER_TO_INT(g_list_nth_data(listColors,0))], (color_x1+color_x2)/2, (color_y1+color_y2)/2, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_title_bold, "fill-color", "darkblue", NULL); }
/* set initial values for the next level */ static void gletters_next_level() { gamewon = FALSE; gc_bar_set_level(gcomprisBoard); gletters_destroy_all_items(); /* Try the next level */ speed=fallRateBase+(fallRateMult/gcomprisBoard->level); fallSpeed=dropRateBase+(dropRateMult/gcomprisBoard->level); gcomprisBoard->sublevel=1; gc_score_set(gcomprisBoard->sublevel); }
/* set initial values for the next level */ static void canal_lock_next_level() { gc_bar_set_level(gcomprisBoard); gamewon = FALSE; from = 0; /* 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; update_lights(); }
/* set initial values for the next level */ static void hanoi_next_level() { gc_bar_set_level(gcomprisBoard); hanoi_destroy_all_items(); gamewon = FALSE; /* Select level difficulty */ switch(gcomprisBoard->level) { case 1: number_of_item_x = 3; number_of_item_y = 5; break; case 2: number_of_item_x = 4; number_of_item_y = 5; break; case 3: number_of_item_x = 5; number_of_item_y = 6; case 4: number_of_item_x = 6; number_of_item_y = 7; break; case 5: number_of_item_x = 6; number_of_item_y = 8; break; case 6: number_of_item_x = 5; number_of_item_y = 9; break; default: number_of_item_x = 5; number_of_item_y = 7; } /* Try the next level */ hanoi_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas)); }
/* set initial values for the next level */ static void memory_next_level() { gc_bar_set_level(gcomprisBoard); to_tux = FALSE; if (currentUiMode == UIMODE_SOUND){ /* We play a sound here to cancel any pending sounds callback from a previous play */ playing_sound = TRUE; gc_sound_play_ogg_cb("memory/LRBuddhist_gong_05_LA.ogg",start_callback); } else playing_sound = FALSE; memory_destroy_all_items(); boardRootItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas), NULL); numberOfColumn = levelDescription[gcomprisBoard->level*2]; numberOfLine = levelDescription[gcomprisBoard->level*2+1]; remainingCards = numberOfColumn * numberOfLine; gcomprisBoard->number_of_sublevel=1; gcomprisBoard->sublevel=0; create_item(boardRootItem); lock_user = FALSE; if (currentMode == MODE_TUX){ tux_memory_size = tux_memory_sizes[gcomprisBoard->level]; g_warning("tux_memory_size %d", tux_memory_size ); tux_pairs = 0; player_pairs = 0; update_scores(); } }
/* set initial values for the next level */ static void superbrain_next_level() { guint i; gboolean selected_color[MAX_COLORS]; gc_bar_set_level(gcomprisBoard); superbrain_destroy_all_items(); gamewon = FALSE; /* Select level difficulty : should not go above MAX_PIECES */ /* number_of_color must be upper than number_of_piece to allow unicity */ if(gcomprisBoard->level < LEVEL_MAX_FOR_HELP) { number_of_piece = gcomprisBoard->level + 2; number_of_color = gcomprisBoard->level + 4; } else { number_of_piece = gcomprisBoard->level - LEVEL_MAX_FOR_HELP + 3; number_of_color = gcomprisBoard->level - LEVEL_MAX_FOR_HELP + 5; } current_y_position = BOARDHEIGHT - 50; /* Init a random solution : colors choosen are uniquely choosen */ for(i=0; i<number_of_color; i++) { selected_color[i] = FALSE; } for(i=0; i<number_of_piece; i++) { guint j; j = (guint)g_random_int_range(0, number_of_color); while(selected_color[j]) j = (guint)g_random_int_range(0, number_of_color); solution[i] = j; selected_color[j] = TRUE; } boardRootItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas), NULL); boardLogoItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas), NULL); /* The OK Button */ GooCanvasItem *item = goo_canvas_svg_new (boardLogoItem, gc_skin_rsvg_get(), "svg-id", "#OK", NULL); SET_ITEM_LOCATION(item, 270, 50); g_signal_connect(item, "button_press_event", (GCallback) process_ok, NULL); gc_item_focus_init(item, NULL); /* The list of the pieces */ for(i=0; i<number_of_color; i++) { goo_canvas_ellipse_new (boardLogoItem, PIECE_DISPLAY_X, PIECE_DISPLAY_Y + i*((PIECE_WIDTH*1.5)*2 + PIECE_GAP/2), PIECE_WIDTH * 1.5, PIECE_WIDTH * 1.5, "fill_color_rgba", colors[i], "stroke-color", "white", "line-width", (double)1, NULL); } superbrain_create_item(boardRootItem); }
/* ===================================================================== * set initial values for the next level * =====================================================================*/ static void maze_next_level() { GdkPixbuf *pixmap = NULL; maze_destroy_all_items(); gc_bar_set_level(gcomprisBoard); setlevelproperties(); mapActive = FALSE; ind = 0; gamewon = FALSE; initMaze(); generateMaze((g_random_int()%breedte),(g_random_int()%hoogte)); removeSet(); /* Try the next level */ maze_create_item(goo_canvas_get_root_item(gcomprisBoard->canvas)); draw_background(wallgroup); if(modeIsInvisible) { g_object_set (wallgroup, "visibility", GOO_CANVAS_ITEM_INVISIBLE, NULL); } /* make a new group for the items */ begin=g_random_int()%hoogte; end=g_random_int()%hoogte; /* Draw the tux */ RsvgHandle *svg_handle = gc_rsvg_load("maze/tux_top_south.svg"); tuxitem = goo_canvas_svg_new (tuxgroup, svg_handle, NULL); g_object_unref (svg_handle); goo_canvas_item_translate(tuxgroup, cellsize*(0)-breedte + board_border_x, cellsize*(begin)-hoogte + board_border_y); g_signal_connect(tuxitem, "button_press_event", (GCallback) tux_event, NULL); if(run_fast_possible) { /* Load the tux shoes */ svg_handle = gc_rsvg_load("maze/tux_shoes_top_south.svgz"); tuxshoes = goo_canvas_svg_new (tuxgroup, svg_handle, "pointer-events", GOO_CANVAS_EVENTS_NONE, NULL); g_object_unref (svg_handle); /* Load fast-mode switch button */ svg_handle = gc_rsvg_load("maze/fast-mode-button.svgz"); fast_mode_button = goo_canvas_svg_new (boardRootItem, svg_handle, NULL); g_object_unref (svg_handle); goo_canvas_item_translate(fast_mode_button, 10, 10); g_signal_connect(fast_mode_button, "button_press_event", (GCallback) on_fast_mode_button_press, NULL); gc_item_focus_init(fast_mode_button, NULL); } /* Draw the target */ pixmap = gc_pixmap_load("maze/door.png"); if(pixmap) { draw_image(mazegroup,breedte-1,end,pixmap); #if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24 gdk_pixbuf_unref(pixmap); #else g_object_unref(pixmap); #endif } position[ind][0]=0; position[ind][1]=begin; Maze[0][begin]=Maze[0][begin]+SET; viewing_direction=EAST; threeDactive=FALSE; if(run_fast_possible) { // run_fast-mode should be initialized at every level, whether TRUE or FALSE if (gcomprisBoard->level < 14) set_run_fast(FALSE); if (gcomprisBoard->level >= 14) set_run_fast(TRUE); } update_tux(viewing_direction); if(!modeIs2D) threeDdisplay(); }
/* set initial values for the next level */ static void planegame_next_level() { RsvgHandle *svg_handle = NULL; GooCanvasItem *item; gc_bar_set_level(gcomprisBoard); planegame_destroy_all_items(); rootitem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas), NULL); clouds_rootitem = goo_canvas_group_new (rootitem, NULL); /* Try the next level */ speed=100+(40/(gcomprisBoard->level)); fallSpeed=10000-gcomprisBoard->level*200; /* Make the images tend to 0.5 ratio */ imageZoom=0.3+(0.5/(gcomprisBoard->level)); /* Setup and Display the plane */ planespeed_y = 0; planespeed_x = 0; svg_handle = gc_rsvg_load("planegame/tuxhelico.svgz"); plane_x = 50; plane_y = 300; planeitem = goo_canvas_group_new (rootitem, NULL); goo_canvas_item_translate(planeitem, plane_x, plane_y); item = goo_canvas_svg_new (planeitem, svg_handle, NULL); goo_canvas_item_scale(item, 0.4 * imageZoom, 0.4 * imageZoom); g_object_unref(svg_handle); /* Game rules */ plane_target = 1; plane_last_target = 10; gcomprisBoard->number_of_sublevel=plane_last_target; gcomprisBoard->sublevel=plane_target; if(gcomprisBoard->level>1) { /* No scoring after level 1 */ gc_score_end(); } else { gc_score_start(SCORESTYLE_NOTE, BOARDWIDTH - 195, BOARDHEIGHT - 30, gcomprisBoard->number_of_sublevel); gc_score_set(gcomprisBoard->sublevel); } }
/* set initial values for the next level */ static void money_next_level() { guint min_price = 0, max_price = 0; guint paid = 0; guint number_of_item = 0; guint i; gchar *display_format; gc_set_background(goo_canvas_get_root_item(gcomprisBoard->canvas), "money/money-bg.png"); gc_bar_set_level(gcomprisBoard); money_destroy_all_items(); gamewon = FALSE; boardRootItem = goo_canvas_group_new (goo_canvas_get_root_item(gcomprisBoard->canvas), NULL); /* The OK Button */ GooCanvasItem *item = goo_canvas_svg_new( boardRootItem, gc_skin_rsvg_get(), "svg-id", "#OK", NULL); SET_ITEM_LOCATION(item, 725, 230); g_signal_connect(item, "button_press_event", (GtkSignalFunc) moneyactivity_process_ok, NULL); gc_item_focus_init(item, NULL); tux_money = MONEY_WIDGET(money_widget_new()); money_widget_set_position(tux_money, boardRootItem, 100.0, 380.0, 700.0, 490.0, 5, 2, FALSE); /* Select level difficulty */ switch(currentMode) { case WITHOUT_CENTS: switch(gcomprisBoard->level) { case 1: number_of_item = 1; min_price = 3; max_price = 10; money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 2: number_of_item = 1; min_price = 10; max_price = 20; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 3: number_of_item = 2; min_price = 20; max_price = 30; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 4: number_of_item = 2; min_price = 30; max_price = 40; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 5: number_of_item = 3; min_price = 40; max_price = 50; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 6: number_of_item = 3; min_price = 50; max_price = 60; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 7: number_of_item = 4; min_price = 60; max_price = 70; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_50E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 8: number_of_item = 4; min_price = 70; max_price = 80; money_widget_add(tux_money, MONEY_EURO_PAPER_50E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 9: number_of_item = 4; min_price = 50; max_price = 100; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_50E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); break; } break; case WITH_CENTS: switch(gcomprisBoard->level) { case 1: number_of_item = 1; min_price = 1; max_price = 3; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; case 2: number_of_item = 1; min_price = 1; max_price = 3; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; case 3: number_of_item = 2; min_price = 1; max_price = 3; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; case 4: number_of_item = 3; min_price = 1; max_price = 3; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; case 5: number_of_item = 4; min_price = 0; max_price = 4; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; } break; case BACK_WITHOUT_CENTS: switch(gcomprisBoard->level) { case 1: number_of_item = 1; min_price = 3; max_price = 9; paid = 10; money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 2: number_of_item = 1; min_price = 1; max_price = 19; paid = 20; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 3: number_of_item = 2; min_price = 2; max_price = 29; paid = 30; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 4: number_of_item = 2; min_price = 2; max_price = 39; paid = 40; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 5: number_of_item = 3; min_price = 3; max_price = 49; paid = 50; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 6: number_of_item = 3; min_price = 3; max_price = 60; paid = 100; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_50E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 7: number_of_item = 4; min_price = 4; max_price = 70; paid = 100; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_50E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 8: number_of_item = 4; min_price = 4; max_price = 80; paid = 100; money_widget_add(tux_money, MONEY_EURO_PAPER_50E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); break; case 9: number_of_item = 4; min_price = 4; max_price = 99; paid = 100; money_widget_add(tux_money, MONEY_EURO_PAPER_10E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_PAPER_50E); money_widget_add(tux_money, MONEY_EURO_PAPER_20E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); money_widget_add(tux_money, MONEY_EURO_PAPER_5E); break; } break; case BACK_WITH_CENTS: switch(gcomprisBoard->level) { case 1: number_of_item = 1; min_price = 1; max_price = 3; paid = 5; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; case 2: number_of_item = 1; min_price = 1; max_price = 3; paid = 5; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; case 3: number_of_item = 2; min_price = 1; max_price = 3; paid = 5; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; case 4: number_of_item = 3; min_price = 1; max_price = 3; paid = 5; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; case 5: number_of_item = 4; min_price = 0; max_price = 4; paid = 5; money_widget_add(tux_money, MONEY_EURO_COIN_2E); money_widget_add(tux_money, MONEY_EURO_COIN_1E); money_widget_add(tux_money, MONEY_EURO_COIN_5C); money_widget_add(tux_money, MONEY_EURO_COIN_2C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_50C); money_widget_add(tux_money, MONEY_EURO_COIN_20C); money_widget_add(tux_money, MONEY_EURO_COIN_10C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); money_widget_add(tux_money, MONEY_EURO_COIN_1C); break; } break; } seller_money = MONEY_WIDGET(money_widget_new()); money_widget_set_position(seller_money, boardRootItem, 100.0, 20.0, 700.0, 130.0, 5, 2, FALSE); money_widget_set_target(seller_money, tux_money); money_widget_set_target(tux_money, seller_money); /* Display what to buy */ price_target = 0; for(i=1; i<=number_of_item; i++) { gdouble object_price; gchar *text; GooCanvasItem *item; RsvgHandle *svg_handle; RsvgDimensionData dimension; double xratio, yratio; guint offset_x = 50; guint boardwidth = BOARDWIDTH - offset_x * 2; /* Display the price */ object_price = (double) g_random_int_range(min_price/number_of_item, max_price/number_of_item); { /* Select an image list depending on the price */ gchar **imageList; guint number_of_images; if ( object_price < 5 ) { imageList = imageList1; number_of_images = NUMBER_OF_IMAGES1; } else if ( object_price < 10 ) { imageList = imageList2; number_of_images = NUMBER_OF_IMAGES2; } else { imageList = imageList3; number_of_images = NUMBER_OF_IMAGES3; } svg_handle = \ gc_rsvg_load(imageList[g_random_int_range(0, number_of_images - 1)]); rsvg_handle_get_dimensions(svg_handle, &dimension); item = goo_canvas_svg_new ( boardRootItem, svg_handle, NULL); } xratio = (gdouble)(boardwidth/(number_of_item+1)) / dimension.width; yratio = 100.0 / dimension.height; xratio = yratio = MIN(xratio, yratio); goo_canvas_item_translate(item, offset_x + (i*boardwidth)/(number_of_item+1) - dimension.width*xratio/2, 200); goo_canvas_item_scale(item, xratio, xratio); if( (currentMode == WITH_CENTS) || (currentMode == BACK_WITH_CENTS) ) { /* Set here the way to display money. Change only the money sign, and it's place, always keep %.2f, it will be replaced by 0,34 if decimal is ',' in your locale */ display_format = _("$ %.2f"); /* Add random cents */ if(gcomprisBoard->level == 1) { object_price += (double)((double) g_random_int_range(1, 9))/10.0; } else { object_price += (double)((double) g_random_int_range(1, 99))/100.0; } } else { /* Set here the way to display money. Change only the money sign, and it's place, always keep %.2f, it will be replaced by 0,34 if decimal is ',' in your locale */ display_format = _("$ %.0f"); } price_target += object_price; text = g_strdup_printf(display_format, object_price); goo_canvas_text_new(boardRootItem, text, offset_x + (i*boardwidth)/(number_of_item+1), 185, -1, GTK_ANCHOR_CENTER, "font", gc_skin_font_board_big, "fill-color", "white", NULL); g_free(text); g_object_unref(svg_handle); } if (paid) { // Calc the money back instead of the objects price price_target = paid - price_target; // Display Tux and his money display_paying_tux(paid); } }