OS Windows support
parent
758685fe57
commit
423e6d0d35
7
Player.h
7
Player.h
|
@ -38,8 +38,6 @@ private:
|
|||
sf::Sound _fullHealthSound;
|
||||
sf::Sound _fullAbilitySound;
|
||||
|
||||
std::string _name = "im";
|
||||
|
||||
std::vector<std::shared_ptr<Weapon>> _weapons;
|
||||
size_t _selectedWeapon = 0;
|
||||
|
||||
|
@ -67,14 +65,9 @@ public:
|
|||
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) {
|
||||
_health = h;
|
||||
}
|
||||
void setAbility(double a) {
|
||||
_ability = a;
|
||||
}
|
||||
|
||||
[[nodiscard]] double health() const { return _health; }
|
||||
[[nodiscard]] double ability() const { return _ability; }
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <fstream>
|
||||
#include "engine/animation/AColor.h"
|
||||
#include "engine/animation/AFunction.h"
|
||||
#include "engine/animation/ATranslate.h"
|
||||
#include "engine/animation/ARotate.h"
|
||||
#include "engine/animation/Timeline.h"
|
||||
|
||||
|
@ -86,7 +85,7 @@ void Shooter::start() {
|
|||
camera->translateToPoint(player->position() + Point4D{0, 1.8, 0});
|
||||
player->attach(camera, "camera");
|
||||
|
||||
world->addBody(player, player->name());
|
||||
world->addBody(player, "Player");
|
||||
player->translate(Point4D{0, 10, 0});
|
||||
|
||||
client = std::make_shared<Client>(player);
|
||||
|
@ -201,7 +200,7 @@ void Shooter::play() {
|
|||
}
|
||||
|
||||
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>();
|
||||
newPlayer->setCollision(false);
|
||||
|
||||
|
@ -230,7 +229,7 @@ void Shooter::spawnPlayer(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 + "_head");
|
||||
world->removeBody(name + "_eye1");
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// Created by Èâàí Èëüèí on 06.02.2021.
|
||||
// Created by Ivan Ilin on 06.02.2021.
|
||||
//
|
||||
|
||||
#include "Shooter.h"
|
||||
|
|
|
@ -25,7 +25,7 @@ std::pair<Point4D, string> World::rayCast(const Point4D& from, const Point4D& to
|
|||
double minDistance = 10000;
|
||||
|
||||
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;
|
||||
|
||||
for(auto& tri : object.second->triangles()) {
|
||||
|
@ -63,16 +63,21 @@ void World::checkCollision(const std::string& body) {
|
|||
|
||||
_objects[body]->setInCollision(false);
|
||||
|
||||
for (auto &obj : _objects) {
|
||||
if(obj.first != body) {
|
||||
std::pair<bool, Simplex> gjk = _objects[body]->checkGJKCollision(obj.second);
|
||||
for (auto it = _objects.begin(); it != _objects.end();) {
|
||||
|
||||
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 (obj.second->isCollider()) {
|
||||
CollisionPoint epa = _objects[body]->EPA(gjk.second, obj.second);
|
||||
Solver::solveCollision(_objects[body], obj.second, epa);
|
||||
if (obj->isCollider()) {
|
||||
CollisionPoint epa = _objects[body]->EPA(gjk.second, obj);
|
||||
Solver::solveCollision(_objects[body], obj, epa);
|
||||
}
|
||||
if (_objects[body]->collisionCallBack() != nullptr)
|
||||
_objects[body]->collisionCallBack()(obj.first, obj.second);
|
||||
_objects[body]->collisionCallBack()(name, obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue