This commit is contained in:
h4570
2022-07-30 17:00:22 +02:00
parent ff2967c7e5
commit 1bdb33e1a6
10 changed files with 195 additions and 67 deletions
+3
View File
@@ -10,6 +10,8 @@
#pragma once
#include <string>
namespace Tyra {
class FileUtils {
@@ -18,6 +20,7 @@ class FileUtils {
~FileUtils();
static std::string getCwd();
static std::string fromCwd(const std::string& relativePath);
static std::string fromCwd(const char* relativePath);
const char* getElfName() const { return elfName; };
+22
View File
@@ -35,6 +35,28 @@ class Vec2 {
Vec2();
~Vec2();
void operator=(const Vec2& v);
Vec2 operator+(const Vec2& v) const;
Vec2 operator-(const Vec2& v) const;
Vec2 operator*(const Vec2& v) const;
Vec2 operator/(const Vec2& v) const;
Vec2 operator+(const float& v) const;
Vec2 operator-(const float& v) const;
Vec2 operator*(const float& v) const;
Vec2 operator/(const float& v) const;
void operator+=(const Vec2& v);
void operator-=(const Vec2& v);
void operator*=(const Vec2& v);
void operator/=(const Vec2& v);
void operator+=(const float& v);
void operator-=(const float& v);
void operator*=(const float& v);
void operator/=(const float& v);
void set(const float& t_x, const float& t_y);
void set(const Vec2& v);
void rotate(const float& t_angle, const float& t_x, const float& t_y);
+4
View File
@@ -56,6 +56,10 @@ std::string FileUtils::getCwd() {
return result;
}
std::string FileUtils::fromCwd(const std::string& relativePath) {
return fromCwd(relativePath.c_str());
}
std::string FileUtils::fromCwd(const char* file) {
auto cwd = getCwd();
return cwd + file;
+49
View File
@@ -54,6 +54,55 @@ void Vec2::rotate(const float& t_angle, const float& t_x, const float& t_y) {
y = ynew + t_y;
}
void Vec2::operator=(const Vec2& v) {
x = v.x;
y = v.y;
}
Vec2 Vec2::operator+(const Vec2& v) const { return Vec2(x + v.x, y + v.y); }
Vec2 Vec2::operator-(const Vec2& v) const { return Vec2(x - v.x, y - v.y); }
Vec2 Vec2::operator*(const Vec2& v) const { return Vec2(x * v.x, y * v.y); }
Vec2 Vec2::operator/(const Vec2& v) const { return Vec2(x / v.x, y / v.y); }
Vec2 Vec2::operator+(const float& v) const { return Vec2(x + v, y + v); }
Vec2 Vec2::operator-(const float& v) const { return Vec2(x - v, y - v); }
Vec2 Vec2::operator*(const float& v) const { return Vec2(x * v, y * v); }
Vec2 Vec2::operator/(const float& v) const { return Vec2(x / v, y / v); }
void Vec2::operator+=(const Vec2& v) {
x += v.x;
y += v.y;
}
void Vec2::operator-=(const Vec2& v) {
x -= v.x;
y -= v.y;
}
void Vec2::operator*=(const Vec2& v) {
x *= v.x;
y *= v.y;
}
void Vec2::operator/=(const Vec2& v) {
x /= v.x;
y /= v.y;
}
void Vec2::operator+=(const float& v) {
x += v;
y += v;
}
void Vec2::operator-=(const float& v) {
x -= v;
y -= v;
}
void Vec2::operator*=(const float& v) {
x *= v;
y *= v;
}
void Vec2::operator/=(const float& v) {
x /= v;
y /= v;
}
void Vec2::print() const {
auto text = getPrint(nullptr);
printf("%s\n", text.c_str());