Пример #1
0
static short	check_team_exists(t_env *e, t_players *player, char *team)
{
  t_teams	*current;

  current = e->params->teams;
  while (current)
    {
      if (strcmp(team, current->name) == 0)
	return (current->id_team);
      else if (strcmp(team, CLIENT_GRAPHIC) == 0)
	return (add_graphic(e, player));
      current = current->next;
    }
  return (0);
}
// ********************************************************************************************** //
//                                                                                                //
// ********************************************************************************************** //
classPlayer::classPlayer(std::string set_name, int playerNumber) : teleporter_n(-1), selected_weapon(WEAPON_DEFAULT), l_key_released(true), r_key_released(true)
{
	_number = playerNumber-1;
	max_projectiles = game_data.players[_number].max_shots;
    //std::cout << "classPlayer::classPlayer - max_projectiles: " << max_projectiles << std::endl;
	position.y = -TILESIZE;
	position.x = 80;
	hit_duration = 2500;
	//hitPoints.total = game_data.players[_number].HP;
	hitPoints.total = PLAYER_INITIAL_HP;
	hitPoints.current = hitPoints.total;
	name = set_name;
	add_graphic();
	init_weapon_colors();
	initFrames();
	shield_type = SHIELD_FRONT; /// @TODO: from editor
	// load items from save
	if (game_data.players[_number].can_slide == true) {
		slide_type = 1;
	}
    _jump_accel = game_data.players[_number].jump_gravity;
    move_speed = game_data.players[_number].move_speed/10;

    double temp_move_speed = game_data.players[_number].move_speed;
    temp_move_speed = temp_move_speed / 10;
    double intpart;
    double fractpart = modf(temp_move_speed , &intpart);


    if (fractpart > 0) { // calculates how many frames we need to give an extra pixel movement
        _fractional_move_speed = 10 - fractpart*10;
    }

    std::cout << ">>>>>>>>>>>>> move_speed: " << move_speed << ", fractpart: " << fractpart << ", _fractional_move_speed: " << _fractional_move_speed << std::endl;

    _touch_damage_reductor = game_data.players[_number].touch_damage_reduction;
    if (_touch_damage_reductor > 0) {
        _hit_move_back_dist = TILESIZE;
    }
    _charged_shot_projectile_id = game_data.players[_number].full_charged_projectile_id;
    //std::cout << "Player[" << name << "].jump_gravity: " << _jump_accel << std::endl;
    _simultaneous_shots = game_data.players[_number].simultaneous_shots;
}