void on_network_game (void) { GtkWidget *ggzbox; struct passwd *pwent; static gboolean ggz_initialized = FALSE; if (ggz_network_mode) { gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), NETWORK_PAGE); return; } game_reset (); ggz_network_mode = TRUE; prompt_player (); if (ggz_initialized == FALSE) { ggz_initialized = TRUE; ggz_gtk_initialize (FALSE, ggz_connected, ggz_game_launched, ggz_closed, NETWORK_ENGINE, NETWORK_VERSION, "gnect.xml", "GGZ Gaming Zone"); ggzbox = ggz_gtk_create_main_area (app); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), ggzbox, NULL); } pwent = getpwuid(getuid()); ggz_embed_ensure_server ("GGZ Gaming Zone", "gnome.ggzgamingzone.org", 5688, pwent->pw_name); gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), NETWORK_PAGE); }
__declspec(interrupt) void gpt0_isr() { //Clear the interrupt request flag MCF_GPT_GPTFLG1 |= 0x01; game_reset(); }
/**************************************************************************** Callback function that's invoked when GGZ is exited. ****************************************************************************/ static void ggz_closed (void) { gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), MAIN_PAGE); ggz_network_mode = FALSE; game_reset (); prompt_player (); }
int change(gchar *data) { int n; n = atoi(data); gtk_container_remove(GTK_CONTAINER(window),vbox); mine_map(n); game_reset(); }
/** * @brief Creates a new tetris game. * * @param width board width (10 in standard Tetris; must be lower than or equal to 14) * @param height board height (20 in standard Tetris) * @param allow_lines_after_overflow 1 to enable the lines completion when the piece overflows * @param pieces_file_name a file describing the pieces (pieces4.dat for standard Tetris) * @param piece_sequence a predeterminated sequence of pieces, or NULL to generate the pieces randomly; * the sequence of pieces must be a NULL-terminated array of pieces indexes * @return the game created * @see new_standard_game(), new_game_from_parameters(), new_game_copy(), free_game() */ Game *new_game(int tetris_implementation, int width, int height, int allow_lines_after_overflow, const char *pieces_file_name, int *piece_sequence) { Game *game; MALLOC(game, Game); MALLOC(game->piece_configuration, PieceConfiguration); load_pieces(pieces_file_name, &game->piece_configuration->nb_pieces, &game->piece_configuration->pieces); game->tetris_implementation = tetris_implementation; game->board = new_board(width, height, allow_lines_after_overflow, game->piece_configuration->nb_pieces, game->piece_configuration->pieces); game->piece_configuration->piece_sequence = piece_sequence; game->piece_configuration->nb_games = 1; game_reset(game); return game; }
/**************************************************************************** Callback function that's called by the library when we launch a game. This means we now have a connection to a gnect server so handling can be given back to the regular gnect code. ****************************************************************************/ static void ggz_game_launched (void) { gchar *str = NULL; network_init (); game_reset (); gtk_notebook_set_current_page (GTK_NOTEBOOK (notebook), MAIN_PAGE); str = g_strdup_printf (_("Welcome to a network game of %s."), NETWORK_ENGINE); add_chat_text (str); g_free (str); }
int main(void) { int i; char choice; char quit; main_init(); quit = FALSE; do { choice = title_page(); switch (choice) { case (0) : case (1) : gPlayers = choice + 1; break; case (2) : continue; default : quit = TRUE; }; if (!quit) { game_reset(); // main game loop do { key_check(); for (i = 0; i != gPlayers; ++i) { player_key_check(i); player_stack_linecheck(i); player_update(i); } screen_draw(); blit(gBuff, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H); } while (gWinner == 0); record_scores(); table_display(); } } while (!quit); table_display(); main_exit(); return 0; }
void game_init() { // initial game progress value; 0x1F = full completion, i.e. 31+1 = 32 levels globals[0x14] = 0x63; // ??? globals[0x13] = -1; // initial title sequence state globals[0x12] = 7; //sony computer entertainment america // ??? globals[0x22] = 0xFF; globals[0x23] = 0xFF; // ??? globals[0x1F] = 0x400; // ??? globals[0x15] = 0; // ??? globals[0x20] = 0; globals[0x21] = 0; // ?? checked by boxes and fruit globals[0x2E] = 1; // ?? globals[0x6D] = 0; // ?? globals[0x73] = 0; // camera mode? globals[0x11] = 0; // used by DispC... globals[0x64] = 0; // ?? globals[0x65] = 0; // ?? globals[0x71] = 1; game_reset(true); }
static void on_select_player2 (GtkWidget * w, gpointer data) { GtkTreeIter iter; gint value; if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (w), &iter)) return; gtk_tree_model_get (GTK_TREE_MODEL (gtk_combo_box_get_model (GTK_COMBO_BOX (w))), &iter, 1, &value, -1); p.level[PLAYER2] = value; g_settings_set_int (settings, "player2", value); scorebox_reset (); who_starts = PLAYER2; /* This gets reversed in game_reset. */ game_reset (); }
void score_limit_run(void) { int tick; // we are paused so use regular ticks tick=time_get(); // draw score limit gl_frame_start(NULL); gui_draw_background(1.0f); network_draw(tick); gl_frame_end(); // pump events since we aren't calling // the regular gui routines input_event_pump(); // if we are hosting, we can exit early // and send the reset message to clients if (net_setup.host.hosting) { // check for time exit or escape exit if ((tick>(score_limit_start_tick+(SCORE_LIMIT_SECOND_PAUSE*1000))) || (input_action_get_state_single(nc_menu))) { game_reset(); score_limit_close(); } return; } // clients can't exit, but if they don't // get an update in the time + 10 seconds, // they auto-quit the game if (tick>(score_limit_start_tick+((SCORE_LIMIT_SECOND_PAUSE+10)*1000))) { score_limit_close(); remote_host_exit(); } }
int main (int argc, char *argv[]) { GOptionContext *context; gboolean retval; GError *error = NULL; setlocale (LC_ALL, ""); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); context = g_option_context_new (NULL); g_option_context_add_group (context, gtk_get_option_group (TRUE)); retval = g_option_context_parse (context, &argc, &argv, &error); g_option_context_free (context); if (!retval) { g_print ("%s", error->message); g_error_free (error); exit (1); } settings = g_settings_new ("org.gnome.gnect"); g_set_application_name (_(APPNAME_LONG)); prefs_init (); game_init (); /* init gfx */ if (!gfx_load_pixmaps ()) { exit (1); } if (create_app ()) { game_reset (); gtk_main (); } game_free (); return 0; }
void game_init(Game *game) { game_reset(game); }
void ui_state_game(void) { int i, x, y, go_x, go_y, result; int aimline_x1 = SCREEN_WIDTH - UI_TILE_WIDTH / 2, aimline_y1 = UI_Y_OFFSET + UI_TILE_HEIGHT / 2, aimline_x2, aimline_y2, strengthbar_width; int play_explosion = 0; int tank_direction, tank_strength, meter_direction; double radians; game_position_t result_pos; image_t *tile; led_clear(); for (i = 0; i < game_soldier_score; i++) led_set(7 - i, 1); for (i = 0; i < game_tank_score; i++) led_set(i, 1); if (game_soldier_score >= UI_MAX_POINTS || game_tank_score >= UI_MAX_POINTS) { ui_state = UI_SCOREBOARD; return; } game_reset(); while (1) { screen_clear(color_black); for (x = 0; x < GAME_WIDTH; x++) for (y = 0; y < GAME_HEIGHT; y++) { tile = game_is_scorched[y][x] ? img_dirt : img_grass; image_draw(x * UI_TILE_WIDTH, y * UI_TILE_HEIGHT + UI_Y_OFFSET, tile); } go_x = game_player.x; go_y = game_player.y; switch (ui_player_direction) { case GAME_NORTH: go_y--; break; case GAME_SOUTH: go_y++; break; case GAME_WEST: go_x--; break; case GAME_EAST: go_x++; break; } switch (ui_state) { case UI_GAME_SOLDIER: if (go_x >= 0 && go_x < GAME_WIDTH && go_y >= 0 && go_y < GAME_HEIGHT) { screen_rectangle( go_x * UI_TILE_WIDTH, go_y * UI_TILE_HEIGHT + UI_Y_OFFSET, UI_TILE_WIDTH, UI_TILE_HEIGHT, color_blue); } if (ui_play_point_sound) snd_play("sounds/point.raw"); else if (play_explosion) snd_play("sounds/eksplosjon.raw"); ui_play_point_sound = 0; play_explosion = 0; if (btn_is_pushed(7)) { result = game_move_player(ui_player_direction); if (result == GAME_MOVE_TANK) { ui_play_point_sound = 1; return; } if (result == GAME_MOVE_OK) { tank_direction = GAME_MIN_DIRECTION; meter_direction = UI_DIRECTION_SPEED; ui_state = UI_GAME_DIRECTION; } } if (btn_is_pushed(6)) { ui_player_direction = ((int)ui_player_direction + 1) % 4; } break; case UI_GAME_DIRECTION: if (btn_is_pushed(0)) { tank_strength = GAME_MIN_STRENGTH; meter_direction = UI_STRENGTH_SPEED; ui_state = UI_GAME_STRENGTH; break; } radians = tank_direction * M_PI / 180; aimline_x2 = aimline_x1 - (int)(cos(radians) * UI_TILE_WIDTH * 3); aimline_y2 = aimline_y1 + (int)(sin(radians) * UI_TILE_HEIGHT * 3); screen_line(aimline_x1, aimline_y1, aimline_x2, aimline_y2, color_red); if (tank_direction >= GAME_MAX_DIRECTION) meter_direction = -UI_DIRECTION_SPEED; if (tank_direction <= GAME_MIN_DIRECTION) meter_direction = UI_DIRECTION_SPEED; tank_direction += meter_direction; tank_direction = MAX(GAME_MIN_DIRECTION, tank_direction); tank_direction = MIN(GAME_MAX_DIRECTION, tank_direction); break; case UI_GAME_STRENGTH: if (btn_is_pushed(0)) { snd_play_wait("sounds/skyte.raw"); result_pos = game_shoot_bullet(tank_direction, tank_strength); ui_state = UI_GAME_SOLDIER; play_explosion = !game_position_equals(result_pos, GAME_SHOT_OOB); if (result_pos.x < 0 && result_pos.y < 0) { ui_play_point_sound = 1; return; } break; } screen_line(aimline_x1, aimline_y1, aimline_x2, aimline_y2, color_red); strengthbar_width = tank_strength * (SCREEN_WIDTH - UI_TILE_WIDTH) / GAME_MAX_STRENGTH; screen_fill_rectangle( SCREEN_WIDTH - UI_TILE_WIDTH / 2 - strengthbar_width, UI_TILE_HEIGHT / 2, strengthbar_width, UI_TILE_HEIGHT, color_red); if (tank_strength >= GAME_MAX_STRENGTH) meter_direction = -UI_STRENGTH_SPEED; if (tank_strength <= GAME_MIN_STRENGTH) meter_direction = UI_STRENGTH_SPEED; tank_strength += meter_direction; tank_strength = MAX(GAME_MIN_STRENGTH, tank_strength); tank_strength = MIN(GAME_MAX_STRENGTH, tank_strength); break; } image_draw( (GAME_WIDTH - 2) * UI_TILE_WIDTH, UI_Y_OFFSET, img_tank); image_draw( game_player.x * UI_TILE_WIDTH, game_player.y * UI_TILE_HEIGHT + UI_Y_OFFSET, img_soldier); screen_show_buffer(); } }
int main(){ printf("NEW GAME!\n\n"); volatile int old_game_state = 0; int doge = 0; //animation counter //buffer init stuff pixel_buffer = alt_up_pixel_buffer_dma_open_dev("/dev/pixel_buffer_dma"); char_buffer = alt_up_char_buffer_open_dev("/dev/char_drawer"); //phil's stuff master* m = master_init(); printf("NEW GAME!\n\n"); // Set the 1st buffer address alt_up_pixel_buffer_dma_change_back_buffer_address(pixel_buffer,pixel_buffer_addr1); // Swap buffers – we have to swap because there is only an API function // to set the address of the background buffer. alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer); while (alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer)); // Set the 2nd buffer address alt_up_pixel_buffer_dma_change_back_buffer_address(pixel_buffer,pixel_buffer_addr2); printf("NEW GAME!\n\n"); // Clear the screen alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 1); alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer); while (alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer)); alt_up_pixel_buffer_dma_clear_screen(pixel_buffer, 1); alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer); while (alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer)); alt_up_char_buffer_clear(char_buffer); //Write some text alt_up_char_buffer_string(char_buffer, "LOADING...", 0, 0); //load bitmap files title = read_bmp("title.bmp"); alt_up_char_buffer_string(char_buffer, "title.bmp", 0, 2); menu = read_bmp("menu.bmp"); alt_up_char_buffer_string(char_buffer, "MENU.BMP", 0, 3); selA = read_bmp("selA.bmp"); alt_up_char_buffer_string(char_buffer, "selA.bmp", 0, 4); selB = read_bmp("selB.bmp"); alt_up_char_buffer_string(char_buffer, "selB.bmp", 0, 5); selC = read_bmp("selC.bmp"); alt_up_char_buffer_string(char_buffer, "selC.bmp", 0, 6); dead = read_bmp("dead.bmp"); alt_up_char_buffer_string(char_buffer, "dead.bmp", 0, 7); bmp * b = read_bmp("para1.bmp"); alt_up_char_buffer_string(char_buffer, "para.bmp", 0, 8); bmp * doge0 = read_bmp("doge0.bmp"); alt_up_char_buffer_string(char_buffer, "doge0.bmp", 0, 9); bmp * doge1 = read_bmp("doge1.bmp"); alt_up_char_buffer_string(char_buffer, "doge1.bmp", 0, 10); bmp * doge2 = read_bmp("doge2.bmp"); alt_up_char_buffer_string(char_buffer, "doge2.bmp", 0, 11); bmp * doge3 = read_bmp("doge3.bmp"); alt_up_char_buffer_string(char_buffer, "doge3.bmp", 0, 12); bmp * flat = read_bmp("flat.bmp"); alt_up_char_buffer_string(char_buffer, "flat.bmp", 0, 13); bmp * coin = read_bmp("coin.bmp"); alt_up_char_buffer_string(char_buffer, "coin.bmp", 0, 14); bmp * spike = read_bmp("spike.bmp"); alt_up_char_buffer_string(char_buffer, "spike.bmp", 0, 15); bmp * box1 = read_bmp("box1.bmp"); alt_up_char_buffer_string(char_buffer, "box1.bmp", 0, 16); bmp * box3 = read_bmp("box3.bmp"); alt_up_char_buffer_string(char_buffer, "box3.bmp", 0, 17); bmp * low = read_bmp("low.bmp"); alt_up_char_buffer_string(char_buffer, "low.bmp", 0, 18); bmp * flatb = read_bmp("flatb.bmp"); alt_up_char_buffer_string(char_buffer, "flatb.bmp", 0, 19); bmp * flatr = read_bmp("flatr.bmp"); alt_up_char_buffer_string(char_buffer, "flatr.bmp", 0, 20); bmp * blue = read_bmp("bstar.bmp"); alt_up_char_buffer_string(char_buffer, "blue.bmp", 0, 21); bmp * red = read_bmp("rstar.bmp"); alt_up_char_buffer_string(char_buffer, "red.bmp", 0, 22); bmp * flag_img = read_bmp("flag.bmp"); alt_up_char_buffer_string(char_buffer, "flag.bmp", 0, 23); name = read_bmp("name.bmp"); alt_up_char_buffer_string(char_buffer, "name.bmp", 0, 24); instr = read_bmp("instr.bmp"); alt_up_char_buffer_string(char_buffer, "instr.bmp", 0, 25); dcol = read_bmp("dcol.bmp"); alt_up_char_buffer_string(char_buffer, "dcol.bmp", 0, 26); win = read_bmp("win.bmp"); alt_up_char_buffer_string(char_buffer, "win.bmp", 0,27); alt_up_char_buffer_clear(char_buffer); printf("NEW GAME!\n\n"); //interrupt init stuff (for object writing) //TIMERPERIOD int timer_period = 1 * 500000; IOWR_16DIRECT(TIMER_0_BASE, 8, timer_period & 0xFFFF); //writes the period to the hardware timer IOWR_16DIRECT(TIMER_0_BASE, 12, timer_period >> 16); IOWR_16DIRECT(TIMER_0_BASE, 4, 1 << 3); //stop timer alt_irq_register(TIMER_0_IRQ,NULL,(void*)handle_timer_interrupts);//registers function to a specific IRQ //IOWR_16DIRECT(TIMER_0_BASE, 4, 0x5); //start timer //SET UP KEYBOARD INTERRUPT// ps2 = alt_up_ps2_open_dev(KEYBOARD_NAME); alt_up_ps2_init(ps2); alt_up_ps2_clear_fifo(ps2); //void* keyboard_control_register_ptr = (void*) (PS2_0_BASE + 4); alt_irq_register(PS2_0_IRQ, m, keyboard_ISR); alt_up_ps2_enable_read_interrupt(ps2); char sw = 0; char p_sw = 0; ///////////////////////////////////////////////////////////////////////// printf("NEW GAME!\n\n"); //SUPERDUPERLOOP while (1){ printf("old state:%i\nnew state: %i\n\n",old_game_state, game_state); draw_menu(game_state); //update screen while (old_game_state == game_state); printf("old state:%i\nnew state: %i\n\n",old_game_state, game_state); //only when entering a new menu alt_up_char_buffer_clear(char_buffer); //ENTER GAME LOOP if (game_state == 5){ printf("START GAME! LEVEL: %i\n\n", highlighted_level); alt_up_char_buffer_string(char_buffer, playername, 10, 4); if (highlighted_level == 1) { free_bmp(b); b = read_bmp("para1.bmp"); game_start(m,b,"lvl/1.txt","song1.wav"); } else if (highlighted_level == 2) { free_bmp(b); b = read_bmp("bg2.bmp"); game_start(m,b,"lvl/2.txt","a/abcd.wav"); } else{ free_bmp(b); b = read_bmp("bg3.bmp"); game_start(m,b,"lvl/2.txt","a/nyan1.wav"); } //collision loop while(!m->c->collide && !m->c->win){ alt_up_char_buffer_string(char_buffer, "POINTS: ", 50, 4); char str[15]; sprintf(str, "%d", m->c->points); alt_up_char_buffer_string(char_buffer, str, 58, 4); sw = IORD_8DIRECT(SWITCHES_BASE,0); IOWR_8DIRECT(LEDS_BASE,0,sw); if(sw == 1 && p_sw == 0){ //m->ab->sfx_flag = 1; m->c->jump_pressed = 1; } p_sw = sw; //boxes int i; for( i= 0 ; i < OBJECT_SIZE ; i++) { if(m->o->color[i] == -1) draw_object(pixel_buffer, box, flat, i); else if(m->o->color[i] == 0) draw_object(pixel_buffer, box, flatb, i); else if(m->o->color[i] == 1) draw_object(pixel_buffer, box, flatr, i); draw_object(pixel_buffer, co, coin, i ); draw_object(pixel_buffer, spikes, spike, i); draw_object(pixel_buffer, box_3, box3, i); draw_object(pixel_buffer, box_1, box1, i); // if(m->color_gates->color[i] == 1) // draw_object(pixel_buffer,cgates, rgate,i); // else if (m->color_gates->color[i] == 0) // draw_object(pixel_buffer,cgates, bgate,i); } //draws the win flag draw_object(pixel_buffer, flag, flag_img, 0); //Draw Doge if (m->c->ducking) draw_bmp(pixel_buffer,m->c->x - m->c->width, m->c->y - m->c->height,low); else{ doge++; if(doge == 37) doge = 0; if( doge <9) draw_bmp(pixel_buffer,m->c->x - m->c->width, m->c->y - m->c->height,doge0); else if (doge <18) draw_bmp(pixel_buffer,m->c->x - m->c->width, m->c->y - m->c->height,doge1); else if (doge <27) draw_bmp(pixel_buffer,m->c->x - m->c->width, m->c->y - m->c->height,doge2); else draw_bmp(pixel_buffer,m->c->x - m->c->width, m->c->y - m->c->height,doge3); } //Draw Color Indicator if(m->c->color == 0) draw_bmp(pixel_buffer, m->c->x- m->c->width + 5, m->c->y - m->c->height - 10, blue); else draw_bmp(pixel_buffer,m->c->x- m->c->width + 5, m->c->y - m->c->height - 10, red); p_counter++; if(p_counter == 3){ p_shift++; alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer); while(alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer)) refill_buffer(m->ab, "a/abcd.wav");//refills the audio buffer unrolled_parallax_draw(pixel_buffer, b); }else if(p_counter == 4){ //if(p_counter == 1){ alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer); while(alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer)) refill_buffer(m->ab, "a/abcd.wav");//refills the audio buffer unrolled_parallax_draw(pixel_buffer, b); p_counter = 0; }else{ // alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer); // while(alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer)) // refill_buffer(m->ab, "a/abcd.wav");//refills the audio buffer // unrolled_parallax_draw(pixel_buffer, b); alt_up_pixel_buffer_dma_swap_buffers(pixel_buffer); while(alt_up_pixel_buffer_dma_check_swap_buffers_status(pixel_buffer)) refill_buffer(m->ab, "a/abcd.wav");//refills the audio buffer int j; for( j = 0 ; j < OBJECT_SIZE ; j++) { clear_object(pixel_buffer, box, b, j); clear_object(pixel_buffer, co, b, j); clear_object(pixel_buffer, spikes, b, j); clear_object(pixel_buffer, box_3, b, j); clear_object(pixel_buffer, box_1, b, j); } clear_object(pixel_buffer,flag,b,0); //clear doge clear_doge(pixel_buffer, m->c->x - m->c->width, m->c->y - m->c->height , b); //clear_loc(pixel_buffer,m->c->x- m->c->width + 5, m->c->y - m->c->height - 10,m->c->x- m->c->width + 5 - 10, m->c->y - m->c->height - 20,b); } } alt_up_char_buffer_string(char_buffer, "POINTS: ", 50, 4); char str[15]; sprintf(str, "%d", m->c->points); alt_up_char_buffer_string(char_buffer, str, 58, 4); printf("game exited\n"); if(m->c->win) game_state = 7; else game_state = 6; highlighted_item = 3; game_reset(m); } //exit game mode, restart superduperloop in main menu old_game_state = game_state; } return 0; }
void run() { gtk_widget_destroy(s_window); mine_map(2); game_reset(); }
void game_init() { game_reset(); }
int start() { gtk_container_remove(GTK_CONTAINER(window),vbox);//将原窗口内的所有构件移除,然后重新绘制。同时调用game_reset()使时间清0,地雷区雷数为初始值。 mine_map(LEVEL); game_reset(); }
void retro_reset(void) { game_reset(); }
static void on_game_new (void) { stop_anim (); game_reset (); }