OS Windows support

master
Vectozavr 2021-10-09 18:38:24 +07:00
parent 758685fe57
commit 423e6d0d35
4 changed files with 17 additions and 20 deletions

View File

@ -38,8 +38,6 @@ private:
sf::Sound _fullHealthSound; sf::Sound _fullHealthSound;
sf::Sound _fullAbilitySound; sf::Sound _fullAbilitySound;
std::string _name = "im";
std::vector<std::shared_ptr<Weapon>> _weapons; std::vector<std::shared_ptr<Weapon>> _weapons;
size_t _selectedWeapon = 0; size_t _selectedWeapon = 0;
@ -67,14 +65,9 @@ public:
setCollisionCallBack([this](const std::string& objName, std::shared_ptr<RigidBody> obj) {collisionWithObject(objName, obj);}); setCollisionCallBack([this](const std::string& objName, std::shared_ptr<RigidBody> obj) {collisionWithObject(objName, obj);});
}; };
[[nodiscard]] std::string name() const { return "Player_" + _name; }
void setHealth(double h) { void setHealth(double h) {
_health = h; _health = h;
} }
void setAbility(double a) {
_ability = a;
}
[[nodiscard]] double health() const { return _health; } [[nodiscard]] double health() const { return _health; }
[[nodiscard]] double ability() const { return _ability; } [[nodiscard]] double ability() const { return _ability; }

View File

@ -6,7 +6,6 @@
#include <fstream> #include <fstream>
#include "engine/animation/AColor.h" #include "engine/animation/AColor.h"
#include "engine/animation/AFunction.h" #include "engine/animation/AFunction.h"
#include "engine/animation/ATranslate.h"
#include "engine/animation/ARotate.h" #include "engine/animation/ARotate.h"
#include "engine/animation/Timeline.h" #include "engine/animation/Timeline.h"
@ -86,7 +85,7 @@ void Shooter::start() {
camera->translateToPoint(player->position() + Point4D{0, 1.8, 0}); camera->translateToPoint(player->position() + Point4D{0, 1.8, 0});
player->attach(camera, "camera"); player->attach(camera, "camera");
world->addBody(player, player->name()); world->addBody(player, "Player");
player->translate(Point4D{0, 10, 0}); player->translate(Point4D{0, 10, 0});
client = std::make_shared<Client>(player); client = std::make_shared<Client>(player);
@ -201,7 +200,7 @@ void Shooter::play() {
} }
void Shooter::spawnPlayer(sf::Uint16 id) { void Shooter::spawnPlayer(sf::Uint16 id) {
std::string name = "Player_" + std::to_string(id); std::string name = "Enemy_" + std::to_string(id);
std::shared_ptr<Player> newPlayer = std::make_shared<Player>(); std::shared_ptr<Player> newPlayer = std::make_shared<Player>();
newPlayer->setCollision(false); newPlayer->setCollision(false);
@ -230,7 +229,7 @@ void Shooter::spawnPlayer(sf::Uint16 id) {
} }
void Shooter::removePlayer(sf::Uint16 id) { void Shooter::removePlayer(sf::Uint16 id) {
std::string name = "Player_" + std::to_string(id); std::string name = "Enemy_" + std::to_string(id);
world->removeBody(name); world->removeBody(name);
world->removeBody(name + "_head"); world->removeBody(name + "_head");
world->removeBody(name + "_eye1"); world->removeBody(name + "_eye1");

View File

@ -1,5 +1,5 @@
// //
// Created by Èâàí Èëüèí on 06.02.2021. // Created by Ivan Ilin on 06.02.2021.
// //
#include "Shooter.h" #include "Shooter.h"

View File

@ -25,7 +25,7 @@ std::pair<Point4D, string> World::rayCast(const Point4D& from, const Point4D& to
double minDistance = 10000; double minDistance = 10000;
for(auto& object : _objects) { for(auto& object : _objects) {
if((object.first.find("im") != std::string::npos) || (object.first.find("nr") != std::string::npos)) if((object.first.find("Player") != std::string::npos) || (object.first.find("Bonus") != std::string::npos))
continue; continue;
for(auto& tri : object.second->triangles()) { for(auto& tri : object.second->triangles()) {
@ -63,16 +63,21 @@ void World::checkCollision(const std::string& body) {
_objects[body]->setInCollision(false); _objects[body]->setInCollision(false);
for (auto &obj : _objects) { for (auto it = _objects.begin(); it != _objects.end();) {
if(obj.first != body) {
std::pair<bool, Simplex> gjk = _objects[body]->checkGJKCollision(obj.second); auto obj = it->second;
std::string name = it->first;
it++;
if(name != body) {
std::pair<bool, Simplex> gjk = _objects[body]->checkGJKCollision(obj);
if (gjk.first) { if (gjk.first) {
if (obj.second->isCollider()) { if (obj->isCollider()) {
CollisionPoint epa = _objects[body]->EPA(gjk.second, obj.second); CollisionPoint epa = _objects[body]->EPA(gjk.second, obj);
Solver::solveCollision(_objects[body], obj.second, epa); Solver::solveCollision(_objects[body], obj, epa);
} }
if (_objects[body]->collisionCallBack() != nullptr) if (_objects[body]->collisionCallBack() != nullptr)
_objects[body]->collisionCallBack()(obj.first, obj.second); _objects[body]->collisionCallBack()(name, obj);
} }
} }
} }