void Event::gen_level_campaign(int level, int boss, bool coop) { int tmpx = 0, tmpy = 0; int p_x = 2 + (rand() % (globject::mapX_size - 4)); int p_y = 2 + (rand() % (globject::mapY_size - 4)); boss = (boss > 0) ? 0 : 1; fill_border_map(); this->char_list.push_back(Factory::create_player(0, (float)p_x, (float)p_y, PLAYER1)); // change model if (coop == true) { p_x = 2 + (rand() % (globject::mapX_size - 4)); p_y = 2 + (rand() % (globject::mapY_size - 4)); while (check_coord(0, (float)p_x, (float)p_y) != true) { p_x = 2 + (rand() % (globject::mapX_size - 4)); p_y = 2 + (rand() % (globject::mapY_size - 4)); } this->char_list.push_back(Factory::create_player(0, (float)p_x, (float)p_y, PLAYER2)); // change model } int i = 0; while (i < (level % 3) + boss) { tmpx = 2 + (rand() % (globject::mapX_size - 4)); tmpy = 2 + (rand() % (globject::mapY_size - 4)); if (check_coord(0, (float)tmpx, (float)tmpy) == true) { if (boss == 1) this->char_list.push_back(Factory::create_boss(0, (float)tmpx, (float)tmpy, BOSS_A, BOSS_A)); // change model else this->char_list.push_back(Factory::create_enemy(0, (float)tmpx, (float)tmpy, ENEMY1)); // change model i++; } } gen_obstacle((level / 3)); }
int is_room(char *line) { char **info_room; info_room = NULL; if (!(ft_strchr(line, ' ')) || nb_space(line) != 1) return (0); info_room = ft_strsplit(line, ' '); if (!(check_nb_data(info_room))) { free_split(info_room); return (0); } if (!(check_name(info_room[0]))) { free_split(info_room); return (0); } if (!(check_coord(info_room[1])) || !(check_coord(info_room[2]))) { free_split(info_room); return (0); } free_split(info_room); return (1); }
void check_tetriminos(t_env *e) { valid_piece(e); check_coord(X); add_nb_tetri(&NB_TETRI, X); check_limit_tetri(NB_TETRI); add_width_and_save(NB_TETRI, &MAP_WIDTH, &MAP_WIDTH_SAVED); check_tetriminos_sharp(e); }
void Event::gen_level_arena(int level, int coop) { int i = 0, tmpx = 0, tmpy = 0; fill_border_map(); while (i < coop) { int p_x = 2 + (rand() % (globject::mapX_size - 4)); int p_y = 2 + (rand() % (globject::mapY_size - 4)); if (check_coord(0, (float)p_x, (float)p_y) == true) { this->char_list.push_back(Factory::create_player(0, (float)p_x, (float)p_y, PLAYER1 + i)); i++; } } tmpx = 2 + (rand() % (globject::mapX_size - 4)); tmpy = 2 + (rand() % (globject::mapY_size - 4)); while (check_coord(0, (float)tmpx, (float)tmpy) != true) { tmpx = 2 + (rand() % (globject::mapX_size - 4)); tmpy = 2 + (rand() % (globject::mapY_size - 4)); } this->char_list.push_back(Factory::create_boss(0, (float)tmpx, (float)tmpy, BOSS_A, BOSS_A)); gen_obstacle((level / 3)); }
void Event::gen_level_multi(int level, int coop) { int i = 0; fill_border_map(); while (i < coop) { int p_x = 2 + (rand() % (globject::mapX_size - 4)); int p_y = 2 + (rand() % (globject::mapY_size - 4)); if (check_coord(0, (float)p_x, (float)p_y) == true) { this->char_list.push_back(Factory::create_player(0, (float)p_x, (float)p_y, PLAYER1 + i)); // change model i++; } } gen_obstacle((level / 3)); }
void Event::gen_obstacle(int difficulty) { int block = ((globject::mapX_size - 2) * (globject::mapY_size - 2)); int tmpx = 0, tmpy = 0; while (block >= 0) { tmpx = 1 + (rand() % (globject::mapX_size - 2)); tmpy = 1 + (rand() % (globject::mapY_size - 2)); if (check_coord(1, (float)tmpx, (float)tmpy) == true) { delete this->map[tmpy][tmpx]; this->map[tmpy][tmpx] = NULL; if (rand() % 20 <= 2) this->map[tmpy][tmpx] = Factory::create_wall(WALL_INDESTRUCTIBLE, (float)tmpx, (float)tmpy, WALL_INDESTRUCTIBLE); else this->map[tmpy][tmpx] = Factory::create_wall(rand_range(WALL_HP_1, 1 + difficulty), (float)tmpx, (float)tmpy, WALL_HP_1); } block--; } }
void check_tetriminos_sharp(t_env *e) { int count; count = 0; X = 0; Y = 0; while (TETRI_TAB[X] != NULL) { while (TETRI_TAB[X][Y] != '\0') { if (TETRI_TAB[X][Y] == '#') count++; Y++; } check_coord(count); X++; } }
void solver(t_fill *fill) { fill->map_size = 2; while (fill->map_size * fill->map_size < fill->num_piece * 4) fill->map_size++; init_map(fill->map_size, fill->map); fill->piece = 0; while (fill->piece <= fill->num_piece) { if (check_place(fill->parsing[fill->piece], &fill->coord[fill->piece], fill->map)) { place(fill->parsing[fill->piece], &fill->coord[fill->piece], fill->map, 'A' + fill->piece); fill->piece++; } else if (check_coord(&fill->coord[fill->piece], fill->map_size)) update_coord(&fill->coord[fill->piece], fill->map_size); else solver_bis(fill); } }