void main()
#endif
{
  game_t game;

  /* Initialize the front end */
  fe_init();

  /* Initialize the game */
  /* Create the game */
  memset(&game, 0, sizeof(game_t));

  /* Create the paddle */
  init_paddle(&game.paddle, SPECIAL_NONE, (SCREEN_WIDTH/2)-(PADDLE_WIDTH/2));

  /* Init the balls (only one active) */
  init_ball(&game.p_balls[0], game.paddle.x+(PADDLE_WIDTH/2), PADDLE_Y-PADDLE_HEIGHT, BALL_STATE_ACTIVE|BALL_STATE_HOLDING);
  game.nr_balls = 1;

  /* Init the specials */
  game.lives = NR_LIVES;

  /* Set the numbe of levels */
  if (fe_load_data(game.p_levels, 0, (FIELD_WIDTH+1)*FIELD_HEIGHT, "Zarkanoid"))
    fe_finalize(); /* Could not load the levels */
  game.levels = (game.p_levels[0]-'0')*10+(game.p_levels[1]-'0'); /* Number of levels */
  game.level = 5*((game.p_levels[3]-'0')*10+(game.p_levels[4]-'0')); /* Starting level (skip 5 levels at a time) */

#if defined(TARGET_SDL)
  /* Set the level to start at to the argument */
  if (argc > 1)
    game.level = atoi(argv[1]);
#endif

  /* Load the first level */
  goto_level(&game);

  /* Draw the game screen */
  draw_screen(&game);

  fe_sleep(100);
  /* Start the game */
  do_game(&game);


  /* Clean up afterwards */
  fe_finalize();

#if defined(TARGET_SDL)
  return 0;
#endif
}
Exemple #2
0
int main(void)
{
  game_t game;
  menu_t main_menu;
  VMGPFONT small_font;
  int submenus[1];
  bool_t done = FALSE;

  small_font.width = 4;
  small_font.height = 6;
  small_font.bpp = 1;
  small_font.palindex = 1;
  small_font.chartbl = SMALL_FONT+16; /* Which characters are present in the font? */
  small_font.fontdata = SMALL_FONT+16+256; /* The pixel data */

  get_screen_size(&screen_w, &screen_h);

  game_init(&game);

  menu_init(&main_menu, &small_font, main_menu_msgs,
	    0, game.p_title_screen->height, screen_w, screen_h);


  while (!done)
    {
      /* Display title screen */
      vSetTransferMode(MODE_BLOCK);
      vClearScreen(vRGB(0,0,0));
      vDrawObject(0,0, game.p_title_screen);

      switch(menu_select(&main_menu, ~0, submenus))
	{
	case 1:
	  break;
	case 6:
	  return 1;
	case -1:
	default:
	  break;
	}

      vSetTransferMode(MODE_TRANS);
      vPlayResource(NULL,0,SOUND_FLAG_STOP);

      level_goto(&game, &levels[submenus[0]], pt(0, 80));
      do_game(&game);
    }

  return 0;
}
Exemple #3
0
void start_game()
{
  CHAR_DATA *i;
  DESCRIPTOR_DATA *d;
    
  for (d = first_descriptor; d; d = d->next)
  {
  if( d->connected == CON_PLAYING )
  {
    i = d->character;
    if (IS_SET(i->in_room->room_flags2, ROOM_ARENA))
    {
       send_to_char("\r\nThe floor falls out from bellow, droping you in the arena\r\n", i);
       char_from_room(i);
//      i->pcdata->oldac = i->armor;
//       i->armor = -1500;
       char_to_room(i, get_room_index( ARENA_START));
       do_look(i,"auto");
    }
  }
 }
  do_game();
}
Exemple #4
0
int main(int argc, char* argv[]){
  int x, y, result;

  int ch;
  while ((ch = getopt(argc, argv, "bpthro:123T?")) != -1) {
    switch (ch) {
    case 'b': show_board_status = FALSE;  break;
    case 'p': show_placed_tile = TRUE; break;
    case 't': show_available_tiles = FALSE; break;
    case 'h': show_hint = TRUE; break;
    case 'r': first_player = 2; break; // player 2 moves first
    case '1': on_serial = 1; break; // player 1 on serial
    case '2': on_serial = 2; break; // player 2 on serial
    case '3': on_serial = 3; break; // both player on serial
    case 'T': use_tcp = TRUE; break; // use TCP
    case 'o': move_timeout = atoi(optarg); break; // set timeout
    case '?':
    default:
      usage();
      return 0;
    }
  }

  init_serial();

  printf(">> %s %s vs %s %s \n", 
	 team_ids[0], ((first_player==1) ? "*" : ""),
	 team_ids[1], ((first_player==2) ? "*" : ""));

  // ------------------------------
  // clear board & available pieces

  for(y=0; y<16; y++)
    for(x=0; x<16; x++)
      board[y][x] = 0;

  for(y=0; y<2; y++)
    for(x=0; x<21; x++)
      available[y][x] = 1;

  // setup board: border is already filled
  for(x=0; x<16; x++){
    board[ 0][ x] = BORDER;
    board[15][ x] = BORDER;
    board[ x][ 0] = BORDER;
    board[ x][15] = BORDER;
  }

#ifdef DEBUG_FILL
  // for test (some grids already occupied on start)
  for(y=7; y<=14; y++)
    for(x=12; x<=14; x++)
      board[y][x] = 2;

  for(y=12; y<=14; y++)
    for(x=7; x<=14; x++)
      board[y][x] = 2;
#endif

#ifdef DEBUG_LESS_TILES
  for(x=5; x<21; x++){
    available[0][x] = 0;
    available[1][x] = 0;
  }
#endif


  switch(result = do_game()){
    int a1, a2;
    
  case TERMINATE_NORMAL:
    a1 = remaining_size(1);
    a2 = remaining_size(2);
    
    printf("** Total remaining size: %d / %d. ", a1, a2);
    if(a1 != a2)
      printf("Player %d won the game!\n", ( (a1<a2) ? 1 : 2 ) );
    else
      printf("Draw game.\n");
    break;

  case 1:
  case 2:
    printf("** Player %d lost the game by violation.\n", result);
    break;

  default:
  case TERMINATE_WRONG:
    printf("** Game terminated unexpectedly.\n");
    break;
  }
  
  close_serial();
  return 0;
}
Exemple #5
0
// Entry point
int main(int argc, char *argv[])
{
	// Initialize SDL's subsystems - in this case, only video.
	if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) 
	{
		fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
		exit(1);
	}

	// Register SDL_Quit to be called at exit; makes sure things are
	// cleaned up when we quit.
	atexit(SDL_Quit);

	Uint32 maybe_fullscreen;
	maybe_fullscreen = USE_FULLSCREEN ? SDL_FULLSCREEN : 0;

	// Attempt to create a window.
	screen = SDL_SetVideoMode(DISPLAY_WIDTH, DISPLAY_HEIGHT, 32, SDL_SWSURFACE | maybe_fullscreen);

	// If we fail, return error.
	if ( screen == NULL ) {
		fprintf(stderr, "Unable to set DISPLAY_WIDTHxDISPLAY_HEIGHT video: %s\n", SDL_GetError());
		exit(1);
	}

	setup();

	// Main loop: loop forever.
	while (1)
	{

		// Fill background black
		SDL_FillRect(screen, 0, 0);

		// advance game
		do_game();

		// Render stuff
		render();

		// Poll for events, and handle the ones we care about.
		SDL_Event event;
		while (SDL_PollEvent(&event)) 
		{
			switch (event.type) 
			{
				case SDL_KEYDOWN:
					switch (event.key.keysym.sym)
					{
						case 119: // W
							plr.y_input += 1;
							break;

						case 115: // S
							plr.y_input -= 1;
							break;

						case 97: // A
							plr.x_input -= 1;
							break;

						case 100: // D
							plr.x_input += 1;
							break;

						case SDLK_RETURN:
							spawn_wall(wal, i_vector(DISPLAY_WIDTH/2, DISPLAY_WIDTH/2), i_vector(plr.face.x, plr.face.y));
							break;

						default:
							break;
					}
					break;

				case SDL_MOUSEMOTION:			/* Mouse moved */
					plr.face.x = event.motion.x;
					plr.face.y = event.motion.y;

					// keep mouse in window
					if (event.motion.x < PLAYER_BOUND_WIDTH) 
						SDL_WarpMouse(PLAYER_BOUND_WIDTH,event.motion.y);

					if (event.motion.x > DISPLAY_WIDTH - PLAYER_BOUND_WIDTH) 
						SDL_WarpMouse(DISPLAY_WIDTH - PLAYER_BOUND_WIDTH,event.motion.y);

					if (event.motion.y < PLAYER_BOUND_WIDTH) 
						SDL_WarpMouse(event.motion.x,PLAYER_BOUND_WIDTH);

					if (event.motion.y > DISPLAY_HEIGHT - PLAYER_BOUND_WIDTH) 
						SDL_WarpMouse(event.motion.x,DISPLAY_HEIGHT - PLAYER_BOUND_WIDTH);

					break;

				case SDL_MOUSEBUTTONDOWN:		/* Mouse button pressed */
					plr.fire = 1;
					break;

				case SDL_MOUSEBUTTONUP:		/* Mouse button released */
					plr.fire = 0;
					break;

				case SDL_KEYUP:
					switch (event.key.keysym.sym)
					{
						case 119: // W
							plr.y_input -= 1;
							break;

						case 115: // S
							plr.y_input += 1;
							break;

						case 97: // A
							plr.x_input += 1;
							break;

						case 100: // D
							plr.x_input -= 1;
							break;

						default:
							break;
					}

					// If escape is pressed, return (and thus, quit)
					if (event.key.keysym.sym == SDLK_ESCAPE)
						return 0;
					break;

				case SDL_QUIT:
					return(0);
			}
		}
	}
	return 0;
}