Skip to content

Commit

Permalink
Changed position type from vec3 to vec2
Browse files Browse the repository at this point in the history
  • Loading branch information
RiverHillbug committed Mar 2, 2024
1 parent 7008f4a commit 868f563
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 9 deletions.
4 changes: 2 additions & 2 deletions Minigin/GameObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ void GameObject::Update(const float deltaTime)

void GameObject::SetWorldPosition(const float x, const float y)
{
SetWorldPosition(glm::vec3(x, y, 0.0f));
SetWorldPosition(glm::vec2(x, y));
}

void GameObject::SetWorldPosition(const glm::vec3& position)
void GameObject::SetWorldPosition(const glm::vec2& position)
{
m_Transform.SetPosition(position);

Expand Down
4 changes: 2 additions & 2 deletions Minigin/GameObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ class GameObject final

inline Transform GetTransform() const { return m_Transform; }
void SetWorldPosition(const float x, const float y);
void SetWorldPosition(const glm::vec3& position);
void SetWorldPosition(const glm::vec2& position);
inline bool IsDestroyed() const { return m_IsDestroyed; }
inline bool IsLocalPositionDirty() const { return m_LocalPositionIsDirty; }
//inline bool IsLocalPositionDirty() const { return m_LocalPositionIsDirty; }

GameObject() = default;
GameObject(const float x, const float y);
Expand Down
26 changes: 24 additions & 2 deletions Minigin/Transform.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,30 @@
#include "Transform.h"

void Transform::SetPosition(const float x, const float y, const float z)
Transform::Transform(const glm::vec2& position)
: m_Position{ position }
{

}

void Transform::SetPosition(const float x, const float y)
{
m_Position.x = x;
m_Position.y = y;
m_Position.z = z;
}

void Transform::SetPosition(const glm::vec2 position)
{
m_Position = position;
}

/*
Transform Transform::operator+(const Transform& transform1, const Transform& transform2)
{
return transform1.m_Position + transform2.m_Position;
}
Transform Transform::operator-(const Transform& transform1, const Transform& transform2)
{
return transform1.m_Position - transform2.m_Position;
}
*/
12 changes: 9 additions & 3 deletions Minigin/Transform.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@
class Transform final
{
public:
inline const glm::vec3& GetPosition() const { return m_Position; }
void SetPosition(const float x, const float y, const float z);
Transform() = default;
Transform(const glm::vec2& position);
inline const glm::vec2& GetPosition() const { return m_Position; }
void SetPosition(const float x, const float y);
void SetPosition(const glm::vec2 position);

/*static Transform operator+(const Transform& transform1, const Transform& transform2);
static Transform operator-(const Transform& transform1, const Transform& transform2);*/

private:
glm::vec3 m_Position;
glm::vec2 m_Position;
};

0 comments on commit 868f563

Please sign in to comment.