void visual_init(t_general *gen) { if (!gen->visual) return ; start_graph(); gen->map = newwin(65, 193, 2, 4); gen->text = newwin(1, 1, 67, 256); gen->board = newwin(64, 52, 2, 200); refresh(); pc_color_up(gen); map_display(gen, 0, 1); initial_info(gen); wrefresh(gen->map); wrefresh(gen->board); }
void combat_move_to_area(Character *character) { int xx = -1, yy = -1, d = 1000; int x, y; int i, j; x = character->x / 4 - combat_x; y = character->y / 4 - combat_y; if (x < 0 || y < 0 || x >= COMBAT_WIDTH || y >= COMBAT_HEIGHT) { if (x < 0) x = 0; if (y < 0) y = 0; if (x >= COMBAT_WIDTH) x = COMBAT_WIDTH - 1; if (y >= COMBAT_HEIGHT) x = COMBAT_HEIGHT - 1; } else { if (combat_area[x][y] != 0 && combat_area[x][y] < 1000) return; } for (i = 0; i < COMBAT_WIDTH; ++i) for (j = 0; j < COMBAT_HEIGHT; ++j) if (combat_area[i][j] != 0 && combat_area[i][j] < 1000 && map_can_move_to(character, combat_x + i, combat_y + j) && abs(i - x) + abs(j - y) < d) { d = abs(i - x) + abs(j - y); xx = i; yy = j; } if (xx < 0) { character->x = game_get_leader()->x; character->y = game_get_leader()->y; } else { character->x = (combat_x + xx) * 4; character->y = (combat_y + yy) * 4; } map_character_update(character); /* we must do it, otherwise map_can_move_to() does not work */ map_display(0, 0); }
void multi_display(struct game* game) { assert(game); struct map* map = NULL; int w, h; int* scores; switch(game_get_state(game)) { case PLAYING: case PAUSED: game_display(game); if(player_get_nb_player_alive(game) == 1) multi_change_state(game, SCORE); break; case CHOOSE_MAP: map = level_get_curr_map(game_get_curr_level(game)); w = 10 + 15 + sprite_get_max_width() + 50 + SIZE_BLOC * map_get_width(map); h = max(30 * (sprite_get_nb_map_multi() + 1), SIZE_BLOC * map_get_height(map)); window_resize( w, h); window_clear(); for(int i = 0; i < sprite_get_nb_map_multi(); i++) { window_display_image( sprite_get_map_multi(i), 10 + 15, 15 + 30 * i); } window_display_image(sprite_get_menu(M_S_SELECT_BLACK), 10, 15 + 30 * game_get_pos(game)); map_display( map, 10 + 15 + sprite_get_max_width() + 50, (h-(SIZE_BLOC * map_get_height(map))) / 2); window_refresh(); break; case SCORE: window_clear(); level_display(game_get_curr_level(game)); bomb_display(game, level_get_curr_map(game_get_curr_level(game))); for(int i = 0; i < game_get_nb_player(game); i++) player_display(game_get_player(game, i+1)); int map_w = map_get_width(level_get_curr_map(game_get_curr_level(game))); int map_h = map_get_height(level_get_curr_map(game_get_curr_level(game))); int mid_w = map_w / 2 * SIZE_BLOC + map_w%2 * SIZE_BLOC / 2; int mid_h = map_h / 2 * SIZE_BLOC + map_h%2 * SIZE_BLOC / 2; window_display_image( sprite_get_menu(M_BG_GREY), mid_w - 240, mid_h - 262); window_display_image( sprite_get_score(player_get_id_player_alive(game)), mid_w - 200, mid_h - 222); scores = game_get_scores(game); for(int i = 0; i < game_get_nb_player(game); i++) { window_display_sprite( sprite_get_players(i+1), sprite_get_rect_player_anim(0, i+1, SOUTH), mid_w - 200, mid_h - 222 + 80 + 80 * i); window_display_image( sprite_get_number_white(scores[i]), mid_w - 140, mid_h - 222 + 100 + 80 * i); } window_refresh(); break; } }
void level_display(struct level* level) { map_display(level->maps[level->cur_map], 0, 0); }
int combat_frame() { if (!combat_mode) return 0; if (active_character->action != CHARACTER_STAY) { character_frame(active_character); map_display(0, 0); goto end_combat_frame; } if (gui_mode() == DIALOG_MESSAGE) { gui_frame(); if (gui_mode() != DIALOG_MESSAGE) { if (combat_who_attacked->life <= 0 && game_in_party(combat_who_attacked)) gui_player_dead(combat_who_attacked, 0); combat_character_finished(); } goto end_combat_frame; } if (combat_attack_animation) { combat_attack_animation = 0; /* message switches to next player */ gui_message(combat_result_text, 1); goto end_combat_frame; } if (game_in_party(active_character)) { if (gui_frame() != MAIN_MENU) goto end_combat_frame; if (game_get_moving()) combat_player_move(); } else { combat_enemy_move(); if (active_character->x < 0) goto end_combat_frame; } if (!combat_attack_animation && active_character->ap <= 0) combat_character_finished(); map_display(0, 0); end_combat_frame: map_animate_frame(); return combat_mode; }