Esempio n. 1
0
void Game::initialize(){
	init();
	game::network::Socket::socket_init();
	config.load(folder_path+"config.txt");
	window=create_window();

	//window->render_on();
	draw = new Display::Draw();
	draw->register_cur();
	UIObj_Creator=new UI::UIObjectCreator();
	UIObj_Creator->register_cur();

	renderer = new Display::Renderer(draw, window);
	//render_task = new RenderTask(renderer);


	input = new Input::Input(window->get_window());
	input->register_cur();
	game_receiver=new Input::Receiver("Game");
	input->push_receiver(game_receiver);

	controller_system=new ControllerSystem();
	controller_system->push(new Input::SelectableControl());
	controller_system->push(new Audio::AudioController());


	thread_pool = create_thread_pool();

	s_loading = new LoadingScene();
	s_loading->initialize(draw,input,thread_pool);

	initialize_game();
}
Esempio n. 2
0
int		main(int argc, char **argv, char **env)
{
  t_tetris	game;
  t_list	list;
  bool		files;

  files = true;
  initialize_struct(&game);
  initialize_value(&game, argv[0], env);
  if (argc > 1)
    options(&game, argc, argv);
  init_list(&list);
  files = (!(initialize_files(&list, &game))) ? false : true;
  if (game.debug == true)
    mode_debug(&game, list);
  game.list = list;
  if (files == true)
    {
      if ((game.scene->rows + 2 > (tgetnum("lines")))
  	  || (game.scene->colums + 43 > (tgetnum("cols"))))
  	my_puterr("Terminal too small\n");
      else if ((check_one_valid(&list)) == 1)
  	initialize_game(&game);
    }
  my_free(&game, &list);
  endwin();
  return (0);
}
Esempio n. 3
0
/* MAIN FUNCTION */
int main(){
    initialize_game();
    load_images();
    play_menu_sound();
    set_initial_values();
    
    welcome_screen();
	return 0;
}END_OF_MAIN()
static void run_game()
{
	game_data game;

	initialize_game(&game, wsi::milliseconds());

	running = true;

	for (;;)
	{
		wsi::update(&screen);

		bool rendering = wsi::should_render();

		int64_t millisecond_clock_now = wsi::milliseconds();

		unsigned ticks_elapsed = 0;
		float fractional_ticks = 0;
		calc_game_elapsed_time(&game, &ticks_elapsed, &fractional_ticks, millisecond_clock_now);

		game_command action = { 0 };
		process_inputs(&action);

		if (!running) break;

		update_game(&game, ticks_elapsed, &action, millisecond_clock_now);
		update_fps();

		if (action.toggle_pause)
		{
			pause_eviz_dx12(game.paused);
		}

		if (rendering)
		{
			float dpi = (float)screen.dpi.cx;
			float x_dips = screen.dimensions.cx * 96.0f / dpi;
			float y_dips = screen.dimensions.cy * 96.0f / dpi;
			set_swapchain_options_dx12(&wsi::screen_window, NULL, x_dips, y_dips, dpi, &swapchain_opts);
			rebuild_hud_string(&game);
			dx12_render_stats stats;
			render_game_dx12(hud_string, &game, fractional_ticks, screen.prefs.vsync, &stats);
			if (stats.latency) {
				const float alpha = 0.1f;
				frame_latency = (1-alpha)*frame_latency + alpha*stats.latency;
				frame_latency_stddev = stats.stddev_jitter;
				frame_latency_minmaxd = stats.minmax_jitter;
				current_frametime_cpu = (1 - alpha)*current_frametime_cpu + alpha*stats.cpu_frame_time;
				current_frametime_gpu = (1 - alpha)*current_frametime_gpu + alpha*stats.gpu_frame_time;
			}
		}

		//wsi::limit_fps(max_fps);
	}
}
Esempio n. 5
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();
	}
}
Esempio n. 6
0
/*******************************************************************************
 * ENTRY POINT
 ******************************************************************************/
