From 65f2c6364347b9f1ffa9f21e1cd79b14490d4170 Mon Sep 17 00:00:00 2001 From: Vectozavr <60608292+vectozavr@users.noreply.github.com> Date: Fri, 29 Oct 2021 23:43:39 +0700 Subject: [PATCH] Huge refactoring v3 --- Player.cpp | 6 ++++-- engine/Vec3D.cpp | 4 ++++ engine/Vec3D.h | 2 ++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Player.cpp b/Player.cpp index d3bfe99..de0913c 100644 --- a/Player.cpp +++ b/Player.cpp @@ -4,7 +4,6 @@ #include "Player.h" #include "engine/Screen.h" -#include "engine/ResourceManager.h" #include "engine/utils/Log.h" Player::Player(ObjectNameTag name) : RigidBody(name) { @@ -12,7 +11,10 @@ Player::Player(ObjectNameTag name) : RigidBody(name) { setAcceleration(Vec3D{0, -ShooterConsts::GRAVITY, 0}); setCollision(true); setVisible(false); - setColor({240, 168, 168}); + + //setColor({240, 168, 168}); + Vec3D randColor = Vec3D::Random(); + setColor({static_cast(randColor.x()*255), static_cast(randColor.y()*255), static_cast(randColor.z()*255)}); setCollisionCallBack([this](const ObjectNameTag& tag, std::shared_ptr obj) {collisionWithObject(tag, obj);}); } diff --git a/engine/Vec3D.cpp b/engine/Vec3D.cpp index 8fb28dc..82cc2d6 100644 --- a/engine/Vec3D.cpp +++ b/engine/Vec3D.cpp @@ -87,3 +87,7 @@ Vec3D Vec3D::cross(const Vec3D& vec) const { Vec4D Vec3D::makePoint4D() const { return Vec4D(x(), y(), z(), 1.0); } + +Vec3D Vec3D::Random() { + return Vec3D((double)rand()/RAND_MAX, (double)rand()/RAND_MAX, (double)rand()/RAND_MAX); +} diff --git a/engine/Vec3D.h b/engine/Vec3D.h index e37c018..43c65b1 100644 --- a/engine/Vec3D.h +++ b/engine/Vec3D.h @@ -45,6 +45,8 @@ public: [[nodiscard]] double abs() const; // Returns vector length [[nodiscard]] Vec3D normalized() const; // Returns normalized vector without changing [[nodiscard]] Vec4D makePoint4D() const; + + static Vec3D Random(); };