Пример #1
0
int
main()
{
    /* Future Work 3:
       How the selfloader bootstraps user processes needs to be modified further. Changes were
       made to accomodate the new way that muslc expects process's stacks to be set up when
       processes start, but the one part of this that still needs to changed is how user processes
       find their system call table. Currently the selfloader sets up user processes so that
       the selfloader's system call table is used by user processes by passing the address of the
       selfloader's system call table to the user processes via the user process's environment
       variables. Ideally, user processes would use their own system call table.
    */

    uintptr_t address = strtoll(getenv("SYSTABLE"), NULL, 16);
    refos_init_selfload_child(address);
    int c, i, *ptr;
    int delay = INITIAL_DELAY_MS;
    refos_initialise();

    peekShape = NULL;

    /* Initialise board. */
    ptr = board;
    for (i = B_SIZE - 1; i>=0; i--) {
        *ptr++ = i < 25 || i % B_COLS < 2 ? A_BG_W : RESETATTR;
    }

    srand((unsigned int) RANDOM_SEED);

    clrscr();

    print_welcome_message();
    printf("      Press the space bar to continue...\n");
    show_online_help();

    while (1) {
        c = io_nonblock_getkey();
        rand();
        if (c == ' ') break;
    }
    clrscr();
    show_online_help();

    /* Main game loop. */
    shape = next_shape();
    while (!exitGame) {
        c = io_nonblock_getkey();
        rand();
        if (c >= 0) {
            game_frame(c);
        } else {
            game_frame(0);
            usleep((delay - level * LEVEL_DECREASE_DELAY_MS) * 1000);
        }
    }

    gotoxy (0, 25);
    printf("Game over! You reached %d points.\n", points);
}
Пример #2
0
int main ( int argc, char** argv )
{
    printf("Starting test ... \n");

    gamepad_buttons[0] = 0; // all up
    gamepad_buttons[1] = 0;
    
    game_init();

    printf("  Game init done. \n");

    // program main loop
    for (int i=0;i<EMU_FRAMES;i++) {
        handle_gamepad();

        // update game
        game_frame();

        // update time
        vga_frame++;

        // one sound buffer per frame 
        game_snd_buffer(audio,BITBOX_SNDBUF_LEN); 

        refresh_screen();
    } // end main loop

    // all is well ;)
    printf("  Test OK !\n");
    return 0;
}
Пример #3
0
__attribute__((weak)) int main(void)
{
	game_init();

	while (1) {
		game_frame();

		// wait next frame.
		int oframe=vga_frame;
		while (oframe==vga_frame);

		set_led(button_state());
	}
}
Пример #4
0
void run_game() {

  // Create player 1
  std::list<Link> player1;
  Link p1start = {5, MAX_BOARD_Y / 2, 'X', 1};
  player1.push_back(p1start);

  // Create player 2
  std::list<Link> player2;
  Link p2start = {MAX_BOARD_X - 5, MAX_BOARD_Y / 2, 'O', 2};
  player2.push_back(p2start);

  clear();
  print_board();
  print_snake(player1);
  print_snake(player2);

  // Wait for initial direction input
  int p1direction;
  int p2direction;
  bool p1sel = false;
  bool p2sel = false;
  while(!(p1sel && p2sel)) {
    if (kbhit()) {
      int input = getch();
      if (!p1sel) {
        p1sel = get_init_dir(p1direction, input, 1);
      }
      if (!p2sel) {
        p2sel = get_init_dir(p2direction, input, 2);
      }
    }
  }

  int loser = 0;
  while(loser == 0) {
    game_frame(player1, p1direction, player2, p2direction);
    loser = check_collisions(player1, player2);
    if (loser == 0) {
      loser = check_collisions(player2, player1);
    }
  }
  if (!play_again(loser)) {
    return;
  }
  else {
    run_game();
  }
}
Пример #5
0
int main ( int argc, char** argv )
{

    for (int i=1;i<argc;i++) {
        if (!strcmp(argv[i],"--fullscreen"))
            fullscreen = 1;
        else if (!strcmp(argv[i],"--slow"))
            slow = 1;
        else if (!strcmp(argv[i],"--verbose"))
            quiet = 0;
        else if (!strcmp(argv[i],"--scale2x"))
            scale = 2;
        else {
            instructions();
            exit(0);
        }
    }

    // display current options
    if (!quiet) {
        printf("Options : %s %s scale : %d\n",fullscreen?"fullscreen":"windowed",slow?"slow":"normal speed",scale);
        instructions();
        printf(" - Starting\n");
    }

    gamepad_buttons[0] = 0; // all up
    gamepad_buttons[1] = 0;

    if (init()) return 1;
    game_init();

    // now start sound
    SDL_PauseAudio(0);

    // program main loop
    bool done = false;
    while (!done)
    {

        // message processing loop
        done = handle_events();
        kbd_emulate_gamepad();
        // update game
        game_frame();

        // update time
        vga_frame++;
        
        #if VGA_MODE!=NONE
        refresh_screen(screen);
        #endif

        SDL_Delay(time_left());
        next_time += slow ? TICK_INTERVAL*10:TICK_INTERVAL;

        SDL_Flip(screen);
    } // end main loop

    // all is well ;)
    if (!quiet)
        printf(" - Exited cleanly\n");
    return 0;
}
Пример #6
0
int main(int argc, char *argv[])
{
	int res;

	if (argc == 6)
	{
		nbTeams = (int) strtol(argv[1], &argv[1], 10);
		//TODO : mettre des #define pour equipe min et max
		if (nbTeams > 10 || nbTeams < 2)
		{
			printf("Please enter a number of teams between 2 and %d\n", 10); //TODO : wtf ? 50% string 50% %d ?
			exit(EXIT_SUCCESS);
		}

		nbPlayers = (int) strtol(argv[2], &argv[2], 10);
		if (nbPlayers > MAXPLAYERS || nbPlayers < 2)
		{
			printf("Please enter a number of players between 2 and %d\n", MAXPLAYERS);
			exit(EXIT_SUCCESS);
		}
		//tell photon server the ip adress
		NotifyPhotonServer(argv[5]);

		networkLoad = (int) strtol(argv[3], &argv[3], 10);
		networkLoadinterval = (int) strtol(argv[4], &argv[4], 10);
		printf("%d teams, %d players\n", nbTeams, nbPlayers);

	}
	else
	{
		printf("Airstrike nbOfTeams nbOfPlayers NetworkLoad(Bytes) networkLoadinterval(ms) IPadressOfPhoton\n");
		exit(EXIT_SUCCESS);
	}

	res = general_setup() == 0;
	assert(res);
	engine_setup();
	DEBUGPOINT(1);
	teams_setup();
	DEBUGPOINT(42);
	players_setup();
	objects_setup();

	planeCollision=cfgnum("game.planeCollision",1);
	networkport = cfgnum("network.port",1234);

	network_init();


	Mix_Music *play_sound = NULL;
	play_sound = Mix_LoadMUS("data/sound/Xcyril-La_decouverte_et_la_conquete.wav");
	Mix_PlayMusic(play_sound, -1);
	//Mix_VolumeMusic(MIX_MAX_VOLUME/2);

	fprintf(stderr, "Entering main loop.\n");
	while (process_events())
	{
		if (!paused)
		{
			if(inGame){
				game_frame();
			}else{
				connect_frame();
			}
		}
		else
		{
			console_mode();
			paused = 0;
		}
	}
	// We probably never get here right now, because of exit() calls. 
	fprintf(stderr, "Left main loop.\n");
	sprite_group_free(mech_group);
	sprite_group_free(bomb_group);
	sprite_group_free(bullet_group);
	sprite_group_free(effects_group);
	sprite_group_free(foreground_group);
	return EXIT_SUCCESS;
}