void init_world_from_file(World * world, char * worldFileName) { FILE* file; file = fopen(worldFileName, "r"); if (file != NULL) { char* buffer = (char*) malloc(BUFFER_LENGTH * sizeof(char)); int line = 0; char type; int x; int y; FrameAnimator fa_castle; FrameAnimator fa_spawn; while (fgets(buffer, BUFFER_LENGTH, file)) { switch (line) { case 0: sscanf(buffer, "%i %i", &x, &y); init_world(world, x, y); break; case 1: sscanf(buffer, "%i %i", &x, &y); world->spawn->spawn_location.world_x = convert_tile2world_x(x); world->spawn->spawn_location.world_y = convert_tile2world_y(y); init_frameAnimator(&fa_spawn, 3, 9, 5, TILE_SIZE, TILE_SIZE); world->spawn->all.frameAnimator = fa_spawn; break; case 2: sscanf(buffer, "%i %i", &x, &y); world->castle->castle.world_x = convert_tile2world_x(x); world->castle->castle.world_y = convert_tile2world_y(y); init_frameAnimator(&fa_castle, 3, 36, 4, TILE_SIZE, TILE_SIZE); world->castle->all.frameAnimator = fa_castle; break; default: sscanf(buffer, "%c %i %i", &type, &x, &y); world->entities[x][y].obstacle.world_x = convert_tile2world_x(x); world->entities[x][y].obstacle.world_y = convert_tile2world_y(y); world->entities[x][y].type = OBSTACLE; world->entities[x][y].obstacle.type = OBSTACLE; if (type == 'W') { world->entities[x][y].obstacle.obstacle_type = WATER; } else if (type == 'M') { world->entities[x][y].obstacle.obstacle_type = MOUNTAIN; } } line++; } free(buffer); } else{ printf("File kan niet ingelezen worden!"); init_world(world, 0, 0); } }
int main(int argc, char * argv[]) { uint32_t generation = 0; init_gfx(); init_random(); run = true; init_world(); while(run) { SDL_Event sdl_ev; if (SDL_PollEvent(&sdl_ev) != 0) { if (sdl_ev.type == SDL_KEYDOWN) switch (sdl_ev.key.keysym.sym) { case SDLK_q: run = false; break; case SDLK_SPACE: pause = !pause; break; default: break; } } if (!pause) { draw(); SDL_Flip(surface); next_generation(); generation++; /* SDL_Delay(50); */ } } SDL_Quit(); return 0; }
void init_draw_coords (float clb_width_val) { /* Load the arrays containing the left and bottom coordinates of the clbs * * forming the FPGA. clb_width_val sets the width and height of a drawn * * clb. */ int i; if (!show_graphics) return; /* -nodisp was selected. */ clb_width = clb_width_val; pin_size = clb_width / (4. * pins_per_clb); pin_size = min (pin_size, clb_width / (4. * io_rat)); pin_size = min (pin_size, 0.3); x_clb_left[0] = 0.; for (i=1;i<=nx+1;i++) x_clb_left[i] = x_clb_left[i-1] + clb_width + chan_width_y[i-1] + 1.; y_clb_bottom[0] = 0.; for (i=1;i<=ny+1;i++) y_clb_bottom[i] = y_clb_bottom[i-1] + clb_width + chan_width_x[i-1] + 1.; init_world (0., y_clb_bottom[ny+1] + clb_width, x_clb_left[nx+1]+ clb_width, 0.); }
server_t * init_server() { server_t *server = calloc(1, sizeof(server_t)); server->clients = calloc(16, sizeof(client_conn_t)); server->client_count = 16; server->world = init_world(); server->sock = -1; return server; }
void GameScene::update(float dt) { for (Entity* d : decorations_) { d->update(dt); } for (Entity* p : platforms_) { p->update(dt); } for (Entity* g : goalflags_) { g->update(dt); } update_effects(dt); for (Entity* c : collectibles_) { c->update(dt); sf::FloatRect bbox(c->collision_area()); if (!c->animation().hidden() && bbox.Intersects(player_.collision_area())) { explode(c,true); collectsnd_.Play(); } } update_player(dt); bool out_of_bounds = true; for (Entity* p : platforms_) { if (vector_magnitude( p->position() - player_.position()) < 1000) { out_of_bounds = false; } } if (out_of_bounds) { init_world(); } update_camera(dt); }
int main(int argc, char *argv[]) { /* parse commandline returns filename index in argv */ /* create floorplan data structure */ gfp=fpCreate(argv[commandlineParse(argc,argv)]); if (gPostScript ) gGUI = 1 ; /* enable gui if post script required */ if (!gGUI ) gVerbose = 1 ; /* enable verbose if if gui is not enabled */ /* change random seed into current time */ srandom(time(NULL)); if (gGUI) { /* calculating world and drawing dimentions */ gWorldStep=MIN((880/((gfp->ny)*2)),(1000/((gfp->nx)+1))); /* grid step */ gWorldX =((gfp->nx)+1)*gWorldStep+240; /* world X dimension */ gWorldY =(gfp->ny)*2*gWorldStep+180 ; /* world Y dimension */ /* initialize display with WHITE 1000x1000 background */ init_graphics((char*)"Simulated-Annealing Cell-Based Placement Tool", WHITE, NULL); init_world (0.,0.,gWorldX,gWorldY); /* Create new buttons */ create_button ((char*)"Window" , (char*)"---1" , NULL ); /* Separator */ create_button ((char*)"---1" , (char*)"Enable PS", enablePS ); /* enable PS */ create_button ((char*)"Enable PS", (char*)"Disable PS", disablePS); /* disable PS */ create_button ((char*)"Disable PS", (char*)"Run 1" , run1 ); /* refresh every 1 temp */ create_button ((char*)"Run 1" , (char*)"Run 10" , run10 ); /* refresh every 10 temp */ create_button ((char*)"Run 10" , (char*)"Run 100" , run100 ); /* refresh every 100 temp */ create_button ((char*)"Run 100" , (char*)"Run 1000" , run1000 ); /* refresh every 1000 temp */ create_button ((char*)"Run 1000" , (char*)"Run All" , runAll ); /* refresh at end only */ } /* invoke simulated-annealing placement with designated parameters */ fpAnneal(gfp ,(gMoveTemp*(gfp->cellsN)^(4/3)) ,gInitTemp*(gfp->bbox) ,gCoolRate ,gFreezeTemp/(gfp->bbox/gfp->netsN) ); /* finished! wait still until 'Exit" is pressed */ if (gGUI) while(1) waitLoop(); /* free database */ fpDelete(gfp); return 1; }
int main(void) { t_global_data d; set_env(&d); create_renderer(&d); init_view(&d, &d.view); init_world(&d.world, 1000); SDL_ShowCursor(0); main_loop(&d); SDL_ShowCursor(1); return (0); }
int main(int argc , char **argv) { threshold = (int)(height * width / 5) ; init_world(); init_plants(); init_herbs(); init_carns(); //whilecount(); printf("gsw!\n"); exit(1); }
void Parrot_init(struct Parrot_Interp *interpreter) { if (!interpreter->world_inited) { /* global_setup.c:init_world sets up some vtable stuff. * It must only be called once. */ interpreter->world_inited = 1; init_world(interpreter); } }
void make_world(World* world, int width, int height, int num_cities, int seed) { /* Makes a new world struct world : Pointer to the world to create width : The width of the world height : The height of the world num_cities : The number of cities in the world seed : The random seed to use to select the cities */ // Random number generation mt19937::result_type rseed = seed; auto rgen = bind(uniform_real_distribution<>(0, 1), mt19937(rseed)); // Initialize the world init_world(world, width, height, num_cities); // Create a set to deal with uniqueness set<tuple<int, int>> coordinates; set<tuple<int, int>>::iterator it; pair<set<tuple<int, int>>::iterator,bool> ret; // Create some unique random cities for (int i=0; i<num_cities; i++) { while (true) { // Try to add a new set of coordinates tuple<int,int> coors((int)(rgen() * width), \ (int)(rgen() * height)); ret = coordinates.insert(coors); // Break if the city was added successfully if (ret.second) break; } } // Add those cities to the world { int i = 0; for (it=coordinates.begin(); it!=coordinates.end(); it++) { world->cities[i].x = get<0>(*it); world->cities[i].y = get<1>(*it); i++; } } }
/* Pointless Idea, it'd be cool to run a '###' across the grid, in such a way that it moved one block at a time, or something. */ int main(int argc, char **argv){ srandom(time(NULL)); //add options later ncurses_init(); atexit((void(*)(void))endwin); sigaction(SIGTERM, &interupt_act, NULL); world *w = init_world(term_rows, term_cols); randomize_grid(w); draw_world(w, stdscr); while(1){ wmove(stdscr, 0, 0); setup_initial_conditons(w, stdscr); run_life(w, stdscr); } }
void GameScene::init() { init_world(); bgm_.OpenFromFile("sound/gamebgm.wav"); collectsndbuf_.LoadFromFile("sound/collect.wav"); collectsnd_.SetBuffer(collectsndbuf_); bgm_.Play(); camera_position_ = rect_center(player_.bounding_box()); camera_target_ = camera_position_; camera_zoom_ = sf::Vector2f(0.5f,0.5f); camera_zoom_target_ = camera_zoom_; camera_zoom_lerp_ratio_ = 0.7; camera_pan_lerp_ratio_ = 0.9f; update_camera(1); }
WORLD* new_world( char *spr, int tile_index, int x, int y, int w, int h, int cw, int ch ) { WORLD *world; world = (WORLD *) malloc( sizeof(WORLD) ); if (world != NULL) init_world(world, spr, tile_index, x, y, w, h, cw, ch); return world; }
main() { int k; init_world(); init_curses(); draw_vmap(); // fskipc=0; do { //Keyboard loop if(pause==0) { evolv(); //k=fskipc/fskip; if ((fskipc%fskip)==0) { //fskipc=0; info_status(); draw_vmap(); } fskipc++; age++; } cho=getch(); } while(kbd()); finish_game(); return(0); }
static void drawInit( int sizex, int sizey, char* seqName, char* filename, float score) { int i,k=0; int x,y; char* c; c =(char*)malloc(sizeof(char)*1000); /* initialize display */ init_graphics("RNA"); /* still picture drawing allows user to zoom, etc. */ init_world (0.,0.,CELLSIZE*sizex,CELLSIZE*sizey); //event_loop(button_press, drawscreen); /* animation section */ clearscreen(); init_postscript(filename); clearscreen(); sprintf(c, "%s%s%s%d%s%f%s", "RNA: ", seqName, ", length = ", sizex, ", energy = ",-score/1000.0, " kal/mol"); //printf(" output string is %s\n",c); update_message("RNA secondary structure"); flushinput(); drawtext (sizex*CELLSIZE/2,sizey*CELLSIZE/10,c,1.0e6); flushinput(); setcolor (BLACK); setlinewidth(1); setlinestyle (SOLID); for (i=0;i<=sizex;i++) { drawline (i*CELLSIZE,(sizey/2-1)*CELLSIZE,i*CELLSIZE,CELLSIZE*sizey/2); flushinput(); } drawline(0,(sizey/2-1)*CELLSIZE, sizex*CELLSIZE, CELLSIZE*(sizey/2-1)); drawline(0,sizey*CELLSIZE/2, sizex*CELLSIZE, CELLSIZE*sizey/2); flushinput(); free(c); }
int main() { World world; init_world(&world); srand(time(NULL)); int i; for (i = 0; i < 10 + rand() % 10; i++) { new_bum(&world); } while (1){ printf("\e[2J \e[0;0f"); shit_out(&world, world.A); getchar(); next_turn(&world, world.A); if ((rand() % 100) > 70) { new_bum(&world); } } return 0; }
static int32_t genesis(struct output_writter *output, struct memory_allocator *allocator) { int32_t rtrn = 0; /* Allocate and initialize all the data structures needed by the genetic alorithm. */ rtrn = init_world(output, allocator); if(rtrn < 0) { output->write(ERROR, "Can't init world\n"); return (-1); } /* Create the first generation of organisms aka test cases. */ rtrn = create_first_generation(output, allocator); if(rtrn < 0) { output->write(ERROR, "Can't create first generation\n"); return (-1); } return (0); }
/*********************************************** main *********************************************** * arguments: infile : contains florplan details * * -help (or -h) : print command usage help * * -verbose (or -v) : enables verbose logging mode * * -postscript (or -p) : enables PostScript plotting * * -stepping (or -s) : choose stepping mode, should be followed by one of the following: * * wave (or w) : shows wave expansion (default) * * destination (or d) : shows routing of each destination * * net (or n) : shows routing of each net * * routeall (or r) : shows final routing result * ******************************************************************************************************/ int main(int argc, char *argv[]) { /* arguments parsing */ int argi; /* arguments index */ int fileNameArgInd=-1; /* file name argument index */ char psm,sm,tbm; for(argi=1;argi<argc;argi++) { /* check all argument */ if (argv[argi][0]=='-') { /* switch argument */ switch (tolower(argv[argi][1])) { /* consider first letter */ /* help */ case 'h': printf("Lee-Moore Shortest Path Maze Router\n"); printf("Usage:\n"); printf("\tmaze [OPTIONS] INFILE\n"); printf("Options:\n"); printf("\t-help (also -h): print this message\n"); printf("\t-verbose (also -v): verbose logging\n"); printf("\t-postscript (also -p): generate PostScript every step\n"); printf("\t-traceback (also -t): traceback mode, followed by one of the following\n"); printf("\t\tminturn (also m): avoid turns, try to keep same direction (default)\n"); printf("\t\tdirect (also d): use direct paths toward source\n"); printf("\t-stepping (also -s): stepping mode, followed by one of the following\n"); printf("\t\twave (also w): wave expansion (default)\n"); printf("\t\tdestination (also d): route one destination at once\n"); printf("\t\tnet (also n): route one net at once\n"); printf("\t\trouteall (also n): route all nets at once\n"); printf("\tinfile syntax:\n"); printf("\t\t<FLOORPLAN COORDINATES>\n"); printf("\t\t<BLOCKAGES#>\n"); printf("\t\t<BLOCKAGE 1 COORDINATE>\n"); printf("\t\t<BLOCKAGE 2 COORDINATE>\n"); printf("\t\t...\n"); printf("\t\t<BLOCKAGE b COORDINATE>\n"); printf("\t\t<NETS#>\n"); printf("\t\t<NET 1 TARGETS#> <DEST. 1 COORD.> ... <DEST. t1 COORD.>\n"); printf("\t\t...\n"); printf("\t\t<NET 2 TARGETS#> <DEST. 1 COORD.> ... <DEST. t2 COORD.>\n"); printf("\t\t<NET n TARGETS#> <DEST. 1 COORD.> ... <DEST. tm COORD.>\n"); printf("Examples:\n"); printf("\tmaze a.infile (using default options)\n"); printf("\tmaze a.infile -verbose -postscript -stepping destination\n"); printf("\tmaze a.infile -v -p -s d (same as above)\n"); printf("Report bugs to <*****@*****.**>\n"); return(1); /* verbose */ case 'v': verbose=1; /* set verbose */ break; /* PostScript mode */ case 'p': psEnable=1; /* enable ps creation */ break; /* stepping mode */ case 's': argi++; /* next argument */ if (argi>=argc) sm = 'X'; /* if index is out of range, exit */ else sm = toupper(argv[argi][0]); if ((sm!='W')&&(sm!='D')&&(sm!='N')&&(sm!='R')) { /* consider first letter */ printf("-E- stepping modes are: wave, destination, net, routeall! Exiting...\n"); exit(-1); } else steppingMode=sm; break; /* traceback mode */ case 't': argi++; /* next argument */ if (argi>=argc) tbm = 'X'; /* if index is out of range, exit */ else tbm = toupper(argv[argi][0]); if ((tbm!='M')&&(tbm!='D')) { /* consider first letter */ printf("-E- traceback modes are: minturn, direct! Exiting...\n"); exit(-1); } else tracebackMode=tbm; break; /* unknown argument */ default : printf("-E- unknown argument %s\n",argv[argi]); exit(-1); } /* switch */ } else fileNameArgInd = argi; /* file name argument index */ } /* check if infile is supplied */ if (fileNameArgInd<0) {printf(" -E- infile should be supplied\n"); exit(-1);} /* parse input file into floorplan database */ gfp = fpInfileParse(argv[fileNameArgInd]); /* initialize display with WHITE 1000x1000 background */ init_graphics((char*)"Lee-Moore Shortest Path Maze Router", WHITE, NULL); init_world (0.,0.,1000.,1000.); /* Create new buttons */ create_button ((char*)"Window" , (char*)"---1" , NULL ); /* Separator */ create_button ((char*)"---1" , (char*)"Wave Mode" , waveModeFunc); /* Show wave expansion */ create_button ((char*)"Wave Mode" , (char*)"Dest. Mode", destModeFunc); /* route each destination */ create_button ((char*)"Dest. Mode", (char*)"Wire Mode" , wireModeFunc); /* route each wire */ create_button ((char*)"Wire Mode" , (char*)"Route All" , routeAllFunc); /* route all at once */ /* update global message and wait for 'Proceed' to proceed */ strcpy(glabel,"Initial floorplan. Choose stepping mode then press 'Proceed' to make one step."); waitLoop(); if (psEnable) postscript(drawScreen); /* route all pins in floorplan */ fpRouteAll(gfp); /* finished! wait still until 'Exit" is pressed */ while(1) waitLoop(); /* free database */ fpDelete(gfp); }
// IRQ1 interrupt handler sets keys buffer for this function to read void handle_key(uint8_t key) { hit info; // If the highest bit is not set, this key has not changed if (!(keys[key] & 0x80)) { return; } bool down = keys[key] & 1; // Mark key state as read keys[key] &= 1; switch (key) { // View case KEY_UP: dPitch += down ? 1.0f : -1.0f; break; case KEY_DOWN: dPitch += down ? -1.0f : 1.0f; break; case KEY_LEFT: dYaw += down ? 1.0f : -1.0f; break; case KEY_RIGHT: dYaw += down ? -1.0f : 1.0f; break; case KEY_SPACE: if (down) { playerPos.y += 0.1f; velocity.y += 8.0f; } break; // Check if a block was hit and place a new block next to it case KEY_Q: if (!down) { raytrace(playerPos, ray_dir(160, 100), &info); if (info.hit) { int bx = info.x + info.nx; int by = info.y + info.ny; int bz = info.z + info.nz; if (IN_WORLD(bx, by, bz)) { set_block(bx, by, bz, BLOCK_DIRT); } } } break; // Check if a block was hit and remove it case KEY_E: if (!down) { raytrace(playerPos, ray_dir(160, 100), &info); if (info.hit) { set_block(info.x, info.y, info.z, BLOCK_AIR); } } break; case KEY_ESC: init_world(); break; } // Make sure view look speed doesn't add up with low framerates if (dPitch != 0.0f) dPitch /= absf(dPitch); if (dYaw != 0.0f) dYaw /= absf(dYaw); }
int main(int argc, char *argv[]) { int continuing = 0; int count; int scores_only = 0; int i; #ifndef NOGETOPT while(( i= getopt( argc, argv, "dsh")) != -1) { switch (i) { case 'd': #ifdef DEBUG DG_debug_flag++; #endif break; case 's': scores_only = 1; break; case 'h': #ifdef DEBUG printf("Usage: omega [-shd] [savefile]\n"); #else printf("Usage: omega [-sh] [savefile]\n"); #endif printf("Options:\n"); printf(" -s Display high score list\n"); printf(" -h Display this message\n"); #ifdef DEBUG printf(" -d Enable debug mode\n"); #endif exit(0); break; case '?': /* error parsing args... ignore? */ printf("'%c' is an invalid option, ignoring\n", optopt ); break; } } if (optind >= argc ) { /* no save file given */ #if defined( BSD ) || defined( SYSV ) sprintf( SaveFileName, "Omega%d", getuid() ); #else strcpy( SaveFileName,"Omega"); #endif } else { /* savefile given */ continuing = 1; strcpy(SaveFileName,argv[optind]); } #else /* alternate code for people who don't support getopt() -- no enhancement */ if (argc ==2) { strcpy( SaveFileName, argv[1]); continuing = 1; } else { strcpy( SaveFileName,"Omega"); } #endif /* always catch ^c and hang-up signals */ #ifdef SIGINT signal(SIGINT,signalquit); #endif #ifdef SIGHUP signal(SIGHUP,signalsave); #endif #ifndef MSDOS if (CATCH_SIGNALS) { signal(SIGQUIT,signalexit); signal(SIGILL,signalexit); #ifdef DEBUG if( DG_debug_flag ) { #endif signal(SIGTRAP,signalexit); signal(SIGFPE,signalexit); signal(SIGSEGV,signalexit); #ifdef DEBUG } #endif #ifdef SIGIOT signal(SIGIOT,signalexit); #endif #ifdef SIGABRT signal(SIGABRT,signalexit); #endif #ifdef SIGEMT signal(SIGEMT,signalexit); #endif #ifdef SIGBUS signal(SIGBUS,signalexit); #endif #ifdef SIGSYS signal(SIGSYS,signalexit); #endif } #endif #ifndef FIXED_OMEGALIB if (!(Omegalib = getenv("OMEGALIB"))) #endif Omegalib = OMEGALIB; /* if filecheck is 0, some necessary data files are missing */ if (filecheck() == 0) exit(0); /* all kinds of initialization */ init_perms(); initgraf(); #ifndef MSDOS_SUPPORTED_ANTIQUE initdirs(); #endif initrand(E_RANDOM, 0); initspells(); #ifdef DEBUG /* initialize debug log file */ DG_debug_log = fopen( "/tmp/omega_dbg_log", "a" ); assert( DG_debug_log ); /* WDT :) */ setvbuf( DG_debug_log, NULL, _IOLBF, 0); fprintf(DG_debug_log, "############## new game started ##############\n"); #endif for (count = 0; count < STRING_BUFFER_SIZE; count++) strcpy(Stringbuffer[count],"<nothing>"); #ifdef SAVE_LEVELS msdos_init(); #endif omega_title(); showscores(); if (scores_only ) { endgraf(); exit(0); } /* game restore attempts to restore game if there is an argument */ if (continuing) { game_restore(SaveFileName); mprint("Your adventure continues...."); } else { /* monsters initialized in game_restore if game is being restored */ /* items initialized in game_restore if game is being restored */ inititem(TRUE); Date = random_range(360); Phase = random_range(24); #ifdef NEW_BANK bank_init(); #else strcpy(Password,""); #endif continuing = initplayer(); /* RM: 04-19-2000 loading patch */ } if (!continuing) { init_world(); /* RM: 04-19-2000 loading patch */ mprint("'?' for help or commandlist, 'Q' to quit."); } timeprint(); calc_melee(); if (Current_Environment != E_COUNTRYSIDE) showroom(Level->site[Player.x][Player.y].roomnumber); else terrain_check(FALSE); if (optionp(SHOW_COLOUR)) colour_on(); else colour_off(); screencheck(Player.x,Player.y); /* game cycle */ if (!continuing) time_clock(TRUE); while (TRUE) { if (Current_Environment == E_COUNTRYSIDE) p_country_process(); else time_clock(FALSE); } }
int main(int argc, char * argv[]) { WINDOW * win = init_screen(); #ifdef ENABLE_CURSOR MEVENT event; #endif /* predefined patterns */ struct pattern patterns[] = { {3, 3, (uint8_t *) start}, {3, 3, (uint8_t *) glider}, {5, 4, (uint8_t *) segler}, {3, 7, (uint8_t *) buffer}, {8, 4, (uint8_t *) kreuz}, {6, 6, (uint8_t *) ship} }; struct cursor cur = {0, 0}; struct config cfg; int generation = 0, input, framerate = 17; uint8_t width, height; uint8_t ** worlds[2], ** world; #if defined(RANDOM_SPAWNS) int idle_gens = 0; srand(time(NULL)); #endif memset(&cfg, '\0', sizeof(struct config)); /* initialize world */ world = init_world(win, worlds, &width, &height); /* make the world real */ inhabit_world(patterns[3], width/2, height/2, worlds[0], width, height); /* simulation loop */ while(!cfg.quit) { if (!cfg.paused) { /* calc next generation */ usleep(1 / (float) framerate * 1000000); /* sleep */ calc_next_gen(world, worlds[++generation % 2], width, height); world = worlds[generation % 2]; /* new world */ } /* handle events */ switch (input = getch()) { #ifdef ENABLE_HOTKEYS case '+': /* increase framerate */ framerate++; break; case '-': /* decrease framerate */ if (framerate > 1) framerate--; break; case 'q': /* quit */ cfg.quit = 1; break; #if defined(RANDOM_SPAWNS) case 'd': /* disable random spawn */ rnd_spawns = ~rnd_spawns; break; #endif case 'p': /* pause */ cfg.paused ^= 1; break; case 'c': /* clean world */ clean_world(world, width, height); generation = 0; break; #endif #if defined(ENABLE_HOTKEYS) || defined(ENABLE_CURSOR) case '0': /* insert pattern */ case '1': case '2': case '3': case '4': case '5': inhabit_world(patterns[input - '0'], cur.x, cur.y, world, width, height); break; #endif #ifdef ENABLE_CURSOR case ' ': /* toggle cell at cursor position */ world[cur.x][cur.y] = (world[cur.x][cur.y]) ? 0 : 1; break; case KEY_MOUSE: /* move cursor to mouse posititon */ if (getmouse(&event) == OK && event.bstate & BUTTON1_PRESSED) { cur.x = event.x; cur.y = event.y; if (cur.x >= width) cur.x = width - 1; if (cur.y >= height) cur.y = height - 1; world[cur.x][cur.y] = (world[cur.x][cur.y]) ? 0 : 1; } break; case KEY_UP: if (cur.y > 0) { cur.y--; } break; case KEY_DOWN: if (cur.y < height-1) { cur.y++; } break; case KEY_LEFT: if (cur.x > 0) { cur.x--; } break; case KEY_RIGHT: if (cur.x < width-1) { cur.x++; } break; case KEY_RESIZE: world = resized(win, worlds, &width, &height); break; #endif } #if defined(RANDOM_SPAWNS) if (rnd_spawns) { /* spawn a new pattern at a random position, if nothing happens */ idle_gens++; if (idle_gens >= RANDOM_SPAWNS && !cfg.paused) { idle_gens = 0; inhabit_world(patterns[rand() % (sizeof(patterns)/sizeof(patterns[0]))], rand() % (width - 1), rand() % (height - 1), world, width, height); } } #endif /* update screen */ print_world(world, width, height); #ifdef ENABLE_CURSOR print_cursor(world, cur); #endif #ifdef ENABLE_STATUS attron(COLOR_PAIR(1)); for (int i = 0; i < width; i++) mvprintw(0, width - i, " "); mvprintw(0, 0, "[generation:%4d] [cells:%3d] [fps:%2d] [width:%d] [height:%d] [cursor:%2d|%2d]", generation, calc_cell_count(world, width, height), framerate, width, height, cur.x, cur.y); if (cfg .paused) mvprintw(0, width-6, "PAUSED"); attroff(COLOR_PAIR(1)); #endif #ifdef ENABLE_HOTKEYS if (cfg.paused) { print_menu(width, height); usleep(1); } #endif refresh(); } free_all(worlds, width, height); delwin(win); endwin(); /* exit ncurses mode */ return (EXIT_SUCCESS); }
int main() { int i; struct VEngine veng; struct World world; JoyState* joy; v_init(&veng); joy_init(); /* for a random seed, wait for user input */ i = 0; while (1) { vid_vsync(); key_poll(); v_putbgtile(5, 4, 37); v_putbgtile(6, 4, 48); v_putbgtile(7, 4, 51); v_putbgtile(8, 4, 51); v_putbgtile(9, 4, 51); if (key_hit(KEY_A) || key_hit(KEY_START)) { break; } i ++; } /* sqran(i); */ sqran(4); init_world(&world, &veng); /* obj_set_pos(dude, (16 * 7), (16 * 4)); */ v_draw_bg(world.map, &veng, world.map->dudex, world.map->dudey); while(1) { vid_vsync(); joy = joy_poll(); key_poll(); if (key_hit(KEY_A)) { /* v_draw_more_bg(world.map, veng.mapofsx, veng.mapofsy - 4, 15, 4, world.map->dudex - 6 - veng.dudeposx, world.map->dudey - 4 - 4 - veng.dudeposy); */ } if (key_hit(KEY_START)) { v_init(&veng); init_world(&world, &veng); /* obj_set_pos(veng.obj_buffer[veng.spr_dude], (16 * 7), (16 * 4)); */ v_draw_bg(world.map, &veng, world.map->dudex, world.map->dudey); } /* if (key_hit(KEY_LEFT)) { switch (r_move_left(&world)) { case 1: v_move_left(&veng); break; case 2: v_shake_dude(&veng, 1, 0); break; } } else if (key_hit(KEY_RIGHT)) { switch (r_move_right(&world)) { case 1: v_move_right(&veng); break; case 2: v_shake_dude(&veng, 1, 0); break; } } else if (key_hit(KEY_UP)) { switch (r_move_up(&world)) { case 1: v_move_up(&veng); break; case 2: v_shake_dude(&veng, 0, 1); break; } } else if (key_hit(KEY_DOWN)) { switch (r_move_down(&world)) { case 1: v_move_down(&veng); break; case 2: v_shake_dude(&veng, 0, 1); break; } } */ if (joy->moving) { switch (r_move(&world, joy->dx, joy->dy)) { case 1: v_move(&veng, joy->dx, joy->dy); break; case 2: v_shake_dude(&veng, 0, 1); break; } joy_handled(); } v_move_co(&veng); v_scroll_at_edge(&veng, &world); v_draw_dude(&veng); for (i = 0; i < world.monstercount; i ++) { v_draw_monster(&veng, &world, i); } oam_copy(oam_mem, veng.obj_buffer, 1 + world.monstercount); } return 0; }
void GameScene::player_handle_keydown(sf::Key::Code code) { if (code == sf::Key::R) { init_world(); return; } if (player_.state_machine().state_with_direction_switching(player_.state())) { if (code == player_keys_.left.key) { player_.switch_direction(Player::Left); } else if (code == player_keys_.right.key) { player_.switch_direction(Player::Right); } } if (player_.state() == PlayerState::Idle) { if (code == player_keys_.left.key || code == player_keys_.right.key) { player_.switch_to_state(PlayerState::Moving); } } if (player_.state_machine().state_allowing_aiming(player_.state())) { if (code == player_keys_.up.key) { player_.set_aim_movement(Player::Up); player_.begin_aim_movement(); } else if (code == player_keys_.down.key) { player_.set_aim_movement(Player::Down); player_.begin_aim_movement(); } } if (player_.state_machine().state_allowing_launching(player_.state())) { if (code == player_keys_.action.key) { player_.switch_to_state(PlayerState::Launching); } } if (code == player_keys_.left.key) { player_keys_.left.held = true; } else if (code == player_keys_.right.key) { player_keys_.right.held = true; } else if (code == player_keys_.up.key) { player_keys_.up.held = true; } else if (code == player_keys_.down.key) { player_keys_.down.held = true; } else if (code == player_keys_.action.key) { player_keys_.action.held = true; } }
bool teo_task_template(teo_moveit::teo_task_template_srv::Request &req, teo_moveit::teo_task_template_srv::Response &res) { ros::NodeHandle nh; //Define world ros::Publisher pub_co = nh.advertise<moveit_msgs::CollisionObject>("collision_object", 10); //Define de srv we will want to use ros::ServiceClient move_group_client = nh.serviceClient<teo_moveit::move_group_srv>("move_group_srv"); ros::ServiceClient pick_client = nh.serviceClient<teo_moveit::pick_srv>("pick_srv"); ros::ServiceClient place_client = nh.serviceClient<teo_moveit::place_srv>("place_srv"); //srv variables teo_moveit::move_group_srv mg_srv; teo_moveit::pick_srv pick_srv; teo_moveit::place_srv place_srv; //init the environment, we can modify init_world in worlds.h to init different environments from a parameter. moveit_msgs::CollisionObject co; init_world(pub_co, co, req.param_array[0].world); ros::WallDuration(10.0).sleep(); //We define a loop with the number of servers we want to execute int i=0; ROS_INFO("Yeah received something thing!!"); while(i<req.param_array.size()){ //A "0" in an array means we want to do a move group task if(req.param_array[i].task==0){ ROS_INFO("Yeah i know its a movegroup TASK!"); //we call services for move_group mg_srv.request.group_name=req.param_array[i].group_name; mg_srv.request.p=req.param_array[i].p; mg_srv.request.pos_tolerance= req.param_array[i].pos_tolerance; mg_srv.request.ang_tolerance= req.param_array[i].ang_tolerance; //We call the service, and make sure it worked if (move_group_client.call(mg_srv)) { ROS_INFO("It should have move (0u0*)"); } else { ROS_ERROR("Failed to call service (o-o^)"); break; } } //A "1" in an array means we want to do a pick task if(req.param_array[i].task==1){ //We call the service to pick the object pick_srv.request.group_name=req.param_array[i].group_name; pick_srv.request.pick_object=co; //We call the service, and make sure it worked if (pick_client.call(pick_srv)) { ROS_INFO("It should have pick the object (0u0)*"); } else { ROS_ERROR("Failed to call service (o-o^)"); break; } } //A "2" in an array means we want to do a place task if(req.param_array[i].task==2){ //We call the service to pick the object place_srv.request.group_name=req.param_array[i].group_name; place_srv.request.place_object=co; //We call the service, and make sure it worked if (place_client.call(place_srv)) { ROS_INFO("It should have pick the object (0u0*)"); } else { ROS_ERROR("Failed to call service (o-o^)"); break; } } i++; ros::WallDuration(10.0).sleep(); } return true; }
bool objects_init(Map_Settings mSettings) { // Load_Menu_Textures(); SDL_ShowCursor(false); char szfm1path[256]; char szobjpath[256]; char sztexpath[256]; /* chemins vers les objets 3D */ strcpy(szobjpath, g_exepath); strcat(szobjpath, "objects"PATHDELIM_S); /* chemins vers les textures */ strcpy(sztexpath, g_exepath); strcat(sztexpath, "textures"PATHDELIM_S); /* chargement d'un objet Graine */ g_ObjsSeed = new C3DObjElements ; strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"seed.fm1"); if (!C3DObjLoader::Load3d(szfm1path,&g_ObjsSeed->m_hiRes, AnimNameUID, ObjNameUID)) return false; g_ObjsSeed->m_hiRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, &g_matDefault); g_ObjsSeed->m_lowRes = 0 ; /* chargement d'un objet Fourmi Récolteuse générique */ g_ObjsHarvester = new C3DObjElements; strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"minor.fm1"); if (!C3DObjLoader::Load3d(szfm1patPATHDELIMh,&g_ObjsHarvester->m_hiRes, AnimNameUID, ObjNameUID)) return false; g_ObjsHarvester->m_hiRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, &g_matSeed); /* chargement d'un objet Fourmi Récolteuse générique */ strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"minor-lowres.fm1"); if (!C3DObjLoader::Load3d(szfm1path,&g_ObjsHarvester->m_lowRes, AnimNameUID, ObjNameUID)) return false; g_ObjsHarvester->m_lowRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, NULL); /* chargement d'un objet Herbe Type 1 */ g_ObjsWeed1 = new C3DObjElements; strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"weed1.fm1"); if (!C3DObjLoader::Load3d(szfm1path,&g_ObjsWeed1->m_hiRes, AnimNameUID, ObjNameUID)) return false; g_ObjsWeed1->m_hiRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, NULL); g_ObjsWeed1->m_lowRes = NULL; /* chargement d'un objet Herbe Type 2 */ g_ObjsWeed2 = new C3DObjElements; strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"weed2.fm1"); if (!C3DObjLoader::Load3d(szfm1path,&g_ObjsWeed2->m_hiRes, AnimNameUID, ObjNameUID)) return false; g_ObjsWeed2->m_hiRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, NULL); g_ObjsWeed2->m_lowRes = NULL; /* chargement d'un objet Champignon*/ g_ObjsMushroom = new C3DObjElements; strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"mushroom.fm1"); if (!C3DObjLoader::Load3d(szfm1path,&g_ObjsMushroom->m_hiRes, AnimNameUID, ObjNameUID)) return false; g_ObjsMushroom->m_hiRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, NULL); g_ObjsMushroom->m_lowRes = NULL; /* chargement d'un objet Fleur Rouge*/ g_ObjsRedFlower = new C3DObjElements; strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"redflower.fm1"); if (!C3DObjLoader::Load3d(szfm1path,&g_ObjsRedFlower->m_hiRes, AnimNameUID, ObjNameUID)) return false; g_ObjsRedFlower->m_hiRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, NULL); g_ObjsRedFlower->m_lowRes = NULL; /* chargement d'un objet Araignée*/ g_ObjsSpider = new C3DObjElements; strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"spider.fm1"); if (!C3DObjLoader::Load3d(szfm1path,&g_ObjsSpider->m_hiRes, AnimNameUID, ObjNameUID)) return false; g_ObjsSpider->m_hiRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, NULL); g_ObjsSpider->m_lowRes = NULL; /* chargement d'un objet Major*/ g_ObjsMajor = new C3DObjElements; strcpy(szfm1path, g_exepath); strcat(szfm1path, "objects"PATHDELIM_S"major.fm1"); if (!C3DObjLoader::Load3d(szfm1path,&g_ObjsMajor->m_hiRes, AnimNameUID, ObjNameUID)) return false; g_ObjsMajor->m_hiRes->Load(szobjpath, sztexpath, true, &g_textures_list, &g_objects_list, NULL); g_ObjsMajor->m_lowRes = NULL; //g_ObjsMajor->m_hiRes->SelectDefaultAnimation(ANIMATION_WALK_UID); //g_ObjsMajor->m_hiRes->ChangeFrameRateRatio(4); /* CVector3f grav (0,-0.8f,0); CVector3f randplan (0.0f, 0.0f, 0.0f); CVector3f randspeed (0.3f, 0.8f, 0.4f);*/ /*g_ObjsMajor->m_hiRes->InitParticleSystem(OBJECT_SHOOTPARTICLE_UID, 20.0f, 20, 5.0f, 1.0f, 0.3f, 1.0f, 0.3f, 0.8f, false,0, 0.5f,0.5f, grav, randplan, randspeed, NULL,NULL); g_ObjsMajor->m_hiRes->Reset();*/ //g_ObjsMajor->m_hiRes->StartParticleSystem(); init_world(world,"AI_test.wld", mSettings); // minor.load3d(); /* initialisation des objets par copie */ /* g_ObjGraine = new C3DObjElement; *(g_ObjGraine) = *(ObjGraine); g_ObjGraine->ChangeFrameRateRatio(10.0); g_ObjFourmi1 = new C3DObjElement; *(g_ObjFourmi1) = *(ObjOuvriere); g_ObjFourmi1->ChangeFrameRateRatio(40.0); g_ObjFourmi1->SelectDefaultAnimation(ANIMATION_STAY_UID); g_ObjFourmi1->RandomAnimationStart(ANIMATION_STAY_UID); g_ObjFourmi2 = new C3DObjElement; *(g_ObjFourmi2) = *(ObjOuvriere); g_ObjFourmi2->ChangeFrameRateRatio(10.0); g_ObjFourmi2->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi2->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi3 = new C3DObjElement; *(g_ObjFourmi3) = *(ObjOuvriere); g_ObjFourmi3->ChangeFrameRateRatio(10.0); g_ObjFourmi3->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi3->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi4 = new C3DObjElement; *(g_ObjFourmi4) = *(ObjOuvriere); g_ObjFourmi4->ChangeFrameRateRatio(10.0); g_ObjFourmi4->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi4->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi5 = new C3DObjElement; *(g_ObjFourmi5) = *(ObjOuvriere); g_ObjFourmi5->ChangeFrameRateRatio(10.0); g_ObjFourmi5->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi5->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi6 = new C3DObjElement; *(g_ObjFourmi6) = *(ObjOuvriere); g_ObjFourmi6->ChangeFrameRateRatio(10.0); g_ObjFourmi6->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi6->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi7 = new C3DObjElement; *(g_ObjFourmi7) = *(ObjOuvriere); g_ObjFourmi7->ChangeFrameRateRatio(10.0); g_ObjFourmi7->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi7->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi8 = new C3DObjElement; *(g_ObjFourmi8) = *(ObjOuvriere); g_ObjFourmi8->ChangeFrameRateRatio(10.0); g_ObjFourmi8->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi8->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi9 = new C3DObjElement; *(g_ObjFourmi9) = *(ObjOuvriere); g_ObjFourmi9->ChangeFrameRateRatio(10.0); g_ObjFourmi9->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi9->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi10 = new C3DObjElement; *(g_ObjFourmi10) = *(ObjOuvriere); g_ObjFourmi10->ChangeFrameRateRatio(10.0); g_ObjFourmi10->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi10->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi11 = new C3DObjElement; *(g_ObjFourmi11) = *(ObjOuvriere); g_ObjFourmi11->ChangeFrameRateRatio(10.0); g_ObjFourmi11->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi11->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi12 = new C3DObjElement; *(g_ObjFourmi12) = *(ObjOuvriere); g_ObjFourmi12->ChangeFrameRateRatio(10.0); g_ObjFourmi12->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi12->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi13 = new C3DObjElement; *(g_ObjFourmi13) = *(ObjOuvriere); g_ObjFourmi13->ChangeFrameRateRatio(10.0); g_ObjFourmi13->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi13->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi14 = new C3DObjElement; *(g_ObjFourmi14) = *(ObjOuvriere); g_ObjFourmi14->ChangeFrameRateRatio(10.0); g_ObjFourmi14->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi14->RandomAnimationStart(ANIMATION_WALK_UID); g_ObjFourmi15 = new C3DObjElement; *(g_ObjFourmi15) = *(ObjOuvriere); g_ObjFourmi15->ChangeFrameRateRatio(10.0); g_ObjFourmi15->SelectDefaultAnimation(ANIMATION_WALK_UID); g_ObjFourmi15->RandomAnimationStart(ANIMATION_WALK_UID); */ CVector3f PositionInitiale( 600,400,600 ); CVector3f VitesseInitiale( 5.,-180.,0 ); CVector3f Force( 0.f,-9.81f*80.f,-500.f ); CVector3f RandomPlan( 1200,0.0,1200 ); CVector3f RandomSpeed( 0, -40, 0 ); strcpy(g_sztextureparticule, g_exepath); strcat(g_sztextureparticule, "textures"PATHDELIM_S"particle.tga"); GLuint texuid; glGenTextures(1, &texuid); // Create The Texture tgaLoad(g_sztextureparticule,texuid); g_ParticleSystem.Init(1000, 5, 10, 0.8f, 1.0f, 1.0f, 0.25f, true, texuid, 10.,13., PositionInitiale, VitesseInitiale, Force, RandomPlan, RandomSpeed,&create_particle_callback, NULL); g_ParticleChrono.Reset(); return true; }
int main(int argc, char *argv[]) { test_return_t return_code; unsigned int x; char *collection_to_run= NULL; char *wildcard= NULL; world_st world; collection_st *collection; collection_st *next; void *world_ptr; world_stats_st stats; #ifdef LIBMEMCACHED_WITH_SASL_SUPPORT if (sasl_client_init(NULL) != SASL_OK) { fprintf(stderr, "Failed to initialize sasl library!\n"); return 1; } #endif memset(&stats, 0, sizeof(stats)); memset(&world, 0, sizeof(world)); get_world(&world); collection= init_world(&world); if (world.create) { test_return_t error; world_ptr= world.create(&error); if (error != TEST_SUCCESS) exit(1); } else { world_ptr= NULL; } if (argc > 1) collection_to_run= argv[1]; if (argc == 3) wildcard= argv[2]; for (next= collection; next->name; next++) { test_return_t collection_rc= TEST_SUCCESS; test_st *run; bool failed= false; bool skipped= false; run= next->tests; if (collection_to_run && fnmatch(collection_to_run, next->name, 0)) continue; stats.collection_total++; collection_rc= world.collection.startup(world_ptr); if (collection_rc != TEST_SUCCESS) goto skip_pre; if (next->pre) { collection_rc= world.runner->pre(next->pre, world_ptr); } skip_pre: switch (collection_rc) { case TEST_SUCCESS: fprintf(stderr, "\n%s\n\n", next->name); break; case TEST_FAILURE: fprintf(stderr, "\n%s [ failed ]\n\n", next->name); stats.collection_failed++; goto cleanup; case TEST_SKIPPED: fprintf(stderr, "\n%s [ skipping ]\n\n", next->name); stats.collection_skipped++; goto cleanup; case TEST_MEMORY_ALLOCATION_FAILURE: case TEST_MAXIMUM_RETURN: default: assert(0); break; } for (x= 0; run->name; run++) { struct timeval start_time, end_time; long int load_time= 0; if (wildcard && fnmatch(wildcard, run->name, 0)) continue; fprintf(stderr, "Testing %s", run->name); if (world.test.startup) { world.test.startup(world_ptr); } if (run->requires_flush && world.test.flush) { world.test.flush(world_ptr); } if (world.test.pre_run) { world.test.pre_run(world_ptr); } // Runner code { #if 0 if (next->pre && world.runner->pre) { return_code= world.runner->pre(next->pre, world_ptr); if (return_code != TEST_SUCCESS) { goto error; } } #endif gettimeofday(&start_time, NULL); return_code= world.runner->run(run->test_fn, world_ptr); gettimeofday(&end_time, NULL); load_time= timedif(end_time, start_time); #if 0 if (next->post && world.runner->post) { (void) world.runner->post(next->post, world_ptr); } #endif } if (world.test.post_run) { world.test.post_run(world_ptr); } stats.total++; fprintf(stderr, "\t\t\t\t\t"); switch (return_code) { case TEST_SUCCESS: fprintf(stderr, "%ld.%03ld ", load_time / 1000, load_time % 1000); stats.success++; break; case TEST_FAILURE: stats.failed++; failed= true; break; case TEST_SKIPPED: stats.skipped++; skipped= true; break; case TEST_MEMORY_ALLOCATION_FAILURE: fprintf(stderr, "Exhausted memory, quitting\n"); abort(); case TEST_MAXIMUM_RETURN: default: assert(0); // Coding error. break; } fprintf(stderr, "[ %s ]\n", test_strerror(return_code)); if (world.test.on_error) { test_return_t rc; rc= world.test.on_error(return_code, world_ptr); if (rc != TEST_SUCCESS) break; } } if (next->post && world.runner->post) { (void) world.runner->post(next->post, world_ptr); } if (! failed && ! skipped) { stats.collection_success++; } cleanup: world.collection.shutdown(world_ptr); } if (stats.collection_failed || stats.collection_skipped) { fprintf(stderr, "Some test failures and/or skipped test occurred.\n\n"); } else { fprintf(stderr, "All tests completed successfully\n\n"); } if (world.destroy) { test_return_t error; error= world.destroy(world_ptr); if (error != TEST_SUCCESS) { fprintf(stderr, "Failure during shutdown.\n"); stats.failed++; // We do this to make our exit code return 1 } } world_stats_print(&stats); #ifdef LIBMEMCACHED_WITH_SASL_SUPPORT sasl_done(); #endif return stats.failed == 0 ? 0 : 1; }
game* init_game(size_t xlim, size_t ylim) { world *w = init_world(xlim, ylim); return init_game_from_world(w); }