int main( int argc, char** argv )
{
    /* Initialize GLUT */
    initialize_GLUT( &argc, argv );
    
    /* Initialize game modules */
    initialize_game();
    
    /* Start event processing */
    glutMainLoop();
    
    return 0;
}
Esempio n. 7
0
int
test_initialize_game()
{
		Game *gamep;
		int ret, t_ret;
		
		if ((ret = initialize_game(&gamep)) != 0) {
				printf("INIT_GAME INITIALIZATION fails\n");
				printf("    expected 0 got %d\n", ret);
				return ret;
		}
		if ((t_ret = COUNT_PIECES(gamep->board)) != 0) {
				printf("INIT_GAME EMPTY BOARD fails\n");
				printf("    expected 0 got %d\n", t_ret);
				ret = ret == 0 ? t_ret : ret; 
		}
		if ((t_ret = COUNT_PIECES(gamep->remaining)) != NPIECES) {
				printf("INIT_GAME ALL PIECES fails\n");
				printf("    expected %d got %d\n", NPIECES, t_ret);
				ret = ret == 0 ? t_ret : ret; 
		}

		return ret;
}
Esempio n. 8
0
int main(int argc, char *argv[])
{
    // An array of 4 players, may need to be a pointer if you want it set dynamically
    player players[NUM_PLAYERS];
    
    // Input buffer and and commands
    //char buffer[BUFFER_LEN] = { 0 };

    // Display the game introduction and initialize the questions
    initialize_game();

    // Prompt for players names
    printf("This is Jeopardy \n");

    // initialize each of the players in the array
    for(int i = 0; i < 4; i++) {
        players[i].score = 0;

        printf("Enter player name: ");
        scanf("%s", (char *) &players[i].name);
    }

    // Perform an infinite loop getting command input from users until game ends
    //while (fgets(buffer, BUFFER_LEN, stdin) != NULL)
    while(!answered_status())
    {
        system("clear");

        char selected_player[MAX_LEN] = "";
        char selected_category[MAX_LEN] = "";
        int selected_val = 0;

        do {
            if(strcmp(selected_player, "") != 0)
                printf("The player %s was not found", selected_player);

            printf("Enter first player's name: ");
            scanf("%s", (char *) &selected_player);
        } while(!player_exists(players, 4, selected_player));

        do {
            if(selected_val != 0)
                printf("Invalid selection");

            printf("Enter category: ");
            getchar();
            fgets((char *) selected_category, MAX_LEN, stdin);
            strtok(selected_category, "\n");

            printf("Enter: ");
            scanf("%d", (int *) &selected_val);
        } while(already_answered(selected_category, selected_val));


        system("clear");
        display_question(selected_category, selected_val);

        char *answer[MAX_LEN] = {0};
        getchar();
        fgets((char *) answer, MAX_LEN, stdin);

        char *tokenize_answer;
        tokenize((char *) answer, &tokenize_answer);

        if(tokenize_answer == NULL)
            printf("Try again");
        else if(valid_answer(selected_category, selected_val, tokenize_answer)) {
            printf("Correct Answer!");
            printf("%s gains %d points \n", selected_player, selected_val);
            update_score(players, 4, selected_player, selected_val);
        } else {
            printf("Wrong Answer!");
            int num = get_question_number(selected_category, selected_val);
            printf("Correct answer was: %s", questions[num].answer);
        }

        track_answered(selected_category, selected_val);

        // Call functansions from the questions and players source files

        // Execute the game until all questions are answered

        // Display the final results and exit
    }

    show_results(players, 4);
    getchar();

    return EXIT_SUCCESS;
}
int main(void)
{
  initialize_game();
}
int main(int argc, char *argv[])
{
	srand(time(NULL));
    // An array of 4 players, may need to be a pointer if you want it set dynamically
    player players[4];
 
    // Input buffer and and commands
    char buffer[BUFFER_LEN] = { 0 };

    // Display the game introduction and prompt for players namesc
    printf("Welcome to Jeopardy: CSCI-3020 Edition! \n \n");
    // initialize each of the players in the array
    for (int i = 0; i < 4; i++){ 
        printf("Enter the name of player %d. \n", i);
        scanf("%s", players[i].name);
        printf("\n");
        players[i].score = 0;
    }

    initialize_game();
    int *turnOrder = (int*)malloc(4*sizeof(int));
    generateTurnOrder(turnOrder);

    printf("Turn Order: \n");
    printf("--------------- \n");
    for (int i = 0; i <= 3; i++){
    	printf("%d \n", turnOrder[i]);
    }
    printf("---------------\n");
    
    player selectedPlayer;
    char *category = (char*)calloc(256,sizeof(char));
    int value;
    // Perform an infinite loop getting command input from users until game ends
    while (fgets(buffer, BUFFER_LEN, stdin) != NULL)
    {

    	for(int i = 0; i < 4; i++){
    		selectedPlayer = players[turnOrder[i] - 1];

    		printf("%s's turn. \n", selectedPlayer.name);
    		display_categories();
    		printf("\nSelect a category: \n");
    		scanf("%s", category);
    		printf("\nSelect a value: \n");
    		scanf("%d", &value);

    		display_question(category, value);


    	}
        // Call functions from the questions and players source files
	
        // Execute the game until all questions are answered
       
        // Display the final results and exit
    }



    free(turnOrder);
    return EXIT_SUCCESS;
}
Esempio n. 11
0
void initialize_games() {
	initialize_game();
}