int main (int argc, char *argv[]) { game_t *game = game_create (); game_start (game); setup_board_every_gem_different (game); int **old_board = copy_board (game); int m = game->n_rows; int n = game->n_cols; replace_gem (game, 2, 2, 999999); replace_gem (game, 3, 2, 1999999); replace_gem (game, 4, 2, 999999); int i; for (i = 0; i < 50 * 2; ++i) { game_loop (game); } for (i = 0; i < m; ++i) { fail_if (game->board[3][i] == old_board[3][i]); } for (i = 0; i < n; ++i) { if (i == 3) continue; fail_if (game->board[i][1] != old_board[i][0]); fail_if (game->board[i][0] == old_board[i][0]); } setup_board_every_gem_different (game); old_board = copy_board (game); replace_gem (game, 2, 2, 999999); replace_gem (game, 2, 3, 1999999); replace_gem (game, 2, 4, 999999); for (i = 0; i < 50 * 2; ++i) { game_loop (game); } for (i = 0; i < m; ++i) { fail_if (game->board[2][i] == old_board[2][i]); } for (i = 0; i < n; ++i) { if (i == 2) continue; fail_if (game->board[i][1] != old_board[i][0]); fail_if (game->board[i][0] == old_board[i][0]); } game_destroy (game); return 0; }
char menu_loop(t_board *board, t_surfaces *surf) { SDL_Event event; char loop; SDL_Surface *current; loop = 42; current = surf->title; while (loop) { show_background(current, surf->screen); SDL_ShowCursor(1); SDL_WaitEvent(&event); if ((((event.type == SDL_KEYDOWN) && (event.key.keysym.sym == SDLK_ESCAPE)) || (event.type == SDL_QUIT)) && (current == surf->title)) loop = 0; // Écran de victoire if ((((event.type == SDL_KEYDOWN) && (event.key.keysym.sym == SDLK_ESCAPE)) || (event.type == SDL_QUIT)) && (current != surf->title)) { loop = 42; current = surf->title; } if (event.type == SDL_MOUSEBUTTONUP) { if (current == surf->title) { if ((event.motion.x > 180) && (event.motion.x < 480)) { if ((event.motion.y > 400) && (event.motion.y < 450)) loop = game_loop(board, surf, 1); if ((event.motion.y > 480) && (event.motion.y < 520)) loop = game_loop(board, surf, 0); if ((event.motion.y > 560) && (event.motion.y < 600)) loop = 0; if (loop == 1) current = surf->blackwin; else if (loop == 2) current = surf->whitewin; else show_background(surf->title, surf->screen); } } else { loop = 42; current = surf->title; } } SDL_Flip(surf->screen); } return (0); }
/* * Process user input */ void process_input(GLFWwindow *win, const std::string &inp) { static constexpr char num_options {'4'}; const std::string s {inp}; const char inp_char {s[0]}; if (s.length() == 1 && inp_char >= '0' && inp_char < num_options) { game_loop(win, inp_char - '0'); } else { std::cerr << "Wrong input: drawing default scene\n"; game_loop(win, 0); } }
void IdleFunc() { static int MarkTime; if ((int)(MarkTime - timer_ms_gettime64()) < 0) { MarkTime = timer_ms_gettime64() + YETI_VIEWPORT_INTERVAL; keyboard_update(&yeti.keyboard); pvr_wait_ready(); pvr_scene_begin(); /* The cool thing here is that we don't have to worry about which display list to open/close, which display list is open, or any of that when using PVR DMA. We submit everything with pvr_list_prim instead of pvr_prim and things get submitted in the right order automatically. Just run your game loop in between "pvr_scene_begin();" and "pvr_scene_finish();" and the rest is taken care of. */ game_loop(&yeti); /* Done drawing! */ pvr_scene_finish(); } }
int main(int argc, char *argv[]) { setlocale(LC_ALL,"it_IT.UTF-8"); // in primis srand(time(NULL)); // caos! startNcurses(&(globali.gioco.larg),&(globali.gioco.alt)); // inizializza ncurses snprintf(globali.playername,maxnome,"%s",getenv("USER")); // salva il nome del giocatore (max 10 char) init_colori(&globali); // attiva i colori globali.speed=2; globali.gioco.serpente.ai=noAI; globali.safe_graph=0; if (!parse_cmdline(argc,argv,&globali)) { start_gioco(&globali); // inizializza le var di gioco globali.gameover=1; globali.paused=1; title_loop(&globali); // schermata titolo globali.paused=0; globali.gameover=0; } else start_gioco(&globali); // inizializza le var di gioco atexit(endNcurses); // eseguita automaticamente all'uscita clear(); //dump_snacache(globali.gioco.serpente.cache,globali.gioco.larg,globali.gioco.alt); refresh(); sleep(3); refresh(); game_loop(&globali); // loop di gioco end_gioco(&globali); // libera la memoria return 0; }
int main() { signal(SIGINT, finish); srand(time(NULL)); initscr(); curs_set(0); // hide the cursor keypad(stdscr, TRUE); nodelay(stdscr, TRUE); set_escdelay(10); cbreak(); // return after reading one char noecho(); start_color(); init_pair(1, COLOR_GREEN, COLOR_BLACK); init_pair(2, COLOR_MAGENTA, COLOR_BLACK); init_pair(3, COLOR_RED, COLOR_BLACK); init_pair(4, COLOR_BLUE, COLOR_BLACK); init_pair(5, COLOR_CYAN, COLOR_BLACK); init_pair(6, COLOR_YELLOW, COLOR_BLACK); init_pair(7, COLOR_WHITE, COLOR_BLACK); init_pair(8, COLOR_BLACK, COLOR_WHITE); game_loop(Startscreen_create()); /* print_glyphs(); */ finish(0); }
void d3d_flip(void) { static unsigned MarkTime; if ((int)(MarkTime - timeGetTime()) < 0) { MarkTime = timeGetTime() + YETI_VIEWPORT_INTERVAL; keyboard_update(&yeti.keyboard); game_loop(&yeti); ZeroMemory(&ddsd, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); if (lpDDSPrimary->Lock(NULL, &ddsd, DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR, NULL) == DD_OK) { viewport_to_video( (u16*) ddsd.lpSurface, ddsd.lPitch, &yeti.viewport, ddpf.dwRBitMask, ddpf.dwGBitMask, ddpf.dwBBitMask); lpDDSPrimary->Unlock(ddsd.lpSurface); } } }
int test_levels(int map_layout [MAX_X][MAX_Y]) // function for agreagate testing { //printf("Drawing test\n"); int selected_option, control; int wrong_input = 0; do { if (wrong_input == 1) { printf("The chosen option is not valid.\nNumber of desired option: "); control = scanf("%d", &selected_option); fflush(stdin); } else { printf("Choose the level of difficulty: "); printf("\nEASY LEVEL - 1 "); printf("\nMEDIUM LEVEL - 2 "); printf("\nHARD LEVEL - 3 "); printf("\nNumber of desired option: "); control = scanf("%d", &selected_option); fflush(stdin); wrong_input = 1; } } while (selected_option < 1 || selected_option > 3 || control == 0); // selected_level = level_set (selected_option); Problem with this function if(selected_option == 1) { //Load EASY LEVEL levels(1); create_mountain_map(map_layout); //test_drawing_map(map_layout); //test_drawing_units(map_layout); } else if(selected_option == 2) { //Load MEDIUM LEVEL levels(2); create_mountain_map(map_layout); //test_drawing_map(map_layout); //test_drawing_units(map_layout); } else if(selected_option == 3) { //Load HARD LEVEL levels(3); create_mountain_map(map_layout); //test_drawing_map(map_layout); //test_drawing_units(map_layout); } game_loop(map_layout); return selected_option; }
int main() { Enable_curses c; const size_t M = 20; const size_t N = 20; cbreak(); noecho(); nonl(); intrflush(stdscr, false); keypad(stdscr, TRUE); game_init_colors(); WINDOW* win = newwin(M+10, N+10, 0, 0); Map map{M,N}; map.reset(); Player p{5, 6, M, N}; map(p.x, p.y) = PLAYER; map(5,5) = ENEMY; // map(5, 5) = ENEMY; // WINDOW* win = newwin(M+10, N+10, 0, 0); game_loop(p, win, map); }
int main(int argc, char *argv[]) { int opt; while ((opt = getopt(argc, argv, "as")) != -1) { switch (opt) { case 'a': auto_play = 1; break; case 's': suggestion = 1; break; default: /* '?' */ fprintf(stderr, "Usage: %s [-a] [-s]\r\n", argv[0]); fprintf(stderr, "-a: Let AI play the game\r\n"); fprintf(stderr, "-s: Display AI suggestion\r\n"); exit(EXIT_FAILURE); } } init(); srandom(time(NULL)); initscr(); noecho(); game_loop(); refresh(); endwin(); return 0; }
int main(int argc, char **argv) { init(); game_loop(); shutdown(); return 0; }
int main(int argc, char* argv[]) { init(); game_loop(); //closingSplash(); shutdown(); }
int main(int ac, char *av[]) { if ( initialize_board() == -1 ) { return 1; } game_loop(); return 0; }
int main (int argc, char *argv[]) { GAME *game = game_init (); game_loop (game); game_destroy (game); return EXIT_SUCCESS; }
/* * Display a menu of possible actions */ void show_menu(GLFWwindow *win, const std::string &prog_name) { std::cout << "Note: the program can be run as follows:\n" << prog_name << " int_param, where int_param is:\n" << "0:\t100 colourful square (default)\n" << "1:\t100 colourful with varying size and using instancing\n" << "2:\tplanet with asteroids (without instancing)\n" << "3:\tplanet with asteroids (with instancing)\n"; game_loop(win, 0); }
int main() { t_game *game; game = game_create(); game_loop(game); game_quit(game); return (0); }
int main(int argc, char *argv[]){ int c; int port = 8080; char address[16]; int mode = 0; /* mode=0 server, mode=1 client*/ int debug = 0; signal(SIGINT, exit_sigint); /* Parser degli argomenti da riga di comando */ while ((c = getopt(argc, argv, "hc:p:dvn:f:")) != -1){ switch(c){ case 'h': puts(USAGE); exit(0); case 'p': port = atoi(optarg); break; case 'c': mode = 1; strcpy(address, optarg); break; case 'n': strcpy(player, optarg); break; case 'v': puts(INFO); exit(1); case 'f': strcpy(filename, optarg); break; case 'd': W("#####################################"); W("# Starting program in debug mode!!! #"); W("#####################################"); puts("Avvio del programma in modalità debug: solo per sviluppatori"); debug = 1; break; default: puts(USAGE); exit(1); } } puts(BANNER); if (!debug) inizzializza_rete(mode, port, address); init_screen(); posiziona_navi(); game_loop(mode); return 0; }
int main(int argc, char *argv[]) { NOPH_GameCanvas_get(); /* We want to force-in _something_ from J2ME :-) */ printf("Press keys and see the keycodes.\n"); game_loop(); return 0; }
int main(void) { if (init() != 0) return EXIT_FAILURE; if (game_loop() != 0) return EXIT_FAILURE; return EXIT_SUCCESS; }
int main(int argc, char *argv[]) { game_init(); while (!quit_flag) { game_event(&event); game_loop(); game_render(); } game_destroy(); return EXIT_SUCCESS; }
int main(int argc, char **argv) { if(!init(1366, 768, true)) return -1; game_loop(); deinit(); return 0; }
int main( int argc, char* argv[] ) { //get_settings read_settings; //create a settings reading object. int screenDataW = 1920; //put screen data into a temp var int screenDataH = 1080; SDL_Init( SDL_INIT_EVERYTHING ); //start SDL SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); //set GL version of the window SDL_Window* window = SDL_CreateWindow( "RainbowRPG - SDL2.0 - OpenGL2.1", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, screenDataW, screenDataH, SDL_WINDOW_FULLSCREEN_DESKTOP | SDL_WINDOW_OPENGL | SDL_WINDOW_INPUT_GRABBED); //create OpenGL window SDL_GLContext glcontext = SDL_GL_CreateContext(window); //set context as OpenGL // SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN); initGL(screenDataW, screenDataH); //init GL. //command_thread.detach(); // SDL_Delay(1000); std::string mapFile ("a.map"); std::cout << "Initialising map!\n\n"; map* ptrmap; //create a pointer of type map. map currentMap (screenDataW, screenDataH, mapFile); ptrmap = ¤tMap; //make pointer point to instance of map. std::cout << "checking for inputted commands...."; command* ptrCommand; //create a pointer of type command. command commandline; //create command line object. std::cout << "creating command line thread...\n"; boost::thread command_thread ( boost::bind (&command::start_command, &commandline) ); //create a thread of the command line. std::cout << "Command thread started\n\n"; ptrCommand = & commandline; //make pointer point to command object. //boost::thread logic_loop (boost::bind(&entity_logic_loop, ptrmap)); //create logic loop thread. std::cout << "Running game loop func\n\n"; game_loop(ptrCommand, ptrmap, window); //game_loop( ptrmap, window); currentMap.destroy_map(); //destroy the map! SDL_GL_DeleteContext(glcontext); //clean up SDL_Quit(); //quit SDL std::cout << "\nQuited nicely, press any letter/number key then tap return to terminate \n(This is a problem with using threads and std::cin together, must find a better way of doing this safely\n\n"; // - Remember killing the thread causes recursive terminate >.<.)\n\n"; command_thread.join(); //detach both out threads. //logic_loop.join(); return 0; }
int main() { std::srand(std::time(NULL)); allegro_init(); install_timer(); install_keyboard(); // install_mouse(); install_joystick(JOY_TYPE_AUTODETECT); override_config_file(redir("defnot.ini").c_str()); gfx_widescreen = get_config_int("Game", "Widescreen", gfx_widescreen); gfx_fullscreen = get_config_int("Game", "Fullscreen", gfx_fullscreen); if (!setup_gfx() != 0) { allegro_message("Unable to setup the graphics mode\n"); return 1; } // if (gfx_capabilities & GFX_HW_CURSOR) { // enable_hardware_cursor(); // select_mouse_cursor(MOUSE_CURSOR_ARROW); // show_mouse(screen); // } if (!load_media()) { allegro_message("Unable to load data files to play the game\n"); return 1; } // install the timer to control the game speed LOCK_VARIABLE(beats); LOCK_FUNCTION(timer_control); beats = 0; install_int_ex(timer_control, BPS_TO_TIMER(BPS)); // insert the callback routine for the close-button LOCK_VARIABLE(continuing); LOCK_FUNCTION(close_button); set_close_button_callback(close_button); // play the game game_loop(); set_config_int("Game", "Widescreen", gfx_widescreen); set_config_int("Game", "Fullscreen", gfx_fullscreen); remove_int(timer_control); allegro_exit(); return 0; }
/* * main * DESCRIPTION: Play the adventure game. * INPUTS: none (command line arguments are ignored) * OUTPUTS: none * RETURN VALUE: 0 on success, 3 in panic situations */ int main () { game_condition_t game; /* outcome of playing */ /* Randomize for more fun (remove for deterministic layout). */ srand (time (NULL)); /* Provide some protection against fatal errors. */ clean_on_signals (); if (!build_world ()) {PANIC ("can't build world");} init_game (); /* Perform sanity checks. */ if (0 != sanity_check ()) { PANIC ("failed sanity checks"); } /* Create status message thread. */ if (0 != pthread_create (&status_thread_id, NULL, status_thread, NULL)) { PANIC ("failed to create status thread"); } push_cleanup (cancel_status_thread, NULL); { /* Start mode X. */ if (0 != set_mode_X (fill_horiz_buffer, fill_vert_buffer)) { PANIC ("cannot initialize mode X"); } push_cleanup ((cleanup_fn_t)clear_mode_X, NULL); { /* Initialize the keyboard and/or Tux controller. */ if (0 != init_input ()) { PANIC ("cannot initialize input"); } push_cleanup ((cleanup_fn_t)shutdown_input, NULL); { game = game_loop (); } pop_cleanup (1); } pop_cleanup (1); } pop_cleanup (1); /* Print a message about the outcome. */ switch (game) { case GAME_WON: printf ("You win the game! CONGRATULATIONS!\n"); break; case GAME_QUIT: printf ("Quitter!\n"); break; } /* Return success. */ return 0; }
void Game::run() { /* Why not just have the game loop in here? * Because I want to put some code in this * like.. FPS limiters and things. :< */ initialize_game(); while(window.isOpen()) { game_loop(); } }
void Game::start() { framerate->setFPS(GAME_FPS); Mix_FadeOutMusic(500); setup_player_stats(); balls.push_back(new BallZerg(SCREEN_WIDTH/2, SCREEN_HEIGHT/2, 5, 0, EGG, this)); //balls.push_back(new BallZerg(SCREEN_WIDTH/2, SCREEN_HEIGHT/2, 0.2, 2, EGG, this)); // OpenAL test balls[0]->mainBall = true; bool exit = false; intro(); //playMusic(s_music);//DEBUG while ((!exit) && (round <= rounds)) { round_title(); exit = game_loop(); if (!exit) { ++(winner->wins); playSound(loser->s_lose); if (round == rounds) { if (players[0]->wins == players[1]->wins) { playSound(winner->s_win); rounds++; } else { playSound(winner->s_win2); end(); } } else playSound(winner->s_win); round++; players[0]->reset(); players[1]->reset(); } } Mix_FadeOutMusic(1000); }
/* * Main - entry point */ int main(int argc, char *argv[]) { /* Init SDL systems we need or fail */ if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO) < 0) { printf("SDL Init failed: %s\n", SDL_GetError()); return 1; } /* Create window and renderer or fail */ window = SDL_CreateWindow("Tyrion", WIN_X, WIN_Y, WIDTH, HEIGHT, SDL_WINDOW_INPUT_GRABBED); if (!window) { printf("SDL error, could not create window: %s\n", SDL_GetError()); return 1; } /* SDL surface is just an image data type that has the pixels of an image along with all * data needed to render it. surfaces use software rendering (uses CPU to render, not * the GPU). */ surface = SDL_GetWindowSurface(window); /* Load game images, resources */ player_image = SDL_LoadBMP("path/tofile.bmp"); if (!player_image) { printf("SDL error, unable to load image: %s\n", SDL_GetError()); return 1; } /* Game loop */ while (running) { /* Handle events */ game_loop(); /* Blit image to surface */ SDL_BlitSurface(player_image, NULL, surface, NULL); /* Display surface */ SDL_UpdateWindowSurface(window); SDL_Delay(4000); } /* TODO: refactor this clean up code */ SDL_FreeSurface(player_image); player_image = NULL; SDL_DestroyWindow(window); window = NULL; SDL_Quit(); return 0; }
int main( int argc, char *argv[] ) { Uint32 FPS_MAX = 1000 / 63; // 60 fps game_init(); while ( quit_flag == false ) { game_event( &event ); game_loop(); game_render(); SDL_Delay( FPS_MAX ); } game_destroy(); return EXIT_SUCCESS; }
int main(int argc, char* argv[]) { ALLEGRO_EVENT_QUEUE* event_queue; ALLEGRO_TIMER* timer; ALLEGRO_DISPLAY* display; bool done; init(&event_queue, &timer, &display, &done); game_loop(&event_queue, &timer, &display, &done); shutdown(&event_queue, &timer, &display); return 0; } // main()
int main(int argc, char* argv[]) { script_init(); load_ini(); engine_init(); // includes ttf init too vid_init(); dump_lua(); game_loop(); engine_shutdown(); script_shutdown(); return 0; }