diff --git a/Bonus.cpp b/Bonus.cpp deleted file mode 100644 index 72e3ba5..0000000 --- a/Bonus.cpp +++ /dev/null @@ -1,11 +0,0 @@ -// -// Created by Иван Ильин on 05.06.2021. -// - -#include "Bonus.h" - -Bonus::Bonus(const std::string &bonusName, const std::string &filename, const Vec3D &scale) { - _name = bonusName; - loadObj(filename, scale); - setCollider(false); -} diff --git a/Bonus.h b/Bonus.h deleted file mode 100644 index 3c09bc0..0000000 --- a/Bonus.h +++ /dev/null @@ -1,21 +0,0 @@ -// -// Created by Иван Ильин on 05.06.2021. -// - -#ifndef SHOOTER_BONUS_H -#define SHOOTER_BONUS_H - -#include "engine/World.h" -#include "Player.h" - -class Bonus final : public RigidBody { -private: - std::string _name; -public: - explicit Bonus(const std::string &bonusName, const std::string& filename, const Vec3D& scale = Vec3D{1, 1, 1}); - - [[nodiscard]] std::string name() const { return _name; } -}; - - -#endif //SHOOTER_3DZAVR_BONUS_H diff --git a/CMakeLists.txt b/CMakeLists.txt index 35440d5..42c8c21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,8 +22,6 @@ add_executable(shooter weapon/Shotgun.h weapon/Gun.cpp weapon/Gun.h - Bonus.cpp - Bonus.h weapon/Gold_Ak47.h weapon/Rifle.cpp weapon/Rifle.h @@ -34,8 +32,8 @@ add_executable(shooter ShooterConsts.h # 3d engine: engine/Consts.h - engine/Point4D.h - engine/Point4D.cpp + engine/Vec4D.h + engine/Vec4D.cpp engine/Vec3D.cpp engine/Vec3D.h engine/Vec2D.cpp @@ -97,7 +95,7 @@ add_executable(shooter engine/network/UDPConnection.h engine/network/UDPSocket.cpp engine/network/UDPSocket.h - engine/SoundController.cpp engine/SoundController.h) + engine/SoundController.cpp engine/SoundController.h ShooterMsgType.h ShooterMsgType.cpp) if(APPLE OR UNIX) include_directories(/usr/local/include) diff --git a/Client.cpp b/Client.cpp index 71b6ac4..bd67a9b 100644 --- a/Client.cpp +++ b/Client.cpp @@ -6,13 +6,13 @@ #include #include "engine/utils/Log.h" -#include "Bonus.h" #include "engine/animation/Timeline.h" #include "engine/animation/ATranslateToPoint.h" +#include "ShooterMsgType.h" void Client::updatePacket() { sf::Packet packet; - packet << MsgType::ClientUpdate << _player->position().x() << _player->position().y() << _player->position().z() << _player->angle().y() << _player->headAngle() << _player->playerName(); + packet << MsgType::ClientUpdate << _player->position().x() << _player->position().y() << _player->position().z() << _player->angle().y() << _player->headAngle() << _player->playerNickName(); _socket.send(packet, _socket.serverId()); } @@ -24,8 +24,9 @@ void Client::processInit(sf::Packet& packet) { while (packet >> targetId >> buf[0] >> buf[1] >> buf[2] >> buf[3] >> kills >> deaths) { if(targetId != _socket.ownId()) { - if(_spawnPlayerCallBack != nullptr) + if(_spawnPlayerCallBack != nullptr) { _spawnPlayerCallBack(targetId); + } _players[targetId]->translateToPoint(Vec3D{ buf[0], buf[1], buf[2]}); _players[targetId]->setHealth(buf[3]); @@ -42,24 +43,23 @@ void Client::processUpdate(sf::Packet& packet) { while (packet >> targetId >> buf[0] >> buf[1] >> buf[2] >> buf[3] >> buf[4] >> buf[5] >> playerName) { if (_players.count(targetId)) { - std::string tagName = "Player_" + std::to_string(targetId); + std::string name = "Enemy_" + std::to_string(targetId); - // old approach (no animation): - //_players[targetId]->translateToPoint(Vec3D{buf[0], buf[1], buf[2]}); - - // new approach (linear extrapolational animations) - double duration = 1.0 / Consts::NETWORK_WORLD_UPDATE_RATE; - Timeline::animate(AnimationListTag(tagName + "_linearTranslation"), new ATranslateToPoint(_players[targetId], Vec3D{buf[0], buf[1], buf[2]}, duration, Animation::LoopOut::None, Animation::InterpolationType::linear)); + _players[targetId]->translateToPoint(Vec3D{buf[0], buf[1], buf[2]}); _players[targetId]->setHealth(buf[3]); _players[targetId]->rotateToAngle(Vec3D{0, buf[4], 0}); - _players[targetId]->setPlayerName(playerName); + _players[targetId]->setPlayerNickName(playerName); - auto head = _players[targetId]->attached(ObjectNameTag("head")); - auto weapon = _players[targetId]->attached(ObjectNameTag("Weapon")); + auto head = _players[targetId]->attached(ObjectNameTag(name + "_head")); + auto weapon = _players[targetId]->attached(ObjectNameTag("Enemy_" + std::to_string(targetId) + "_weapon")); - head->rotateLeft(buf[5] - _players[targetId]->headAngle()); - weapon->rotateLeft(-(buf[5] - _players[targetId]->headAngle())); + if(head != nullptr) { + head->rotateLeft(buf[5] - _players[targetId]->headAngle()); + } + if(weapon != nullptr) { + weapon->rotateLeft(-(buf[5] - _players[targetId]->headAngle())); + } _players[targetId]->setHeadAngle(buf[5]); } else if (targetId == _socket.ownId()) { @@ -73,8 +73,9 @@ void Client::processNewClient(sf::Packet& packet) { packet >> targetId; - if(_spawnPlayerCallBack != nullptr) + if(_spawnPlayerCallBack != nullptr) { _spawnPlayerCallBack(targetId); + } } void Client::processDisconnect(sf::Uint16 targetId) { @@ -85,23 +86,26 @@ void Client::processDisconnect(sf::Uint16 targetId) { } -void Client::processCustomPacket(MsgType type, sf::Packet& packet) { +void Client::processCustomPacket(sf::Packet& packet) { sf::Uint16 buffId[2]; double dbuff[10]; std::string tmp, tmp2; + ShooterMsgType type; + packet >> type; + switch (type) { - case MsgType::Kill: + case ShooterMsgType::Kill: packet >> buffId[0] >> buffId[1]; _lastEvent = ""; if(buffId[1] == _socket.ownId()) { _player->addKill(); SoundController::playSound(SoundTag("kill"), ShooterConsts::KILL_SOUND); - _lastEvent += _player->playerName(); + _lastEvent += _player->playerNickName(); } else { _players[buffId[1]]->addKill(); - _lastEvent += _players[buffId[1]]->playerName(); + _lastEvent += _players[buffId[1]]->playerNickName(); } _lastEvent += " ~> "; @@ -112,45 +116,51 @@ void Client::processCustomPacket(MsgType type, sf::Packet& packet) { _player->initWeapons(); _player->setFullAbility(); SoundController::playSound(SoundTag("death"), ShooterConsts::DEATH_SOUND); - _lastEvent += _player->playerName(); + _lastEvent += _player->playerNickName(); } else { _players[buffId[0]]->addDeath(); - _lastEvent += _players[buffId[0]]->playerName(); + _lastEvent += _players[buffId[0]]->playerNickName(); } break; - case MsgType::FireTrace: + case ShooterMsgType::FireTrace: packet >> dbuff[0] >> dbuff[1] >> dbuff[2] >> dbuff[3] >> dbuff[4] >> dbuff[5]; - if(_addFireTraceCallBack != nullptr) + if(_addFireTraceCallBack != nullptr) { _addFireTraceCallBack(Vec3D(dbuff[0], dbuff[1], dbuff[2]), Vec3D(dbuff[3], dbuff[4], dbuff[5])); + } break; - case MsgType::InitBonuses: + case ShooterMsgType::InitBonuses: while (packet >> tmp >> dbuff[0] >> dbuff[1] >> dbuff[2]) { - if(_addBonusCallBack != nullptr) + if(_addBonusCallBack != nullptr) { _addBonusCallBack(tmp, Vec3D(dbuff[0], dbuff[1], dbuff[2])); + } } break; - case MsgType::AddBonus: + case ShooterMsgType::AddBonus: packet >> tmp >> dbuff[0] >> dbuff[1] >> dbuff[2]; - if(_addBonusCallBack != nullptr) + if(_addBonusCallBack != nullptr) { _addBonusCallBack(tmp, Vec3D(dbuff[0], dbuff[1], dbuff[2])); + } break; - case MsgType::RemoveBonus: + case ShooterMsgType::RemoveBonus: packet >> tmp; - if(_removeBonusCallBack != nullptr) + if(_removeBonusCallBack != nullptr) { _removeBonusCallBack(ObjectNameTag(tmp)); + } break; - case MsgType::ChangeWeapon: + case ShooterMsgType::ChangeWeapon: packet >> buffId[0] >> tmp; - if(_changeEnemyWeaponCallBack != nullptr) + if(_changeEnemyWeaponCallBack != nullptr) { _changeEnemyWeaponCallBack(tmp, buffId[0]); + } break; default: + Log::log("Client::processCustomPacket: unknown message type " + std::to_string(static_cast(type))); return; } } @@ -164,7 +174,7 @@ void Client::processDisconnected() { void Client::damagePlayer(sf::Uint16 targetId, double damage) { sf::Packet packet; - packet << MsgType::Damage << targetId << damage; + packet << MsgType::Custom << ShooterMsgType::Damage << targetId << damage; _socket.sendRely(packet, _socket.serverId()); Log::log("Client: damagePlayer " + std::to_string(targetId) + " ( -" + std::to_string(damage) + "hp )"); @@ -173,24 +183,25 @@ void Client::damagePlayer(sf::Uint16 targetId, double damage) { void Client::addTrace(const Vec3D& from, const Vec3D& to) { sf::Packet packet; - packet << MsgType::FireTrace << from.x() << from.y() << from.z() << to.x() << to.y() << to.z(); + packet << MsgType::Custom << ShooterMsgType::FireTrace << from.x() << from.y() << from.z() << to.x() << to.y() << to.z(); _socket.send(packet, _socket.serverId()); } void Client::takeBonus(const std::string& bonusName) { sf::Packet packet; - packet << MsgType::RemoveBonus << bonusName; + packet << MsgType::Custom << ShooterMsgType::RemoveBonus << bonusName; _socket.sendRely(packet, _socket.serverId()); - if(_removeBonusCallBack != nullptr) + if(_removeBonusCallBack != nullptr) { _removeBonusCallBack(ObjectNameTag(bonusName)); + } } void Client::changeWeapon(const std::string &weaponName) { sf::Packet packet; - packet << MsgType::ChangeWeapon << weaponName; + packet << MsgType::Custom << ShooterMsgType::ChangeWeapon << weaponName; _socket.sendRely(packet, _socket.serverId()); } diff --git a/Client.h b/Client.h index 5dc3598..ae5b5f8 100644 --- a/Client.h +++ b/Client.h @@ -39,7 +39,7 @@ public: void processNewClient(sf::Packet& packet) override; void processDisconnect(sf::Uint16 targetId) override; - void processCustomPacket(MsgType type, sf::Packet& packet) override; + void processCustomPacket(sf::Packet& packet) override; void processDisconnected() override; diff --git a/Player.cpp b/Player.cpp index db36fb7..d3bfe99 100644 --- a/Player.cpp +++ b/Player.cpp @@ -7,7 +7,7 @@ #include "engine/ResourceManager.h" #include "engine/utils/Log.h" -Player::Player() { +Player::Player(ObjectNameTag name) : RigidBody(name) { loadObj(ShooterConsts::CUBE_OBJ, Vec3D{0.5, 1.9, 0.5}); setAcceleration(Vec3D{0, -ShooterConsts::GRAVITY, 0}); setCollision(true); @@ -18,31 +18,39 @@ Player::Player() { } void Player::rotateWeaponsRelativePoint(const Vec3D& point4D, const Vec3D& v, double val) { - for(auto& weapon : _weapons) + for(auto& weapon : _weapons) { weapon->rotateRelativePoint(point4D, v, val); + } } void Player::collisionWithObject(const ObjectNameTag& tag, std::shared_ptr obj) { - if(tag.str().find("Bonus_gun") != std::string::npos) + if(tag.str().find("Bonus_gun") != std::string::npos) { addWeapon(std::make_shared()); + } - if(tag.str().find("Bonus_shotgun") != std::string::npos) + if(tag.str().find("Bonus_shotgun") != std::string::npos) { addWeapon(std::make_shared()); + } - if(tag.str().find("Bonus_ak47") != std::string::npos) + if(tag.str().find("Bonus_ak47") != std::string::npos) { addWeapon(std::make_shared()); + } - if(tag.str().find("Bonus_gold_ak47") != std::string::npos) + if(tag.str().find("Bonus_gold_ak47") != std::string::npos) { addWeapon(std::make_shared()); + } - if(tag.str().find("Bonus_rifle") != std::string::npos) + if(tag.str().find("Bonus_rifle") != std::string::npos) { addWeapon(std::make_shared()); + } - if(tag.str().find("Bonus_hill") != std::string::npos) + if(tag.str().find("Bonus_hill") != std::string::npos) { setFullHealth(); + } - if(tag.str().find("Bonus_ability") != std::string::npos) + if(tag.str().find("Bonus_ability") != std::string::npos) { setFullAbility(); + } if(tag.str().find("Bonus") != std::string::npos) { _takeBonusCallBack(tag.str()); @@ -60,10 +68,10 @@ void Player::addWeapon(std::shared_ptr weapon) { } _weapons.push_back(weapon); - attach(weapon, ObjectNameTag(weapon->name())); + attach(weapon); _weapons.back()->translate(position()); - _weapons.back()->rotateRelativePoint(position() + Vec3D{0, 1.8, 0}, Vec3D{0, 1, 0}, _angle->y()); + _weapons.back()->rotateRelativePoint(position() + Vec3D{0, 1.8, 0}, Vec3D{0, 1, 0}, _angle.y()); _weapons.back()->rotateRelativePoint(position() + Vec3D{0, 1.8, 0}, left(), headAngle()); _weapons.back()->setAddTraceCallBack(_addTraceCallBack); @@ -72,8 +80,9 @@ void Player::addWeapon(std::shared_ptr weapon) { void Player::initWeapons() { if(!_weapons.empty()) { - for(auto weapon : _weapons) + for(auto weapon : _weapons) { unattach(ObjectNameTag(weapon->name())); + } _removeWeaponCallBack(_weapons[_selectedWeapon]); _weapons.clear(); @@ -99,10 +108,11 @@ void Player::previousWeapon() { if(_weapons.size() > 1) { // change '_selectedWeapon' _removeWeaponCallBack(_weapons[_selectedWeapon]); - if (_selectedWeapon > 0) + if (_selectedWeapon > 0) { _selectedWeapon = (_selectedWeapon - 1) % _weapons.size(); - else + } else { _selectedWeapon = _weapons.size() - 1; + } _addWeaponCallBack(_weapons[_selectedWeapon]); Log::log("selectedWeapon " + std::to_string(_selectedWeapon)); SoundController::playSound(SoundTag("changeWeapon"), ShooterConsts::CHANGE_WEAPON_SOUND); diff --git a/Player.h b/Player.h index bb5cf40..5564726 100644 --- a/Player.h +++ b/Player.h @@ -30,7 +30,7 @@ private: std::vector> _weapons; size_t _selectedWeapon = 0; - std::string _name = ShooterConsts::PLAYER_NAME; + std::string _nickName = ShooterConsts::PLAYER_NAME; std::function _damagePlayerCallBack; std::function _addTraceCallBack; @@ -41,7 +41,7 @@ private: std::function _rayCastFunction; public: - Player(); + explicit Player(ObjectNameTag name); void setHealth(double h) { _health = h; } void setAbility(double a) { _ability = a; } @@ -100,8 +100,8 @@ public: void collisionWithObject(const ObjectNameTag& tag, std::shared_ptr obj); - [[nodiscard]] std::string playerName() const { return _name; } - void setPlayerName(const std::string& name) { _name = name; } + [[nodiscard]] std::string playerNickName() const { return _nickName; } + void setPlayerNickName(const std::string& name) { _nickName = name; } }; diff --git a/PlayerController.cpp b/PlayerController.cpp index 6fe3081..1c462e4 100644 --- a/PlayerController.cpp +++ b/PlayerController.cpp @@ -4,12 +4,10 @@ #include "PlayerController.h" #include "engine/utils/Log.h" -#include "engine/animation/AFunction.h" #include "engine/animation/AWait.h" #include "engine/animation/ATranslate.h" #include "engine/animation/ATranslateToPoint.h" #include "engine/animation/Timeline.h" -#include "engine/animation/ARotate.h" #include "ShooterConsts.h" PlayerController::PlayerController(std::shared_ptr player, @@ -18,13 +16,14 @@ PlayerController::PlayerController(std::shared_ptr player, void PlayerController::update() { // friction - if(_player->inCollision()) - _player->setVelocity(_player->velocity()*(1.0 - Time::deltaTime() * 2)); + if(_player->inCollision()) { + _player->setVelocity(_player->velocity() * (1.0 - Time::deltaTime() * 2)); + } if(_isInSlowMo) { - if(_player->ability() > 0) + if(_player->ability() > 0) { _player->setAbility(_player->ability() - Time::deltaTime()); - else { + } else { _player->setAbility(0); _isInSlowMo = false; _player->setVelocity(_player->velocity() * ShooterConsts::SLOW_MO_COEFFICIENT); @@ -45,52 +44,56 @@ void PlayerController::update() { std::shared_ptr camera = _player->attached(ObjectNameTag("Camera")); if(camera != nullptr && _inRunning && _player->inCollision()) { if (!Timeline::isInAnimList(AnimationListTag("camera_hor_oscil"))) { - Timeline::animate(AnimationListTag("camera_hor_oscil"), new ATranslate(camera, -camera->left() / 6, 0.3,Animation::LoopOut::None, Animation::InterpolationType::cos)); + Timeline::animate(AnimationListTag("camera_hor_oscil"), new ATranslate(camera, -camera->left() / 6, 0.3,Animation::LoopOut::None, Animation::InterpolationType::Cos)); Timeline::animate(AnimationListTag("camera_hor_oscil"), new AWait(0)); - Timeline::animate(AnimationListTag("camera_hor_oscil"), new ATranslate(camera, camera->left() / 6, 0.3, Animation::LoopOut::None, Animation::InterpolationType::cos)); + Timeline::animate(AnimationListTag("camera_hor_oscil"), new ATranslate(camera, camera->left() / 6, 0.3, Animation::LoopOut::None, Animation::InterpolationType::Cos)); - Timeline::animate(AnimationListTag("camera_vert_oscil"), new ATranslate(camera, -Vec3D{0, 1, 0} / 12, 0.15, Animation::LoopOut::None, Animation::InterpolationType::cos)); + Timeline::animate(AnimationListTag("camera_vert_oscil"), new ATranslate(camera, -Vec3D{0, 1, 0} / 12, 0.15, Animation::LoopOut::None, Animation::InterpolationType::Cos)); Timeline::animate(AnimationListTag("camera_vert_oscil"), new AWait(0)); - Timeline::animate(AnimationListTag("camera_vert_oscil"), new ATranslate(camera, Vec3D{0, 1, 0} / 12, 0.15, Animation::LoopOut::None, Animation::InterpolationType::cos)); + Timeline::animate(AnimationListTag("camera_vert_oscil"), new ATranslate(camera, Vec3D{0, 1, 0} / 12, 0.15, Animation::LoopOut::None, Animation::InterpolationType::Cos)); Timeline::animate(AnimationListTag("camera_vert_oscil"), new AWait(0)); - Timeline::animate(AnimationListTag("camera_vert_oscil"), new ATranslate(camera, -Vec3D{0, 1, 0} / 12, 0.15, Animation::LoopOut::None, Animation::InterpolationType::cos)); + Timeline::animate(AnimationListTag("camera_vert_oscil"), new ATranslate(camera, -Vec3D{0, 1, 0} / 12, 0.15, Animation::LoopOut::None, Animation::InterpolationType::Cos)); Timeline::animate(AnimationListTag("camera_vert_oscil"), new AWait(0)); - Timeline::animate(AnimationListTag("camera_vert_oscil"), new ATranslate(camera, Vec3D{0, 1, 0} / 12, 0.15, Animation::LoopOut::None, Animation::InterpolationType::cos)); + Timeline::animate(AnimationListTag("camera_vert_oscil"), new ATranslate(camera, Vec3D{0, 1, 0} / 12, 0.15, Animation::LoopOut::None, Animation::InterpolationType::Cos)); - Timeline::animate(AnimationListTag("camera_init"), new ATranslateToPoint( camera, _player->position() + Vec3D{0, 1.8, 0}, 0.3, Animation::LoopOut::None, Animation::InterpolationType::cos)); + Timeline::animate(AnimationListTag("camera_init"), new ATranslateToPoint( camera, _player->position() + Vec3D{0, 1.8, 0}, 0.3, Animation::LoopOut::None, Animation::InterpolationType::Cos)); } } else if(camera != nullptr && inRunning_old && !_inRunning) { Timeline::deleteAnimationList(AnimationListTag("camera_hor_oscil")); Timeline::deleteAnimationList(AnimationListTag("camera_vert_oscil")); Timeline::deleteAnimationList(AnimationListTag("camera_init")); - Timeline::animate(AnimationListTag("camera_init"), new ATranslateToPoint( camera, _player->position() + Vec3D{0, 1.8, 0}, 0.15, Animation::LoopOut::None, Animation::InterpolationType::cos)); + Timeline::animate(AnimationListTag("camera_init"), new ATranslateToPoint( camera, _player->position() + Vec3D{0, 1.8, 0}, 0.15, Animation::LoopOut::None, Animation::InterpolationType::Cos)); } // Left and right if (Keyboard::isKeyPressed(sf::Keyboard::A)) { _player->translate(_player->left() * Time::deltaTime() * ShooterConsts::WALK_SPEED * coeff); - if(_player->inCollision()) - _player->setVelocity(Vec3D{0,0,0}); + if(_player->inCollision()) { + _player->setVelocity(Vec3D{0, 0, 0}); + } } if (Keyboard::isKeyPressed(sf::Keyboard::D)) { _player->translate(-_player->left() * Time::deltaTime() * ShooterConsts::WALK_SPEED * coeff); - if(_player->inCollision()) - _player->setVelocity(Vec3D{0,0,0}); + if(_player->inCollision()) { + _player->setVelocity(Vec3D{0, 0, 0}); + } } // Forward and backward if (Keyboard::isKeyPressed(sf::Keyboard::W)) { _player->translate(_player->lookAt() * Time::deltaTime() * ShooterConsts::WALK_SPEED * coeff); - if(_player->inCollision()) - _player->setVelocity(Vec3D{0,0,0}); + if(_player->inCollision()) { + _player->setVelocity(Vec3D{0, 0, 0}); + } } if (Keyboard::isKeyPressed(sf::Keyboard::S)) { _player->translate(-_player->lookAt() * Time::deltaTime() * ShooterConsts::WALK_SPEED * coeff); - if(_player->inCollision()) - _player->setVelocity(Vec3D{0,0,0}); + if(_player->inCollision()) { + _player->setVelocity(Vec3D{0, 0, 0}); + } } if (_player->ability() > 0 && !_isInSlowMo && Keyboard::isKeyPressed(sf::Keyboard::LShift)) { @@ -112,19 +115,24 @@ void PlayerController::update() { bool shot = _player->fire(); if(shot) { - if(!_player->inCollision() && (_player->weaponName() == ObjectNameTag("shotgun"))) + if(!_player->inCollision() && (_player->weaponName() == ObjectNameTag("weapon_shotgun"))) { _player->addVelocity(-camera->lookAt() * 30 * coeff); + } } } if (Keyboard::isKeyPressed(sf::Keyboard::Space) && _player->inCollision()) { // if we just want to jump, we have to add particular speed - if (!_isSliding) - _player->addVelocity(Vec3D{ 0, std::abs(_player->collisionNormal().y()) * sqrt(2 * -_player->acceleration().y() * ShooterConsts::JUMP_HEIGHT) * coeff, 0 }); - // if we want to slide, we have to add speed * 60/fps to make it independent on frame rate - else - _player->addVelocity(Vec3D{ 0, std::abs(_player->collisionNormal().y()) * sqrt(2 * -_player->acceleration().y() * ShooterConsts::JUMP_HEIGHT) * coeff * Time::deltaTime() * 60, 0 }); - + if (!_isSliding) { + _player->addVelocity(Vec3D{0, std::abs(_player->collisionNormal().y()) * + sqrt(2 * -_player->acceleration().y() * ShooterConsts::JUMP_HEIGHT) * coeff, + 0}); + // if we want to slide, we have to add speed * 60/fps to make it independent on frame rate + } else { + _player->addVelocity(Vec3D{0, std::abs(_player->collisionNormal().y()) * + sqrt(2 * -_player->acceleration().y() * ShooterConsts::JUMP_HEIGHT) * coeff * + Time::deltaTime() * 60, 0}); + } _player->translate(Vec3D{ 0, Time::deltaTime() * ShooterConsts::WALK_SPEED * 2 * coeff, 0 }); _isSliding = true; } else { @@ -140,16 +148,19 @@ void PlayerController::update() { double rotationLeft = displacement.y() * ShooterConsts::MOUSE_SENSITIVITY; // You can only see in range [-90 : 90] grad - if (_player->headAngle() + rotationLeft > Consts::PI / 2) + if (_player->headAngle() + rotationLeft > Consts::PI / 2) { rotationLeft = Consts::PI / 2 - _player->headAngle(); - if (_player->headAngle() + rotationLeft < -Consts::PI / 2) + } + if (_player->headAngle() + rotationLeft < -Consts::PI / 2) { rotationLeft = -Consts::PI / 2 - _player->headAngle(); + } _player->setHeadAngle(_player->headAngle() + rotationLeft); _player->rotateWeaponsRelativePoint(_player->position() + Vec3D{0, 1.8, 0}, _player->left(), rotationLeft); - if(camera != nullptr) + if(camera != nullptr) { camera->rotateLeft(_player->headAngle() - camera->angleLeftUpLookAt().x()); + } if (_keyboard->isKeyTapped(sf::Keyboard::Right) || _keyboard->isKeyTapped(sf::Keyboard::E)) { _player->nextWeapon(); diff --git a/SFML-VS32/doc/html/classsf_1_1Joystick.html b/SFML-VS32/doc/html/classsf_1_1Joystick.html index f3e035e..2f98f0c 100644 --- a/SFML-VS32/doc/html/classsf_1_1Joystick.html +++ b/SFML-VS32/doc/html/classsf_1_1Joystick.html @@ -106,7 +106,7 @@ Static Public Member Functions  Get the joystick information. More...
  static void update () - Update the states of all joysticks. More...
