Visual Studio refactoring
parent
4900635bec
commit
7dd4a185e3
|
@ -91,7 +91,7 @@ add_executable(shooter
|
|||
engine/network/UDPConnection.h
|
||||
engine/network/UDPSocket.cpp
|
||||
engine/network/UDPSocket.h
|
||||
engine/SoundController.cpp engine/SoundController.h ShooterMsgType.h ShooterMsgType.cpp)
|
||||
engine/SoundController.cpp engine/SoundController.h ShooterMsgType.h ShooterMsgType.cpp engine/animation/AAttractToPoint.h engine/animation/ARotateRelativePoint.h)
|
||||
|
||||
if(APPLE OR UNIX)
|
||||
include_directories(/usr/local/include)
|
||||
|
|
|
@ -11,6 +11,10 @@
|
|||
#include "engine/animation/Timeline.h"
|
||||
#include "ShooterConsts.h"
|
||||
#include "engine/SoundController.h"
|
||||
#include "engine/animation/AAttractToPoint.h"
|
||||
#include "engine/animation/ARotateRelativePoint.h"
|
||||
#include "engine/animation/ATranslateToPoint.h"
|
||||
#include "engine/animation/AWait.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
|
@ -9,6 +9,12 @@
|
|||
#include "engine/animation/Timeline.h"
|
||||
#include "ShooterMsgType.h"
|
||||
|
||||
#include "engine/animation/AAttractToPoint.h"
|
||||
#include "engine/animation/ARotateRelativePoint.h"
|
||||
#include "engine/animation/ATranslateToPoint.h"
|
||||
#include "engine/animation/AWait.h"
|
||||
#include "engine/animation/AFunction.h"
|
||||
|
||||
void ShooterClient::updatePacket() {
|
||||
sf::Packet packet;
|
||||
packet << MsgType::ClientUpdate << _player->position().x() << _player->position().y() << _player->position().z()
|
||||
|
@ -109,12 +115,33 @@ void ShooterClient::processCustomPacket(sf::Packet &packet) {
|
|||
|
||||
if (buffId[0] == _socket.ownId()) {
|
||||
_player->addDeath();
|
||||
// respawn
|
||||
_player->translateToPoint(
|
||||
Vec3D{50.0 * (-1 + 2.0 * (double) rand() / RAND_MAX), 30.0 * (double) rand() / RAND_MAX,
|
||||
50.0 * (-1 + 2.0 * (double) rand() / RAND_MAX)});
|
||||
_player->reInitWeapons();
|
||||
_player->setFullAbility();
|
||||
|
||||
auto camera = _player->attached(ObjectNameTag("Camera"));
|
||||
_player->unattach(ObjectNameTag("Camera"));
|
||||
_player->translateToPoint(Vec3D{10000});
|
||||
Vec2D cameraOrientation(camera->angleLeftUpLookAt().x(), _player->angle().y());
|
||||
camera->rotateLeft(-cameraOrientation.x());
|
||||
camera->transform(Matrix4x4::Rotation(Vec3D(-_player->angle())));
|
||||
|
||||
Timeline::animate(AnimationListTag("camera_anim"), std::make_shared<ATranslateToPoint>(camera, Vec3D(-20, 30, -100)));
|
||||
Timeline::animate(AnimationListTag("camera_anim"), std::make_shared<ARotateRelativePoint>(camera, Vec3D(0), Vec3D{0, Consts::PI, 0}, 5, Animation::LoopOut::None, Animation::InterpolationType::Linear));
|
||||
Timeline::animate(AnimationListTag("camera_anim"), std::make_shared<AWait>(0));
|
||||
Timeline::animate(AnimationListTag("camera_anim"), std::make_shared<AFunction>([this, camera](){
|
||||
// respawn
|
||||
_player->translateToPoint(Vec3D{50.0 * (-1 + 2.0 * (double) rand() / RAND_MAX), 30.0 * (double) rand() / RAND_MAX,
|
||||
50.0 * (-1 + 2.0 * (double) rand() / RAND_MAX)});
|
||||
_player->reInitWeapons();
|
||||
_player->setFullAbility();
|
||||
|
||||
camera->rotateToAngle(Vec3D(0));
|
||||
camera->transform(Matrix4x4::Rotation(Vec3D(_player->angle())));
|
||||
camera->rotateLeft(_player->headAngle());
|
||||
camera->translateToPoint(_player->position() + Vec3D{0, 1.8, 0});
|
||||
_player->attach(camera);
|
||||
|
||||
}, 1, 0.1));
|
||||
|
||||
|
||||
SoundController::playSound(SoundTag("death"), ShooterConsts::DEATH_SOUND);
|
||||
_lastEvent += _player->playerNickName();
|
||||
} else {
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace Consts {
|
|||
const std::string PROJECT_NAME = "engine";
|
||||
const bool USE_LOG_FILE = true;
|
||||
const bool USE_OPEN_GL = true;
|
||||
const bool SHOW_DEBUG_INFO = false;
|
||||
const bool SHOW_DEBUG_INFO = true;
|
||||
const bool SHOW_FPS_COUNTER = true;
|
||||
|
||||
const double PI = 3.14159265358979323846264338327950288;
|
||||
|
|
|
@ -97,6 +97,11 @@ void Object::translateToPoint(const Vec3D &point) {
|
|||
translate(point - position());
|
||||
}
|
||||
|
||||
void Object::attractToPoint(const Vec3D &point, double value) {
|
||||
Vec3D v = (point - position()).normalized();
|
||||
translate(v*value);
|
||||
}
|
||||
|
||||
void Object::rotateToAngle(const Vec3D &v) {
|
||||
rotate(v - _angle);
|
||||
}
|
||||
|
|
|
@ -63,6 +63,8 @@ public:
|
|||
|
||||
void translateToPoint(const Vec3D &point);
|
||||
|
||||
void attractToPoint(const Vec3D &point, double value);
|
||||
|
||||
void scale(const Vec3D &s);
|
||||
|
||||
void rotate(const Vec3D &r);
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
//
|
||||
// Created by Иван Ильин on 01.11.2021.
|
||||
//
|
||||
|
||||
#ifndef SHOOTER_AATTRACTTOPOINT_H
|
||||
#define SHOOTER_AATTRACTTOPOINT_H
|
||||
|
||||
#include "Animation.h"
|
||||
#include "../Object.h"
|
||||
|
||||
class AAttractToPoint : public Animation {
|
||||
private:
|
||||
const std::weak_ptr<Object> _object;
|
||||
const Vec3D _targetPoint;
|
||||
const double _valueToAttract;
|
||||
|
||||
void update() override {
|
||||
if (_object.expired()) {
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
_object.lock()->attractToPoint(_targetPoint, _valueToAttract * dprogress());
|
||||
}
|
||||
|
||||
public:
|
||||
AAttractToPoint(std::weak_ptr<Object> object, const Vec3D &targetPoint, double valueToAttract, double duration = 1,
|
||||
Animation::LoopOut looped = LoopOut::None,
|
||||
Animation::InterpolationType interpolationType = InterpolationType::Bezier)
|
||||
: Animation(duration, looped, interpolationType), _object(object), _targetPoint(targetPoint),
|
||||
_valueToAttract(valueToAttract) {}
|
||||
};
|
||||
|
||||
#endif //SHOOTER_AATTRACTTOPOINT_H
|
|
@ -27,7 +27,7 @@ private:
|
|||
public:
|
||||
ARotate(std::weak_ptr<Object> object, const Vec3D &r, double duration = 1, LoopOut looped = LoopOut::None,
|
||||
InterpolationType interpolationType = InterpolationType::Bezier)
|
||||
: Animation(duration, looped, interpolationType), _object(std::move(object)), _rotationValue(r) {
|
||||
: Animation(duration, looped, interpolationType), _object(object), _rotationValue(r) {
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
//
|
||||
// Created by Иван Ильин on 01.11.2021.
|
||||
//
|
||||
|
||||
#ifndef SHOOTER_AROTATERELATIVEPOINT_H
|
||||
#define SHOOTER_AROTATERELATIVEPOINT_H
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include "Animation.h"
|
||||
#include "../Object.h"
|
||||
|
||||
class ARotateRelativePoint : public Animation {
|
||||
private:
|
||||
const std::weak_ptr<Object> _object;
|
||||
const Vec3D _targetPoint;
|
||||
const Vec3D _rotationValue;
|
||||
|
||||
void update() override {
|
||||
|
||||
if (_object.expired()) {
|
||||
stop();
|
||||
return;
|
||||
}
|
||||
|
||||
_object.lock()->rotateRelativePoint(_targetPoint, _rotationValue * dprogress());
|
||||
}
|
||||
|
||||
public:
|
||||
ARotateRelativePoint(std::weak_ptr<Object> object, const Vec3D &targetPoint, const Vec3D &rotationValue,
|
||||
double duration = 1, Animation::LoopOut looped = LoopOut::None,
|
||||
Animation::InterpolationType interpolationType = InterpolationType::Bezier)
|
||||
: Animation(duration, looped, interpolationType), _object(object), _targetPoint(targetPoint),
|
||||
_rotationValue(rotationValue) {}
|
||||
};
|
||||
|
||||
#endif //SHOOTER_AROTATERELATIVEPOINT_H
|
|
@ -206,6 +206,8 @@
|
|||
<ClInclude Include="engine\animation\ATranslate.h" />
|
||||
<ClInclude Include="engine\animation\ATranslateToPoint.h" />
|
||||
<ClInclude Include="engine\animation\AWait.h" />
|
||||
<ClInclude Include="engine\animation\AAttractToPoint.h" />
|
||||
<ClInclude Include="engine\animation\ARotateRelativePoint.h" />
|
||||
<ClInclude Include="engine\animation\Interpolation.h" />
|
||||
<ClInclude Include="engine\animation\Timeline.h" />
|
||||
<ClInclude Include="engine\Camera.h" />
|
||||
|
|
|
@ -215,6 +215,12 @@
|
|||
<ClInclude Include="engine\animation\AWait.h">
|
||||
<Filter>Файлы заголовков\engine\animation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="engine\animation\AAttractToPoint.h">
|
||||
<Filter>Файлы заголовков\engine\animation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="engine\animation\ARotateRelativePoint.h">
|
||||
<Filter>Файлы заголовков\engine\animation</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="weapon\Ak47.h">
|
||||
<Filter>Файлы заголовков\weapon</Filter>
|
||||
</ClInclude>
|
||||
|
|
Loading…
Reference in New Issue