Remove Point2f, replace with Vector2f

This commit is contained in:
Bram Verhulst
2024-04-17 13:54:48 +02:00
parent 64e96ab209
commit db83ae5e13
42 changed files with 494 additions and 634 deletions

View File

@@ -18,8 +18,8 @@ WorldGridManager::~WorldGridManager() {
}
surroundingTiles WorldGridManager::GetSurroundingTiles(const WorldTile* world_tile) {
surroundingTiles tiles;
Point2f pos = world_tile->GetPosition();
Point2f gridCoords = this->GetIndexFromPosition(pos);
Vector2f pos = world_tile->GetPosition();
Vector2f gridCoords = this->GetIndexFromPosition(pos);
int x = gridCoords.x;
//TODO: Stupid fix, fix this
int y = gridCoords.y - 1;
@@ -38,10 +38,10 @@ surroundingTiles WorldGridManager::GetSurroundingTiles(const WorldTile* world_ti
return tiles;
}
Point2f WorldGridManager::GetIndexFromPosition(Point2f position) {
Vector2f WorldGridManager::GetIndexFromPosition(Vector2f position) {
int x = int(position.x / TILE_WIDTH + WORLD_WIDTH / 2);
int y = int(-position.y / TILE_HEIGHT);
return Point2f{ float(x), float(y) };
return Vector2f{ float(x), float(y) };
}
WorldTile * WorldGridManager::GetTileAtIndex(const int x, const int y) const {
if (x < 0 || x >= WORLD_WIDTH || y < 0 || y >= WORLD_HEIGHT) {
@@ -50,7 +50,7 @@ WorldTile * WorldGridManager::GetTileAtIndex(const int x, const int y) const {
}
return m_worldTiles[x][y];
}
WorldTile * WorldGridManager::GetTileAtWorldPos(const Point2f& pos) const {
WorldTile * WorldGridManager::GetTileAtWorldPos(const Vector2f& pos) const {
int x = int(pos.x / TILE_WIDTH + WORLD_WIDTH / 2);
int y = int(-pos.y / TILE_HEIGHT);
if (x < 0 || x >= WORLD_WIDTH || y < 0 || y >= WORLD_HEIGHT) {