Skip to content
This repository has been archived by the owner on Jun 23, 2023. It is now read-only.

Fix Vector2 warning #22

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Source/Game/Bittermap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ void Bittermap::MoveWithCollision(const Vector2i moveVec, const HitboxPool hitbo

auto limitDist = wallBox.getRadius() + thisHitbox.getRadius();
auto reactionVec = Vector2i(
(currDist.x >= 0 ? limitDist.x : -limitDist.x) - currDist.x,
(currDist.y >= 0 ? limitDist.y : -limitDist.y) - currDist.y
static_cast<int>((currDist.x >= 0 ? limitDist.x : -limitDist.x) - currDist.x),
static_cast<int>((currDist.y >= 0 ? limitDist.y : -limitDist.y) - currDist.y)
);

if (abs(reactionVec.x) == abs(reactionVec.y)) {
Expand Down
90 changes: 45 additions & 45 deletions Source/Unity/Vector2.h
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
#pragma once

namespace Unity {
template<typename T>
struct Vector2 {
T x, y;
Vector2<T>() = default;
Vector2<T>(T x, T y) : x(x), y(y) {}
template<typename U>
Vector2<T> operator+(const Vector2<U>& other) const {
return Vector2<T>(
this->x + other.x,
this->y + other.y
);
};
template<typename U>
Vector2<T> operator-(const Vector2<U>& other) const {
return Vector2<T>(
this->x - other.x,
this->y - other.y
);
};
template<typename U>
Vector2<T> operator*(const U& other) const {
return Vector2<T>(
this->x * other,
this->y * other
);
}
template<typename U>
Vector2<T> operator/(const U& other) const {
return Vector2<T>(
this->x / other,
this->y / other
);
};
template<typename U>
bool operator==(const Vector2<U>& other) const {
return this->x == other.x && this->y == other.y;
}
template<typename U>
Vector2<T>(Vector2<U> const & origin) {
x = (T)origin.x;
y = (T)origin.y;
}
};
using Vector2i = Vector2<int>;
using Vector2f = Vector2<float>;
template<typename T>
struct Vector2 {
T x, y;
Vector2<T>() = default;
Vector2<T>(T x, T y) : x(x), y(y) {}
template<typename U>
Vector2<T> operator+(const Vector2<U>& other) const {
return Vector2<T>(
static_cast<T>(this->x + other.x),
static_cast<T>(this->y + other.y)
);
};
template<typename U>
Vector2<T> operator-(const Vector2<U>& other) const {
return Vector2<T>(
static_cast<T>(this->x - other.x),
static_cast<T>(this->y - other.y)
);
};
template<typename U>
Vector2<T> operator*(const U& other) const {
return Vector2<T>(
static_cast<T>(this->x * other),
static_cast<T>(this->y * other)
);
}
template<typename U>
Vector2<T> operator/(const U& other) const {
return Vector2<T>(
static_cast<T>(this->x / other),
static_cast<T>(this->y / other)
);
};
template<typename U>
bool operator==(const Vector2<U>& other) const {
return this->x == other.x && this->y == other.y;
}
template<typename U>
Vector2<T>(Vector2<U> const & origin) {
x = static_cast<T>(origin.x);
y = static_cast<T>(origin.y);
}
};
using Vector2i = Vector2<int>;
using Vector2f = Vector2<float>;
}
4 changes: 2 additions & 2 deletions game.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<ObjectFileName>.\Debug/</ObjectFileName>
<ProgramDataBaseFileName>.\Debug/</ProgramDataBaseFileName>
<WarningLevel>Level3</WarningLevel>
<TreatWarningAsError>false</TreatWarningAsError>
<TreatWarningAsError>true</TreatWarningAsError>
<SuppressStartupBanner>true</SuppressStartupBanner>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<AdditionalOptions>/utf-8 %(AdditionalOptions)</AdditionalOptions>
Expand Down Expand Up @@ -288,4 +288,4 @@
<UserProperties RESOURCE_FILE="Source\game.rc" />
</VisualStudio>
</ProjectExtensions>
</Project>
</Project>