+ ServerUpdate the states of all joysticks. More...
 

Detailed Description

@@ -119,7 +119,7 @@ Static Public Member Functions
  • 32 buttons per joystick (sf::Joystick::ButtonCount)
  • 8 axes per joystick (sf::Joystick::AxisCount)
  • -

    Unlike the keyboard or mouse, the state of joysticks is sometimes not directly available (depending on the OS), therefore an update() function must be called in order to update the current state of joysticks. When you have a window with event handling, this is done automatically, you don't need to call anything. But if you have no window, or if you want to check joysticks state before creating one, you must call sf::Joystick::update explicitly.

    +

    Unlike the keyboard or mouse, the state of joysticks is sometimes not directly available (depending on the OS), therefore an update() function must be called in order to update the current state of joysticks. When you have a window with event handling, this is done automatically, you don't need to call anything. But if you have no window, or if you want to check joysticks state before creating one, you must call sf::Joystick::update explicitly.

    Usage example:

    // Is joystick #0 connected?
    bool connected = sf::Joystick::isConnected(0);
    // How many buttons does joystick #0 support?
    unsigned int buttons = sf::Joystick::getButtonCount(0);
    // Does joystick #0 define a X axis?
    // Is button #2 pressed on joystick #0?
    bool pressed = sf::Joystick::isButtonPressed(0, 2);
    // What's the current position of the Y axis on joystick #0?
    See also
    sf::Keyboard, sf::Mouse

    Definition at line 41 of file Joystick.hpp.

    @@ -457,7 +457,7 @@ Static Public Member Functions
    -

    Update the states of all joysticks.

    +

    ServerUpdate the states of all joysticks.

    This function is used internally by SFML, so you normally don't have to call it explicitly. However, you may need to call it if you have no window yet (or no window at all): in this case the joystick states are not updated automatically.

    diff --git a/SFML-VS32/doc/html/classsf_1_1RenderTexture.html b/SFML-VS32/doc/html/classsf_1_1RenderTexture.html index fda80b0..e66aaf0 100644 --- a/SFML-VS32/doc/html/classsf_1_1RenderTexture.html +++ b/SFML-VS32/doc/html/classsf_1_1RenderTexture.html @@ -99,7 +99,7 @@ Public Member Functions  Activate or deactivate the render-texture for rendering. More...
      void display () - Update the contents of the target texture. More...
    + ServerUpdate the contents of the target texture. More...
      virtual Vector2u getSize () const  Return the size of the rendering region of the texture. More...
    @@ -376,7 +376,7 @@ Protected Member Functions
    -

    Update the contents of the target texture.

    +

    ServerUpdate the contents of the target texture.

    This function updates the target texture with what has been drawn so far. Like for windows, calling this function is mandatory at the end of rendering. Not calling it may leave the texture in an undefined state.

    diff --git a/SFML-VS32/doc/html/classsf_1_1RenderWindow.html b/SFML-VS32/doc/html/classsf_1_1RenderWindow.html index 4b79f2d..592ba11 100644 --- a/SFML-VS32/doc/html/classsf_1_1RenderWindow.html +++ b/SFML-VS32/doc/html/classsf_1_1RenderWindow.html @@ -403,7 +403,7 @@ Protected Member Functions

    Copy the current contents of the window to an image.

    -
    Deprecated:
    Use a sf::Texture and its sf::Texture::update(const Window&) function and copy its contents into an sf::Image instead.
    +
    Deprecated:
    Use a sf::Texture and its sf::Texture::update(const Window&) function and copy its contents into an sf::Image instead.
    sf::Vector2u windowSize = window.getSize();
    sf::Texture texture;
    texture.create(windowSize.x, windowSize.y);
    texture.update(window);
    sf::Image screenshot = texture.copyToImage();

    This is a slow operation, whose main purpose is to make screenshots of the application. If you want to update an image with the contents of the window and then use it for drawing, you should rather use a sf::Texture and its update(Window&) function. You can also draw things directly to a texture with the sf::RenderTexture class.

    Returns
    Image containing the captured contents
    diff --git a/SFML-VS32/doc/html/classsf_1_1Texture.html b/SFML-VS32/doc/html/classsf_1_1Texture.html index a9928c6..1d6f936 100644 --- a/SFML-VS32/doc/html/classsf_1_1Texture.html +++ b/SFML-VS32/doc/html/classsf_1_1Texture.html @@ -108,28 +108,28 @@ Public Member Functions  Copy the texture pixels to an image. More...
      void update (const Uint8 *pixels) - Update the whole texture from an array of pixels. More...
    + ServerUpdate the whole texture from an array of pixels. More...
      void update (const Uint8 *pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y) - Update a part of the texture from an array of pixels. More...
    + ServerUpdate a part of the texture from an array of pixels. More...
      void update (const Texture &texture) - Update a part of this texture from another texture. More...
    + ServerUpdate a part of this texture from another texture. More...
      void update (const Texture &texture, unsigned int x, unsigned int y) - Update a part of this texture from another texture. More...
    + ServerUpdate a part of this texture from another texture. More...
      void update (const Image &image) - Update the texture from an image. More...
    + ServerUpdate the texture from an image. More...
      void update (const Image &image, unsigned int x, unsigned int y) - Update a part of the texture from an image. More...
    + ServerUpdate a part of the texture from an image. More...
      void update (const Window &window) - Update the texture from the contents of a window. More...
    + ServerUpdate the texture from the contents of a window. More...
      void update (const Window &window, unsigned int x, unsigned int y) - Update a part of the texture from the contents of a window. More...
    + ServerUpdate a part of the texture from the contents of a window. More...
      void setSmooth (bool smooth)  Enable or disable the smooth filter. More...
    @@ -193,7 +193,7 @@ class RenderTarget

    Image living on the graphics card that can be used for drawing.

    sf::Texture stores pixels that can be drawn, with a sprite for example.

    A texture lives in the graphics card memory, therefore it is very fast to draw a texture to a render target, or copy a render target to a texture (the graphics card can access both directly).

    -

    Being stored in the graphics card memory has some drawbacks. A texture cannot be manipulated as freely as a sf::Image, you need to prepare the pixels first and then upload them to the texture in a single operation (see Texture::update).

    +

    Being stored in the graphics card memory has some drawbacks. A texture cannot be manipulated as freely as a sf::Image, you need to prepare the pixels first and then upload them to the texture in a single operation (see Texture::update).

    sf::Texture makes it easy to convert from/to sf::Image, but keep in mind that these calls require transfers between the graphics card and the central memory, therefore they are slow operations.

    A texture can be loaded from an image, but also directly from a file/memory/stream. The necessary shortcuts are defined so that you don't need an image first for the most common cases. However, if you want to perform some modifications on the pixels before creating the final texture, you can load your file to a sf::Image, do whatever you need with the pixels, and then call Texture::loadFromImage.

    Since they live in the graphics card memory, the pixels of a texture cannot be accessed without a slow copy first. And they cannot be accessed individually. Therefore, if you need to read the texture's pixels (like for pixel-perfect collisions), it is recommended to store the collision information separately, for example in an array of booleans.

    @@ -886,7 +886,7 @@ class RenderTarget
    -

    Update the whole texture from an array of pixels.

    +

    ServerUpdate the whole texture from an array of pixels.

    The pixel array is assumed to have the same size as the area rectangle, and to contain 32-bits RGBA pixels.

    No additional check is performed on the size of the pixel array, passing invalid arguments will lead to an undefined behavior.

    This function does nothing if pixels is null or if the texture was not previously created.

    @@ -943,7 +943,7 @@ class RenderTarget
    -

    Update a part of the texture from an array of pixels.

    +

    ServerUpdate a part of the texture from an array of pixels.

    The size of the pixel array must match the width and height arguments, and it must contain 32-bits RGBA pixels.

    No additional check is performed on the size of the pixel array or the bounds of the area to update, passing invalid arguments will lead to an undefined behavior.

    This function does nothing if pixels is null or if the texture was not previously created.

    @@ -976,7 +976,7 @@ class RenderTarget
    -

    Update a part of this texture from another texture.

    +

    ServerUpdate a part of this texture from another texture.

    Although the source texture can be smaller than this texture, this function is usually used for updating the whole texture. The other overload, which has (x, y) additional arguments, is more convenient for updating a sub-area of this texture.

    No additional check is performed on the size of the passed texture, passing a texture bigger than this texture will lead to an undefined behavior.

    This function does nothing if either texture was not previously created.

    @@ -1021,7 +1021,7 @@ class RenderTarget
    -

    Update a part of this texture from another texture.

    +

    ServerUpdate a part of this texture from another texture.

    No additional check is performed on the size of the texture, passing an invalid combination of texture size and offset will lead to an undefined behavior.

    This function does nothing if either texture was not previously created.

    Parameters
    @@ -1051,7 +1051,7 @@ class RenderTarget
    -

    Update the texture from an image.

    +

    ServerUpdate the texture from an image.

    Although the source image can be smaller than the texture, this function is usually used for updating the whole texture. The other overload, which has (x, y) additional arguments, is more convenient for updating a sub-area of the texture.

    No additional check is performed on the size of the image, passing an image bigger than the texture will lead to an undefined behavior.

    This function does nothing if the texture was not previously created.

    @@ -1096,7 +1096,7 @@ class RenderTarget
    -

    Update a part of the texture from an image.

    +

    ServerUpdate a part of the texture from an image.

    No additional check is performed on the size of the image, passing an invalid combination of image size and offset will lead to an undefined behavior.

    This function does nothing if the texture was not previously created.

    Parameters
    @@ -1126,7 +1126,7 @@ class RenderTarget
    -

    Update the texture from the contents of a window.

    +

    ServerUpdate the texture from the contents of a window.

    Although the source window can be smaller than the texture, this function is usually used for updating the whole texture. The other overload, which has (x, y) additional arguments, is more convenient for updating a sub-area of the texture.

    No additional check is performed on the size of the window, passing a window bigger than the texture will lead to an undefined behavior.

    This function does nothing if either the texture or the window was not previously created.

    @@ -1171,7 +1171,7 @@ class RenderTarget
    -

    Update a part of the texture from the contents of a window.

    +

    ServerUpdate a part of the texture from the contents of a window.

    No additional check is performed on the size of the window, passing an invalid combination of window size and offset will lead to an undefined behavior.

    This function does nothing if either the texture or the window was not previously created.

    Parameters
    diff --git a/SFML-VS32/doc/html/classsf_1_1VertexBuffer.html b/SFML-VS32/doc/html/classsf_1_1VertexBuffer.html index fc4cdc1..0629b00 100644 --- a/SFML-VS32/doc/html/classsf_1_1VertexBuffer.html +++ b/SFML-VS32/doc/html/classsf_1_1VertexBuffer.html @@ -103,10 +103,10 @@ Public Member Functions  Return the vertex count. More...
      bool update (const Vertex *vertices) - Update the whole buffer from an array of vertices. More...
    + ServerUpdate the whole buffer from an array of vertices. More...
      bool update (const Vertex *vertices, std::size_t vertexCount, unsigned int offset) - Update a part of the buffer from an array of vertices. More...
    + ServerUpdate a part of the buffer from an array of vertices. More...
      bool update (const VertexBuffer &vertexBuffer)  Copy the contents of another buffer into this buffer. More...
    @@ -664,7 +664,7 @@ Static Private Member Functions
    -

    Update the whole buffer from an array of vertices.

    +

    ServerUpdate the whole buffer from an array of vertices.

    The vertex array is assumed to have the same size as the created buffer.

    No additional check is performed on the size of the vertex array, passing invalid arguments will lead to undefined behavior.

    This function does nothing if vertices is null or if the buffer was not previously created.

    @@ -710,7 +710,7 @@ Static Private Member Functions
    -

    Update a part of the buffer from an array of vertices.

    +

    ServerUpdate a part of the buffer from an array of vertices.

    offset is specified as the number of vertices to skip from the beginning of the buffer.

    If offset is 0 and vertexCount is equal to the size of the currently created buffer, its whole contents are replaced.

    If offset is 0 and vertexCount is greater than the size of the currently created buffer, a new buffer is created containing the vertex data.

    diff --git a/SFML-VS32/doc/html/deprecated.html b/SFML-VS32/doc/html/deprecated.html index 1868eae..12ab3fe 100644 --- a/SFML-VS32/doc/html/deprecated.html +++ b/SFML-VS32/doc/html/deprecated.html @@ -51,7 +51,7 @@
    Member sf::RenderTexture::create (unsigned int width, unsigned int height, bool depthBuffer)
    Use create(unsigned int, unsigned int, const ContextSettings&) instead.
    Member sf::RenderWindow::capture () const
    -
    Use a sf::Texture and its sf::Texture::update(const Window&) function and copy its contents into an sf::Image instead.
    +
    Use a sf::Texture and its sf::Texture::update(const Window&) function and copy its contents into an sf::Image instead.
    Member sf::Shader::setParameter (const std::string &name, const Color &color)
    Use setUniform(const std::string&, const Glsl::Vec4&) instead.
    Member sf::Shader::setParameter (const std::string &name, CurrentTextureType)
    diff --git a/SFML-VS32/doc/html/index.html b/SFML-VS32/doc/html/index.html index d331308..8b44d34 100644 --- a/SFML-VS32/doc/html/index.html +++ b/SFML-VS32/doc/html/index.html @@ -40,7 +40,7 @@ Welcome

    Short example

    Here is a short example, to show you how simple it is to use SFML:

    -
    #include <SFML/Audio.hpp>
    #include <SFML/Graphics.hpp>
    int main()
    {
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
    // Load a sprite to display
    sf::Texture texture;
    if (!texture.loadFromFile("cute_image.jpg"))
    return EXIT_FAILURE;
    sf::Sprite sprite(texture);
    // Create a graphical text to display
    sf::Font font;
    if (!font.loadFromFile("arial.ttf"))
    return EXIT_FAILURE;
    sf::Text text("Hello SFML", font, 50);
    // Load a music to play
    sf::Music music;
    if (!music.openFromFile("nice_music.ogg"))
    return EXIT_FAILURE;
    // Play the music
    music.play();
    // Start the game loop
    while (window.isOpen())
    {
    // Process events
    sf::Event event;
    while (window.pollEvent(event))
    {
    // Close window: exit
    if (event.type == sf::Event::Closed)
    window.close();
    }
    // Clear screen
    window.clear();
    // Draw the sprite
    window.draw(sprite);
    // Draw the string
    window.draw(text);
    // Update the window
    window.display();
    }
    return EXIT_SUCCESS;
    }
    +
    #include <SFML/Audio.hpp>
    #include <SFML/Graphics.hpp>
    int main()
    {
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
    // Load a sprite to display
    sf::Texture texture;
    if (!texture.loadFromFile("cute_image.jpg"))
    return EXIT_FAILURE;
    sf::Sprite sprite(texture);
    // Create a graphical text to display
    sf::Font font;
    if (!font.loadFromFile("arial.ttf"))
    return EXIT_FAILURE;
    sf::Text text("Hello SFML", font, 50);
    // Load a music to play
    sf::Music music;
    if (!music.openFromFile("nice_music.ogg"))
    return EXIT_FAILURE;
    // Play the music
    music.play();
    // Start the game loop
    while (window.isOpen())
    {
    // Process events
    sf::Event event;
    while (window.pollEvent(event))
    {
    // Close window: exit
    if (event.type == sf::Event::Closed)
    window.close();
    }
    // Clear screen
    window.clear();
    // Draw the sprite
    window.draw(sprite);
    // Draw the string
    window.draw(text);
    // ServerUpdate the window
    window.display();
    }
    return EXIT_SUCCESS;
    }
    -

    Update the contents of the target texture.

    +

    ServerUpdate the contents of the target texture.

    This function updates the target texture with what has been drawn so far. Like for windows, calling this function is mandatory at the end of rendering. Not calling it may leave the texture in an undefined state.

    diff --git a/SFML-mingw32/doc/html/classsf_1_1RenderWindow.html b/SFML-mingw32/doc/html/classsf_1_1RenderWindow.html index 4b79f2d..592ba11 100644 --- a/SFML-mingw32/doc/html/classsf_1_1RenderWindow.html +++ b/SFML-mingw32/doc/html/classsf_1_1RenderWindow.html @@ -403,7 +403,7 @@ Protected Member Functions

    Copy the current contents of the window to an image.

    -
    Deprecated:
    Use a sf::Texture and its sf::Texture::update(const Window&) function and copy its contents into an sf::Image instead.
    +
    Deprecated:
    Use a sf::Texture and its sf::Texture::update(const Window&) function and copy its contents into an sf::Image instead.
    sf::Vector2u windowSize = window.getSize();
    sf::Texture texture;
    texture.create(windowSize.x, windowSize.y);
    texture.update(window);
    sf::Image screenshot = texture.copyToImage();

    This is a slow operation, whose main purpose is to make screenshots of the application. If you want to update an image with the contents of the window and then use it for drawing, you should rather use a sf::Texture and its update(Window&) function. You can also draw things directly to a texture with the sf::RenderTexture class.

    Returns
    Image containing the captured contents
    diff --git a/SFML-mingw32/doc/html/classsf_1_1Texture.html b/SFML-mingw32/doc/html/classsf_1_1Texture.html index a9928c6..1d6f936 100644 --- a/SFML-mingw32/doc/html/classsf_1_1Texture.html +++ b/SFML-mingw32/doc/html/classsf_1_1Texture.html @@ -108,28 +108,28 @@ Public Member Functions  Copy the texture pixels to an image. More...
      void update (const Uint8 *pixels) - Update the whole texture from an array of pixels. More...
    + ServerUpdate the whole texture from an array of pixels. More...
      void update (const Uint8 *pixels, unsigned int width, unsigned int height, unsigned int x, unsigned int y) - Update a part of the texture from an array of pixels. More...
    + ServerUpdate a part of the texture from an array of pixels. More...
      void update (const Texture &texture) - Update a part of this texture from another texture. More...
    + ServerUpdate a part of this texture from another texture. More...
      void update (const Texture &texture, unsigned int x, unsigned int y) - Update a part of this texture from another texture. More...
    + ServerUpdate a part of this texture from another texture. More...
      void update (const Image &image) - Update the texture from an image. More...
    + ServerUpdate the texture from an image. More...
      void update (const Image &image, unsigned int x, unsigned int y) - Update a part of the texture from an image. More...
    + ServerUpdate a part of the texture from an image. More...
      void update (const Window &window) - Update the texture from the contents of a window. More...
    + ServerUpdate the texture from the contents of a window. More...
      void update (const Window &window, unsigned int x, unsigned int y) - Update a part of the texture from the contents of a window. More...
    + ServerUpdate a part of the texture from the contents of a window. More...
      void setSmooth (bool smooth)  Enable or disable the smooth filter. More...
    @@ -193,7 +193,7 @@ class RenderTarget

    Image living on the graphics card that can be used for drawing.

    sf::Texture stores pixels that can be drawn, with a sprite for example.

    A texture lives in the graphics card memory, therefore it is very fast to draw a texture to a render target, or copy a render target to a texture (the graphics card can access both directly).

    -

    Being stored in the graphics card memory has some drawbacks. A texture cannot be manipulated as freely as a sf::Image, you need to prepare the pixels first and then upload them to the texture in a single operation (see Texture::update).

    +

    Being stored in the graphics card memory has some drawbacks. A texture cannot be manipulated as freely as a sf::Image, you need to prepare the pixels first and then upload them to the texture in a single operation (see Texture::update).

    sf::Texture makes it easy to convert from/to sf::Image, but keep in mind that these calls require transfers between the graphics card and the central memory, therefore they are slow operations.

    A texture can be loaded from an image, but also directly from a file/memory/stream. The necessary shortcuts are defined so that you don't need an image first for the most common cases. However, if you want to perform some modifications on the pixels before creating the final texture, you can load your file to a sf::Image, do whatever you need with the pixels, and then call Texture::loadFromImage.

    Since they live in the graphics card memory, the pixels of a texture cannot be accessed without a slow copy first. And they cannot be accessed individually. Therefore, if you need to read the texture's pixels (like for pixel-perfect collisions), it is recommended to store the collision information separately, for example in an array of booleans.

    @@ -886,7 +886,7 @@ class RenderTarget
    -

    Update the whole texture from an array of pixels.

    +

    ServerUpdate the whole texture from an array of pixels.

    The pixel array is assumed to have the same size as the area rectangle, and to contain 32-bits RGBA pixels.

    No additional check is performed on the size of the pixel array, passing invalid arguments will lead to an undefined behavior.

    This function does nothing if pixels is null or if the texture was not previously created.

    @@ -943,7 +943,7 @@ class RenderTarget
    -

    Update a part of the texture from an array of pixels.

    +

    ServerUpdate a part of the texture from an array of pixels.

    The size of the pixel array must match the width and height arguments, and it must contain 32-bits RGBA pixels.

    No additional check is performed on the size of the pixel array or the bounds of the area to update, passing invalid arguments will lead to an undefined behavior.

    This function does nothing if pixels is null or if the texture was not previously created.

    @@ -976,7 +976,7 @@ class RenderTarget
    -

    Update a part of this texture from another texture.

    +

    ServerUpdate a part of this texture from another texture.

    Although the source texture can be smaller than this texture, this function is usually used for updating the whole texture. The other overload, which has (x, y) additional arguments, is more convenient for updating a sub-area of this texture.

    No additional check is performed on the size of the passed texture, passing a texture bigger than this texture will lead to an undefined behavior.

    This function does nothing if either texture was not previously created.

    @@ -1021,7 +1021,7 @@ class RenderTarget
    -

    Update a part of this texture from another texture.

    +

    ServerUpdate a part of this texture from another texture.

    No additional check is performed on the size of the texture, passing an invalid combination of texture size and offset will lead to an undefined behavior.

    This function does nothing if either texture was not previously created.

    Parameters
    @@ -1051,7 +1051,7 @@ class RenderTarget
    -

    Update the texture from an image.

    +

    ServerUpdate the texture from an image.

    Although the source image can be smaller than the texture, this function is usually used for updating the whole texture. The other overload, which has (x, y) additional arguments, is more convenient for updating a sub-area of the texture.

    No additional check is performed on the size of the image, passing an image bigger than the texture will lead to an undefined behavior.

    This function does nothing if the texture was not previously created.

    @@ -1096,7 +1096,7 @@ class RenderTarget
    -

    Update a part of the texture from an image.

    +

    ServerUpdate a part of the texture from an image.

    No additional check is performed on the size of the image, passing an invalid combination of image size and offset will lead to an undefined behavior.

    This function does nothing if the texture was not previously created.

    Parameters
    @@ -1126,7 +1126,7 @@ class RenderTarget
    -

    Update the texture from the contents of a window.

    +

    ServerUpdate the texture from the contents of a window.

    Although the source window can be smaller than the texture, this function is usually used for updating the whole texture. The other overload, which has (x, y) additional arguments, is more convenient for updating a sub-area of the texture.

    No additional check is performed on the size of the window, passing a window bigger than the texture will lead to an undefined behavior.

    This function does nothing if either the texture or the window was not previously created.

    @@ -1171,7 +1171,7 @@ class RenderTarget
    -

    Update a part of the texture from the contents of a window.

    +

    ServerUpdate a part of the texture from the contents of a window.

    No additional check is performed on the size of the window, passing an invalid combination of window size and offset will lead to an undefined behavior.

    This function does nothing if either the texture or the window was not previously created.

    Parameters
    diff --git a/SFML-mingw32/doc/html/classsf_1_1VertexBuffer.html b/SFML-mingw32/doc/html/classsf_1_1VertexBuffer.html index fc4cdc1..0629b00 100644 --- a/SFML-mingw32/doc/html/classsf_1_1VertexBuffer.html +++ b/SFML-mingw32/doc/html/classsf_1_1VertexBuffer.html @@ -103,10 +103,10 @@ Public Member Functions  Return the vertex count. More...
      bool update (const Vertex *vertices) - Update the whole buffer from an array of vertices. More...
    + ServerUpdate the whole buffer from an array of vertices. More...
      bool update (const Vertex *vertices, std::size_t vertexCount, unsigned int offset) - Update a part of the buffer from an array of vertices. More...
    + ServerUpdate a part of the buffer from an array of vertices. More...
      bool update (const VertexBuffer &vertexBuffer)  Copy the contents of another buffer into this buffer. More...
    @@ -664,7 +664,7 @@ Static Private Member Functions
    -

    Update the whole buffer from an array of vertices.

    +

    ServerUpdate the whole buffer from an array of vertices.

    The vertex array is assumed to have the same size as the created buffer.

    No additional check is performed on the size of the vertex array, passing invalid arguments will lead to undefined behavior.

    This function does nothing if vertices is null or if the buffer was not previously created.

    @@ -710,7 +710,7 @@ Static Private Member Functions
    -

    Update a part of the buffer from an array of vertices.

    +

    ServerUpdate a part of the buffer from an array of vertices.

    offset is specified as the number of vertices to skip from the beginning of the buffer.

    If offset is 0 and vertexCount is equal to the size of the currently created buffer, its whole contents are replaced.

    If offset is 0 and vertexCount is greater than the size of the currently created buffer, a new buffer is created containing the vertex data.

    diff --git a/SFML-mingw32/doc/html/deprecated.html b/SFML-mingw32/doc/html/deprecated.html index 1868eae..12ab3fe 100644 --- a/SFML-mingw32/doc/html/deprecated.html +++ b/SFML-mingw32/doc/html/deprecated.html @@ -51,7 +51,7 @@
    Member sf::RenderTexture::create (unsigned int width, unsigned int height, bool depthBuffer)
    Use create(unsigned int, unsigned int, const ContextSettings&) instead.
    Member sf::RenderWindow::capture () const
    -
    Use a sf::Texture and its sf::Texture::update(const Window&) function and copy its contents into an sf::Image instead.
    +
    Use a sf::Texture and its sf::Texture::update(const Window&) function and copy its contents into an sf::Image instead.
    Member sf::Shader::setParameter (const std::string &name, const Color &color)
    Use setUniform(const std::string&, const Glsl::Vec4&) instead.
    Member sf::Shader::setParameter (const std::string &name, CurrentTextureType)
    diff --git a/SFML-mingw32/doc/html/index.html b/SFML-mingw32/doc/html/index.html index d331308..8b44d34 100644 --- a/SFML-mingw32/doc/html/index.html +++ b/SFML-mingw32/doc/html/index.html @@ -40,7 +40,7 @@ Welcome

    Short example

    Here is a short example, to show you how simple it is to use SFML:

    -
    #include <SFML/Audio.hpp>
    #include <SFML/Graphics.hpp>
    int main()
    {
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
    // Load a sprite to display
    sf::Texture texture;
    if (!texture.loadFromFile("cute_image.jpg"))
    return EXIT_FAILURE;
    sf::Sprite sprite(texture);
    // Create a graphical text to display
    sf::Font font;
    if (!font.loadFromFile("arial.ttf"))
    return EXIT_FAILURE;
    sf::Text text("Hello SFML", font, 50);
    // Load a music to play
    sf::Music music;
    if (!music.openFromFile("nice_music.ogg"))
    return EXIT_FAILURE;
    // Play the music
    music.play();
    // Start the game loop
    while (window.isOpen())
    {
    // Process events
    sf::Event event;
    while (window.pollEvent(event))
    {
    // Close window: exit
    if (event.type == sf::Event::Closed)
    window.close();
    }
    // Clear screen
    window.clear();
    // Draw the sprite
    window.draw(sprite);
    // Draw the string
    window.draw(text);
    // Update the window
    window.display();
    }
    return EXIT_SUCCESS;
    }
    +
    #include <SFML/Audio.hpp>
    #include <SFML/Graphics.hpp>
    int main()
    {
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 600), "SFML window");
    // Load a sprite to display
    sf::Texture texture;
    if (!texture.loadFromFile("cute_image.jpg"))
    return EXIT_FAILURE;
    sf::Sprite sprite(texture);
    // Create a graphical text to display
    sf::Font font;
    if (!font.loadFromFile("arial.ttf"))
    return EXIT_FAILURE;
    sf::Text text("Hello SFML", font, 50);
    // Load a music to play
    sf::Music music;
    if (!music.openFromFile("nice_music.ogg"))
    return EXIT_FAILURE;
    // Play the music
    music.play();
    // Start the game loop
    while (window.isOpen())
    {
    // Process events
    sf::Event event;
    while (window.pollEvent(event))
    {
    // Close window: exit
    if (event.type == sf::Event::Closed)
    window.close();
    }
    // Clear screen
    window.clear();
    // Draw the sprite
    window.draw(sprite);
    // Draw the string
    window.draw(text);
    // ServerUpdate the window
    window.display();
    }
    return EXIT_SUCCESS;
    }