void GameArea::initGame() { init_map(_cur_map, _row, _col); init_map(_copy_map, _row, _col); _cur_block = nullptr; _next_block = nullptr; _is_first_item = true; _over = false; _full_row = 0; drawArea(); _score = 0; }
int main(int argc, char ** argv) { struct map maps[NUM_MAPS] = {}, maps_compare[NUM_MAPS] = {}; int i, j, k; test_init(argc, argv); k = 0; for (i = 0; i < NUM_MPROTS; i++) for (j = 0; j < NUM_MFLAGS; j++) init_map(maps + k++, i, j); for (i = 0; i < NUM_MAPS; i++) if (make_map(maps + i)) goto err; test_daemon(); test_waitsig(); for (i = 0; i < NUM_MAPS; i++) if ((maps[i].prot_real=check_map(maps + i))<0) goto err; k=0; for (i = 0; i < NUM_MPROTS; i++) for (j = 0; j < NUM_MFLAGS; j++) init_map(maps_compare + k++, i, j); for (i = 0; i < NUM_MAPS; i++) if (make_map(maps_compare+ i)) goto err; for (i = 0; i < NUM_MAPS; i++) if ((maps_compare[i].prot_real=check_map(maps_compare + i))<0) goto err; for (i = 0; i< NUM_MAPS; i++) if (!check_prot(maps[i].prot_real, maps_compare[i].prot_real)){ fail("protection on %i (flag=%d prot=%d) maps has changed (prot=%d(expected %d))", i, maps[i].flag, maps[i].prot, maps[i].prot_real, maps_compare[i].prot_real); goto err; } pass(); for (i = 0; i < NUM_MAPS; i++) { destroy_map(maps + i); destroy_map(maps_compare + i); } return 0; err: return 1; }
/* * Construct top-level node */ void make_root_node(void) { mntfs *root_mnt; char *rootmap = ROOT_MAP; root_node = exported_ap_alloc(); /* * Allocate a new map */ init_map(root_node, ""); /* * Allocate a new mounted filesystem */ root_mnt = find_mntfs(&amfs_root_ops, (am_opts *) 0, "", rootmap, "", "", ""); /* * Replace the initial null reference */ free_mntfs(root_node->am_mnt); root_node->am_mnt = root_mnt; /* * Initialize the root */ if (root_mnt->mf_ops->fs_init) (*root_mnt->mf_ops->fs_init) (root_mnt); /* * Mount the root */ root_mnt->mf_error = root_mnt->mf_ops->mount_fs(root_node, root_mnt); }
void defense_game::init(game *g) { g->turn = HOURS(12); // Start at noon g->temperature = 65; g->u.create(g, PLTYPE_CUSTOM); g->u.str_cur = g->u.str_max; g->u.per_cur = g->u.per_max; g->u.int_cur = g->u.int_max; g->u.dex_cur = g->u.dex_max; init_itypes(g); init_mtypes(g); init_constructions(g); init_recipes(g); current_wave = 0; hunger = false; thirst = false; sleep = false; zombies = false; specials = false; spiders = false; triffids = false; robots = false; subspace = false; mercenaries = false; init_to_style(DEFENSE_EASY); setup(); g->u.cash = initial_cash; popup_nowait("Please wait as the map generates [ 0%]"); init_map(g); caravan(g); }
int file_reader(char *file, int ***map) { int fd; int ret; char *line; int i; if (!(init_map(map, file))) return (0); if (!test_file(file)) return (0); i = 0; fd = open(file, O_RDONLY); while ((ret = get_next_line(fd, &line)) > 0) { if (!((*map)[i] = line_filler(line, (*map)[i]))) return (0); ft_strdel(&line); i++; } if (!test_size(map)) return (0); close(fd); return ((ret < 0) ? 0 : 1); }
void check_env_map7(t_data *data) { if (data->map.end == 1) { init_main(data); init_text(data); init_map(data); init_inventory(data); bunny_delete_sound(&data->menu.menu_music->sound); init_menu(data); data->menu.menu_value = 1; } if ((data->mouse->x >= 13 && data->mouse->x <= 249) && (data->mouse->y >= 182 && data->mouse->y <= 367)) { if (data->player_pos != 0) position_handle(182, 330, data); else { load_map6(data); } } else check_env_map7_2(data); }
int main(void) { t_salle *h; t_init all; char *ptr; t_allp *all_path; t_stap st; if (get_next_line(0, &ptr) <= 0) return (0); all.nb_f = ((int)ft_strlen(ptr) <= 13) ? ft_atol(ptr) : -1; free(ptr); if (!(h = init_map(&all)) || all.nb_f <= 0 || all.nb_f >= 2147483648) exit_error("Error\n"); h = reverse_lst(h); st.start = find_flag(h, "start"); st.stop = find_flag(h, "end"); st.nb_room = salle_len(h); all_path = NULL; if (!search_all_path(st, &all_path, &h)) exit_error("Error\n"); reinit_nb_hall(&all_path); verif_bouchon(&all_path); tri_path(&all_path); affiche(all); pass_fourmis(h, all_path, all.nb_f, all.color); return (0); }
struct SimulationResult* run_simulation() { int rank = get_rank(); int num_processes = get_num_processes(); struct SimulationResult *result = 0; struct StepResult *last_result = 0; // only the master process collects the simulation results if(rank == 0) { result = malloc(sizeof(struct SimulationResult)); result->operations = 0; // set start time gettimeofday(&result->start_time, NULL); } init_map(); MPI_Barrier(MPI_COMM_WORLD); int i = 0; int died = 0; if(rank == 0) { printf("Start Population\n"); } died = get_stats(i, &last_result, result); while(i < MAX_SIMULATION_STEPS && !died) { i++; if(rank == 0) printf("Simulation Step %d\n", i); simulation_step(i); died = get_stats(i, &last_result, result); if(num_processes == 1) { print_bitmap(i); } } MPI_Barrier(MPI_COMM_WORLD); if(rank == 0) { gettimeofday(&result->finish_time, NULL); calc_runtime(result); } return result; }
bool defense_game::init(game *g) { g->turn = HOURS(12); // Start at noon g->temperature = 65; if (!g->u.create(g, PLTYPE_CUSTOM)) return false; g->u.str_cur = g->u.str_max; g->u.per_cur = g->u.per_max; g->u.int_cur = g->u.int_max; g->u.dex_cur = g->u.dex_max; init_itypes(g); init_mtypes(g); init_constructions(g); init_recipes(g); current_wave = 0; hunger = false; thirst = false; sleep = false; zombies = false; specials = false; spiders = false; triffids = false; robots = false; subspace = false; mercenaries = false; init_to_style(DEFENSE_EASY); setup(); g->u.cash = initial_cash; popup_nowait("Please wait as the map generates [ 0%]"); // TODO: support multiple defence games? clean up old defence game g->cur_om = &overmap_buffer.get(g, 0, 0); init_map(g); caravan(g); return true; }
int main(int ac, char **av) { t_data data; /* t_color color[2]; color[0].full = BLACK; color[1].full = RED;*/ if (ac != 2) return (-1); data.ini = av[1]; if (data.win == NULL) return (-1); if ((data.wolf = init_map(data.ini)) == (t_wolf *)-1) return (EXIT_ON_ERROR); data.win = bunny_start(1200, 800, false, "Wolf3D"); data.pix = bunny_new_pixelarray(1200, 800); data.color[0].argb[0] = 100; data.color[0].argb[1] = 100; data.color[0].argb[2] = 100; data.color[0].argb[3] = 255; init_value(data.wolf); bunny_set_loop_main_function((t_bunny_loop)main_loop); bunny_loop(data.win, 22, &data); bunny_free(data.wolf); bunny_delete_clipable(&data.pix->clipable); bunny_stop(data.win); return (0); }
int first_step(t_util *util) { int pid; util->id = 0; util->shm_id = shmget(util->key, (sizeof(char) * (MAP_X * MAP_Y)), IPC_CREAT | SHM_R | SHM_W); util->msg_id = msgget(util->key, IPC_CREAT | SHM_R | SHM_W); util->sem_id = semget(util->key, 1, IPC_CREAT | SHM_R | SHM_W); if (util->shm_id == -1 || util->msg_id == -1 || util->sem_id == -1) return (err_msg(": the creation of a shared memory fail")); util->addr = shmat(util->shm_id, NULL, SHM_R | SHM_W); init_map(util); semctl(util->sem_id, 0, SETVAL, 1); pid = fork(); if (pid != 0) { display(util->addr, init_sdl()); SDL_Quit(); return (1); } if (new_player(util) == -1) return (-1); return (1); }
static void imsmap_reshape (Display *dpy, Window window, void *closure, unsigned int w, unsigned int h) { struct state *st = (struct state *) closure; init_map (st); }
int ntk_load_maps(void) { if (file_exist(server_opt.int_map_file) && (me.int_map = load_map(server_opt.int_map_file, &me.cur_node))) debug(DBG_NORMAL, "Internal map loaded"); else me.int_map = init_map(0); #if 0 /* Don't load the bnode map, it's useless */ if ((me.bnode_map = load_bmap(server_opt.bnode_map_file, me.ext_map, FAMILY_LVLS, &me.bmap_nodes))) { debug(DBG_NORMAL, "Bnode map loaded"); } else #endif bmap_levels_init(BMAP_LEVELS(FAMILY_LVLS), &me.bnode_map, &me.bmap_nodes); bmap_counter_init(BMAP_LEVELS(FAMILY_LVLS), &me.bmap_nodes_closed, &me.bmap_nodes_opened); if (file_exist(server_opt.ext_map_file) && (me.ext_map = load_extmap(server_opt.ext_map_file, &me.cur_quadg))) debug(DBG_NORMAL, "External map loaded"); else me.ext_map = init_extmap(FAMILY_LVLS, 0); return 0; }
bool init_map(int count) { srand(time(NULL)); int seed = rand() % 100; for(int x = 0; x < X_SQUARES; x++) { for(int y = 0; y < Y_SQUARES; y++) { Uint8 c = scaled_octave_noise_3d(1,0.5,1,0x00,0xFF,x,y,seed); map[x][y].r = c; map[x][y].g = c; map[x][y].b = c; } } mutate_map(); mutate_map(); int max_count = colour_map(); float f_count = (float)(max_count); float total = (float)(X_SQUARES * Y_SQUARES); float coverage = f_count / total; printf("Threshold %d \n", threshold); printf("Coverage: %f / %f = %f \n", f_count, total, coverage); if(coverage < 0.25 && count < 10) init_map(count + 1); return true; }
int main() { Game game; // 游戏数据的结构体变量 // 初始化每位玩家的资金 init_money(&game); // 初始化玩家 init_players(&game); // 初始化地图 init_map(&game); // 初始化游戏中的其他数据 init_others(&game); // 输出地图 output_map(&game); // 以下为游戏主要流程,可根据需要修改代码 while (1) { // 此处写游戏主要流程 // 此处写判断游戏是否结束的代码,所用的函数自己定义 // 类似这样: // if (is_game_over(&game)) // { // break; // } } // 游戏所用资源的释放,如果使用了malloc函数分配内存,在这里调用free函数进行释放 return 0; }
t_env *init_env(char *filename) { t_env *e; if ((e = (t_env *)malloc(sizeof(t_env))) == NULL) error(1, 0, "Malloc struct environment!"); e->persp = init_persp(); if (filename != NULL) e->filename = ft_strdup(filename); else e->filename = NULL; e->map = init_map(e, filename); check_gates(e->map); e->width = (int)512 * 2.2; e->height = (int)512 * 1.7; e->mlx = mlx_init(); e->view = init_img(e, e->width, e->height); e->mmap = init_img(e, e->map->column * 4, e->map->line * 4); e->wall = init_texture(e, "greystone.xpm"); e->door = init_texture(e, "greystone_door.xpm"); e->sky = init_texture(e, "sky2.xpm"); e->win = mlx_new_window(e->mlx, e->width, e->height, "Wolf3D"); e->key.strafe = 0; e->init = 0; e->key.run = 0; e->key.turn = 0; return (e); }
// Map::create: Clears all map data and sets map name // ----------------------------------------------- >> void Map::create(string mapname) { name = mapname; lines = (linedef_t **)NULL; sides = (sidedef_t **)NULL; verts = (vertex_t **)NULL; sectors = (sector_t **)NULL; things = (thing_t **)NULL; if (scripts) delete scripts; if (behavior) delete behavior; scripts = new Lump(0, 0, "SCRIPTS"); behavior = new Lump(0, 0, "BEHAVIOR"); n_lines = n_sides = n_verts = n_sectors = n_things = 0; opened = true; changed = 255; init_map(); }
/* Constructeur */ controler::controler() { std::srand(time(NULL)); niveau = 0; init_map(); init_hero(); init_boss(NB_MECHANTS); }
int main(int argc, char** argv) { SDL_Surface* screen, *tileset; SDL_Event event; s_map *map; (void)argc; map = init_map(argv); SDL_Init(SDL_INIT_VIDEO); screen = SDL_SetVideoMode(LARGEUR_TILE * map->sizeX, \ HAUTEUR_TILE * map->sizeY, 32, SDL_HWSURFACE | SDL_DOUBLEBUF); tileset = SDL_LoadBMP("tileset1.bmp"); if (!tileset) { printf("Echec de chargement tileset1.bmp\n"); SDL_Quit(); exit(-1); } Afficher(screen, tileset, map); while (event.type!=SDL_KEYDOWN) SDL_WaitEvent(&event); SDL_FreeSurface(tileset); SDL_Quit(); free(map); return 0; }
int main(int ac, char **av) { t_args option; if (ac < 5) return (usage(av[0])); signal(SIGINT, &signal_handler); signal(SIGPIPE, SIG_IGN); srand(time(NULL) + getpid()); init_args(&option); if (check_args(ac, av, &option) == false || check_all_args(&option) == false) return (usage(av[0])); display_init(&option); g_s.global_time = 0; g_s.id_egg = 1; g_s.other_size = 0; if ((g_s.sock = init_server(option.port)) == -1) return (display_error("Error : Could not init the server.\n")); printf("**** Initialization done\n"); init_map(&g_s, option.width, option.height); init_team(&g_s, option.nb_client, option.team_name); init_stone(&g_s, option.width * option.height); g_s.option = &option; server_loop(&g_s); xclose(g_s.sock); return (0); }
Map::Map() { short Temp[10][15]={ {0},{0},{0},{0},{0}, {0},{0},{0},{0},{0}}; init_map(0, "",Temp,Temp,Temp,NULL,0, NULL, NULL); }
int main() { int **map; map = init_map(); display_map(map); return (0); }
// Initialise the software TICK_COUNT appInitSoftware(TICK_COUNT loopStart){ init_robot(); init_error_list(); init_map(); init_rct_set(); uartAttach(UART3, &lbRcv); return 0; }
int create_graph(FILE* input) { yylex_destroy(); __click_modules = alloc_resource(sizeof(List)); __click_symbol_table = alloc_resource(sizeof(Map)); __click_edges = alloc_resource(sizeof(List)); init_list(__click_modules); init_map(__click_symbol_table); init_list(__click_edges); yyset_in(input); int ret = yyparse(); yylex_destroy(); int k; for(k=0; k<__click_modules->len; k++) { Node* node = (Node*)__click_modules->list[k]; assert(node->type == Node_MODULE); Module* module = (Module*)node->payload; printf("%s::\t", module->name->payload); ArgList* arglist = (ArgList*)module->args->payload; int j; for(j=0; j<arglist->len; j++) { Node* eacharg = (Node*)arglist->list[j]; if(eacharg == NULL) { printf("NULL "); } else if(eacharg->type == Node_VALUE_LIST) { ValueList* valuelist = (ValueList*)eacharg->payload; int i; for(i=0; i<valuelist->len; i++) { Node* eachval = (Node*)valuelist->list[i]; printf("%s ", eachval->payload); } printf(", "); } else { assert(0); } } printf("\n"); } clear_resource(); __click_modules = 0; __click_symbol_table = 0; __click_edges = 0; return ret; }
int main() { int m, n; scanf("%d %d", &n, &m); init_map(map, n, m); show(map, n, m); return 0; }
static void * imsmap_init (Display *dpy, Window window) { struct state *st = (struct state *) calloc (1, sizeof(*st)); st->dpy = dpy; st->window = window; init_map (st); return st; }
void change_map(t_env *e, char *filename) { free_tab(e->map->mapget); free(e->map); e->map = init_map(e, filename); mlx_destroy_image(e->mlx, e->mmap->img); free(e->mmap); e->mmap = init_img(e, e->map->column * 4, e->map->line * 4); }
int main(void) { t_map *map; init_map(map); printf("map initialise\n"); ft_get_map(map); printf("map recupere !\n"); //launch_sequence(&map); return (0); }
static Bool imsmap_event (Display *dpy, Window window, void *closure, XEvent *event) { struct state *st = (struct state *) closure; if (screenhack_event_helper (dpy, window, event)) { init_map (st); return True; } return False; }
static int check_shm(key_t key, t_info *info) { if ((info->shm = shmget(key, SHM_SIZE, SHM_R | SHM_W)) < 0) { info->shm = shmget(key, SHM_SIZE, IPC_CREAT | SHM_R | SHM_W); info->share = (t_share*)shmat(info->shm, NULL, 0); info->share->nb_connect = 0; init_map(info); shmdt(info->share); } return (0); }