Ejemplo n.º 1
0
// ZZZ: split out from update_world()'s loop.
static int
update_world_elements_one_tick()
{
	if (m1_solo_player_in_terminal()) 
	{
		update_m1_solo_player_in_terminal(GameQueue);
	} 
	else
	{
		L_Call_Idle();
		
		update_lights();
		update_medias();
		update_platforms();
		
		update_control_panels(); // don't put after update_players
		update_players(GameQueue, false);
		move_projectiles();
		move_monsters();
		update_effects();
		recreate_objects();
		
		handle_random_sound_image();
		animate_scenery();
		
		// LP additions:
		if (film_profile.animate_items)
		{
			animate_items();
		}
		
		AnimTxtr_Update();
		ChaseCam_Update();
		motion_sensor_scan();
		check_m1_exploration();
		
#if !defined(DISABLE_NETWORKING)
		update_net_game();
#endif // !defined(DISABLE_NETWORKING)
	}

        if(check_level_change()) 
        {
                return kUpdateChangeLevel;
        }

#if !defined(DISABLE_NETWORKING)
        if(game_is_over())
        {
                return kUpdateGameOver;
        }
#endif // !defined(DISABLE_NETWORKING)

        dynamic_world->tick_count+= 1;
        dynamic_world->game_information.game_time_remaining-= 1;
        
        return kUpdateNormalCompletion;
}
Ejemplo n.º 2
0
Archivo: game.c Proyecto: phoboz/edom
void play(int start_level)
{
  coord opx, opy;
  BOOL quit = 0;
  
  /*
   * Build the current level.
   *
   * XXXX: Once it is possible to save/restore the map this no longer
   *       must be done if the game was started by restoring a save file.
   */
  d.dl = start_level;
  build_map();
  create_population();
  build_monster_map();
  d.visited[0] = TRUE;
  
  /* Initial player position. */
  place_player(d.stxu[d.dl], d.styu[d.dl]);

  /* Initial panel position. */
  d.psx = d.psy = 0;

  /*
   * Standard stuff.
   */
  
  do
  {
    /* Print all the new things. */
    update_screen(d.px, d.py);

    /* The message line should be cleared in any case. */
    clear_messages();
    
    /* Memorize the old PC position. */
    opx = d.px;
    opy = d.py;

    SDL_Event event;

    while (SDL_PollEvent(&event))
    {
      if (event.type == SDL_QUIT)
        quit = TRUE;

      if (event.type == SDL_KEYDOWN)
        game_keydown(event.key.keysym.sym);
    }

    int input = get_input();

    if (input & PRESS_ESC)
      quit = TRUE;

    BOOL player_turn = move_monsters();

    if (player_turn && d.pa.act == IDLE)
    {
      if (input & PRESS_LEFT)
      {
        set_dir_actor(&d.pa, LEFT);
        if (is_open(d.px - 1, d.py) &&
            !is_monster_at(d.px - 1, d.py))
          move_player(LEFT);
      }
      else if (input & PRESS_RIGHT)
      {
        set_dir_actor(&d.pa, RIGHT);
        if (is_open(d.px + 1, d.py) &&
            !is_monster_at(d.px + 1, d.py))
          move_player(RIGHT);
      }
      else if (input & PRESS_UP)
      {
        set_dir_actor(&d.pa, UP);
        if (is_open(d.px, d.py - 1) &&
            !is_monster_at(d.px, d.py - 1))
          move_player(UP);
      }
      else if (input & PRESS_DOWN)
      {
        set_dir_actor(&d.pa, DOWN);
        if (is_open(d.px, d.py + 1) &&
            !is_monster_at(d.px, d.py + 1))
          move_player(DOWN);
      }
    }
    else if (d.pa.act == MOVE)
    {
      animate_move_actor(&d.pa);
    }
    else if (d.pa.act == CHARGE)
    {
      animate_charge_actor(&d.pa);
    }
    else if (d.pa.act == ATTACK)
    {
      if (animate_attack_actor(&d.pa))
        attack_monster_at(d.pa.tx, d.pa.ty);
    }

    d.opx = opx;
    d.opy = opy;
  }
  while (quit == FALSE);
}