/** Main entry point for the game. I kept it as simple as I could. */ int main(int argc, char* argv[]) { global = new_globals(); config_handle(); /* Windows doesnt support getopt_long(). Ill need to work around this somehow */ #if !OS_IS_WINDOWS args_handle(argc, argv); #endif engine_init(); atexit(engine_exit); /* no need to call it when quitting */ game_s game = new_game(); engine_draw(&game); while (!game.quit) { int c = engine_get_input(game.speed); game_handle_input(&game, c); game_update(&game); if (game.is_over) game = new_game(); engine_draw(&game); } return EXIT_SUCCESS; }
int main(void) { // initialize stdlib things signal(SIGINT, _finish); srand(time(NULL)); atexit(_exit_cb); // initialize ncurses initscr(); keypad(stdscr, true); nonl(); cbreak(); // TODO use raw() and handle CTRL inputs manually (no signal) noecho(); curs_set(false); nodelay(stdscr, true); // TODO support no color mode (just investigate if attron works) if (!has_colors()) { FPRINTF(stderr, "ncurses colors not supported\n"); exit(EXIT_FAILURE); } start_color(); init_pair(COLOR__GRASS, COLOR_WHITE, COLOR_GREEN); init_pair(COLOR__HP_GOOD, COLOR_GREEN, COLOR_GREEN); init_pair(COLOR__HP_WARNING, COLOR_YELLOW, COLOR_YELLOW); init_pair(COLOR__HP_DANGER, COLOR_RED, COLOR_RED); names_init(); struct game game; audio_init(&game.audio); game_init(&game); // TODO clean this up struct map_chunk chunk; map_chunk_init(&chunk); game.chunk = &chunk; // TODO improve game loop // - "rendering" and update tick do not need to have same rate // - fix input triggering after letting go, etc. for (;;) { int c = getch(); game_handle_input(&game, c); game_tick(&game); game_render(&game); ++game.frame; usleep(100000); } // clean up audio audio_destroy(&game.audio); return EXIT_SUCCESS; }
/** Main entry point for the game. I kept it as simple as I could. */ int main(int argc, char* argv[]) { global = new_globals(); config_handle(); args_handle(argc, argv); engine_init(); atexit(engine_exit); /* no need to call it when quitting */ game_s game = new_game(); engine_draw(&game); while (!game.quit) { int c = engine_get_input(game.speed); game_handle_input(&game, c); game_update(&game); /* THIS WILL BE UNCOMMENTED SOON */ /* if (game.show_help) */ /* { */ /* engine_draw_help(); */ /* engine_wait_for_keypress(); */ /* game.show_help = false; */ /* } */ if (game.is_over) { game_over(&game); engine_draw_gameover(&game); engine_wait_for_keypress(); game = new_game(); } engine_draw(&game); } return EXIT_SUCCESS; }
void game_update() { int eax, tmp; // 0x006E3AEC // screen_game_process_mouse_input(); // RCT2_CALLPROC_EBPSAFE(0x006E3AEC); // screen_game_process_keyboard_input(); // do game logic eax = RCT2_GLOBAL(0x009DE588, uint16) / 31; if (eax == 0) eax = 1; if (eax > 4) eax = 4; // if (ted_fastforwarding) // eax += 8 - 1; if (RCT2_GLOBAL(0x009DEA6E, uint8) == 0) { for (; eax > 0; eax--) { game_logic_update(); RCT2_CALLPROC_EBPSAFE(0x006BD0F8); // play title screen music /* if (rctmem->dword_009E2D74 == 1) { rctmem->dword_009E2D74 = 0; break; } else { if (rctmem->input_state != INPUT_STATE_WIDGET_RESET && rctmem->input_state != INPUT_STATE_WIDGET_NORMAL) break; tmp = rctmem->dword_009DE518 & 0x80; rctmem->dword_009DE518 &= ~0x80; if (tmp) break; } */ } } RCT2_GLOBAL(0x009DE518, uint32) &= ~0x80; RCT2_GLOBAL(0x009AC861, uint16) &= ~0x8000; RCT2_GLOBAL(0x009AC861, uint16) &= ~0x02; tmp = RCT2_GLOBAL(0x009AC861, uint16) & 0x01; RCT2_GLOBAL(0x009AC861, uint16) &= ~0x01; if (!tmp) RCT2_GLOBAL(0x009AC861, uint16) |= 0x02; RCT2_GLOBAL(0x009AC861, uint16) &= ~0x08; tmp = RCT2_GLOBAL(0x009AC861, uint16) & 0x04; RCT2_GLOBAL(0x009AC861, uint16) &= ~0x04; if (!tmp) RCT2_GLOBAL(0x009AC861, uint16) |= 0x04; RCT2_CALLPROC_EBPSAFE(0x006EE77A); window_update_all(); RCT2_GLOBAL(0x01388698, uint16)++; // Input RCT2_GLOBAL(0x0141F568, uint8) = RCT2_GLOBAL(0x0013CA740, uint8); game_handle_input(); RCT2_CALLPROC_EBPSAFE(0x006838BD); RCT2_CALLPROC_EBPSAFE(0x00684218); if (RCT2_GLOBAL(0x009AAC73, uint8) != 255) { RCT2_GLOBAL(0x009AAC73, uint8)++; if (RCT2_GLOBAL(0x009AAC73, uint8) == 255) config_save(); } }
static void game_update(game_t *g) { game_handle_input(g); game_state_update(g->state); }