mirror of
https://github.com/HowestDAE/dae16-VerhulstBram.git
synced 2025-12-16 04:21:48 +01:00
Added Buildings
Fixed rendering bugs with edges
This commit is contained in:
25
.idea/.idea.Motherload/.idea/workspace.xml
generated
25
.idea/.idea.Motherload/.idea/workspace.xml
generated
@@ -13,15 +13,11 @@
|
||||
<list default="true" id="26a0623a-44d5-441c-8048-32ff1dab3479" name="Changes" comment="">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/.idea.Motherload/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.Motherload/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/utils.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/utils.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Engine/utils.h" beforeDir="false" afterPath="$PROJECT_DIR$/Engine/utils.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldGridManager.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GridSystem/WorldTile.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldTile.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/GridSystem/WorldTile.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/GridSystem/WorldTile.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Player.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Player.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Player.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Player.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/TextureManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/TextureManager.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/main.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/Game/main.cpp" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.h" beforeDir="false" afterPath="$PROJECT_DIR$/Game/Levels/World/WorldLevel.h" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/Resources/tiles/dirt/special/hardLeft.png" beforeDir="false" afterPath="$PROJECT_DIR$/Resources/tiles/dirt/special/hardLeft.png" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -40,6 +36,7 @@
|
||||
<setting file="file://$PROJECT_DIR$/Game/Animations/Animation.h" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Game/Camera.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="mock://C:/Users/Bram/Desktop/Programming 2/Exam/dae16-VerhulstBram/Game/main.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="mock://C:/Users/Bram/Desktop/Programming 2/Exam/dae16-VerhulstBram/Game/main.cpp" root0="SKIP_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Game/pch.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||
<setting file="file://$PROJECT_DIR$/Game/pch.h" root0="FORCE_HIGHLIGHTING" />
|
||||
</component>
|
||||
@@ -191,7 +188,8 @@
|
||||
<workItem from="1713544818472" duration="1549000" />
|
||||
<workItem from="1713546379562" duration="319000" />
|
||||
<workItem from="1713609308065" duration="368000" />
|
||||
<workItem from="1713624356487" duration="6843000" />
|
||||
<workItem from="1713624356487" duration="8634000" />
|
||||
<workItem from="1713734301178" duration="2970000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Rework Tile detection system">
|
||||
<option name="closed" value="true" />
|
||||
@@ -257,7 +255,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1713354916684</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="9" />
|
||||
<task id="LOCAL-00009" summary="Fix digging">
|
||||
<option name="closed" value="true" />
|
||||
<created>1713637256627</created>
|
||||
<option name="number" value="00009" />
|
||||
<option name="presentableId" value="LOCAL-00009" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1713637256627</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="10" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -274,7 +280,8 @@
|
||||
<MESSAGE value="Fixed sidePieces (Need to add more cases tho)" />
|
||||
<MESSAGE value="Pre Point2f Nuke Fixed drawing, Added general optimisations" />
|
||||
<MESSAGE value="Remove Point2f, replace with Vector2f" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Remove Point2f, replace with Vector2f" />
|
||||
<MESSAGE value="Fix digging" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Fix digging" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<watches-manager>
|
||||
|
||||
@@ -232,15 +232,16 @@ void utils::FillPolygon(const std::vector<Vector2f>& vertices) {
|
||||
}
|
||||
void utils::DrawArrow(const Vector2f& start, const Vector2f& end, float lineWidth, float arrowSize) {
|
||||
// Origin is bottom left
|
||||
|
||||
utils::DrawLine(start, end);
|
||||
Vector2f arrowEnd = end - start;
|
||||
Vector2f dir = end - start;
|
||||
const float arrowAngle = atan2f(end.y - start.y, end.x - start.x);
|
||||
const float arrowAngle1 = arrowAngle + g_Pi + 0.4f;
|
||||
const float arrowAngle2 = arrowAngle + g_Pi - 0.4f;
|
||||
|
||||
utils::SetColor(Colors::RED);
|
||||
utils::DrawLine(end, end + Vector2f{ dir.y, -dir.x }.Normalized() * arrowSize);
|
||||
utils::DrawLine(end, end + Vector2f{ -dir.y, dir.x }.Normalized() * arrowSize);
|
||||
|
||||
|
||||
const Vector2f arrow1 { end.x + arrowSize * cosf(arrowAngle1), end.y + arrowSize * sinf(arrowAngle1) };
|
||||
const Vector2f arrow2 { end.x + arrowSize * cosf(arrowAngle2), end.y + arrowSize * sinf(arrowAngle2) };
|
||||
utils::DrawLine(end, arrow1);
|
||||
utils::DrawLine(end, arrow2);
|
||||
}
|
||||
|
||||
void utils::FillPolygon(const Vector2f* pVertices, size_t nrVertices) {
|
||||
|
||||
@@ -104,6 +104,14 @@ void WorldTile::DrawSide(const TileDirection& direction) {
|
||||
const WorldTile* tile = m_SurroundingTiles.GetTile(direction);
|
||||
if(tile != nullptr) {
|
||||
const GroundTileTypes type = tile->GetTileType()->getType();
|
||||
if(direction == TileDirection::BottomMiddle || direction == TileDirection::BottomLeft || direction == TileDirection::BottomRight) {
|
||||
if(type == Tiles::Special::GRASS->getType() || type == Tiles::Special::HARD_LEFT->getType() || type == Tiles::Special::HARD_MIDDLE->getType() || type == Tiles::Special::HARD_RIGHT->getType()) {
|
||||
//Fix for edges being renderd on grass / hard tiles
|
||||
//TODO: Possible fix if i have time
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(type != Tiles::AIR->getType()) {
|
||||
m_SideTextures[direction]->Draw(m_Position);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ enum class GroundTileTypes
|
||||
{
|
||||
Air,
|
||||
Dirt,
|
||||
Grass,
|
||||
Hard,
|
||||
Stone,
|
||||
Iron
|
||||
@@ -97,7 +98,7 @@ namespace Tiles
|
||||
static GroundTileType* HARD_RIGHT = new GroundTileType("tiles/dirt/special/hardRight.png", GroundTileTypes::Hard);
|
||||
static GroundTileType* HARD_MIDDLE = new GroundTileType("tiles/dirt/special/hardMiddle.png", GroundTileTypes::Hard);
|
||||
|
||||
static GroundTileType* GRASS = new RandomGroundTile("tiles/dirt/special/grass[0].png", GroundTileTypes::Dirt, 2);
|
||||
static GroundTileType* GRASS = new RandomGroundTile("tiles/dirt/special/grass[0].png", GroundTileTypes::Grass, 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -45,12 +45,36 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
|
||||
}
|
||||
for (int x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||
m_gridManager.GetTileAtIndex(x, 0)->SetTileType(Tiles::AIR);
|
||||
m_gridManager.GetTileAtIndex(x, 1)->SetTileType(Tiles::IRON);
|
||||
m_gridManager.GetTileAtIndex(x, 1)->SetTileType(Tiles::Special::GRASS);
|
||||
}
|
||||
m_refeulBuilding = new Building { "buildings/fuelStation.png", Vector2f { -700, -50 }, TextureManager::GetInstance() };
|
||||
m_refeulBuilding = new Building { "buildings/fuelStation.png", Vector2f { -700, -52 }, TextureManager::GetInstance() };
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f { -700, -50 })->SetTileType(Tiles::Special::HARD_LEFT);
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f { -650, -50 })->SetTileType(Tiles::Special::HARD_MIDDLE);
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f { -600, -50 })->SetTileType(Tiles::Special::HARD_RIGHT);
|
||||
|
||||
m_mineralBuilding = new Building { "buildings/mineralStation.png", Vector2f { -350, -52 }, TextureManager::GetInstance() };
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f {-400, -50})->SetTileType(Tiles::Special::HARD_LEFT);
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f {-350, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f {-300, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f {-250, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f {-200, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f {-150, -50})->SetTileType(Tiles::Special::HARD_RIGHT);
|
||||
|
||||
m_junkBuilding = new Building { "buildings/junkStation.png", Vector2f { 250, -52 }, TextureManager::GetInstance() };
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f {200, -50})->SetTileType(Tiles::Special::HARD_LEFT);
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f {250, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f {300, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f {350, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f {400, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f {450, -50})->SetTileType(Tiles::Special::HARD_RIGHT);
|
||||
|
||||
m_repairBuilding = new Building { "buildings/repairStation.png", Vector2f { 700, -52 }, TextureManager::GetInstance() };
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f {650, -50})->SetTileType(Tiles::Special::HARD_LEFT);
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f {700, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f {750, -50})->SetTileType(Tiles::Special::HARD_MIDDLE);
|
||||
m_gridManager.GetTileAtWorldPos(Vector2f {800, -50})->SetTileType(Tiles::Special::HARD_RIGHT);
|
||||
|
||||
|
||||
}
|
||||
WorldLevel::~WorldLevel() {
|
||||
//delete m_pTextTexture;
|
||||
@@ -137,6 +161,9 @@ void WorldLevel::Draw() const {
|
||||
}
|
||||
|
||||
m_refeulBuilding->Draw();
|
||||
m_mineralBuilding->Draw();
|
||||
m_junkBuilding->Draw();
|
||||
m_repairBuilding->Draw();
|
||||
m_player.Draw();
|
||||
|
||||
utils::SetColor(Colors::GREEN);
|
||||
|
||||
@@ -40,6 +40,9 @@ private:
|
||||
WorldTile* m_pSelectedTile { nullptr };
|
||||
|
||||
Building* m_refeulBuilding;
|
||||
Building* m_mineralBuilding;
|
||||
Building* m_junkBuilding;
|
||||
Building* m_repairBuilding;
|
||||
|
||||
float testLerp{ 0.0f };
|
||||
|
||||
|
||||
BIN
Resources/buildings/junkStation.png
Normal file
BIN
Resources/buildings/junkStation.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
BIN
Resources/buildings/mineralStation.png
Normal file
BIN
Resources/buildings/mineralStation.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 27 KiB |
BIN
Resources/buildings/repairStation.png
Normal file
BIN
Resources/buildings/repairStation.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 6.0 KiB After Width: | Height: | Size: 6.0 KiB |
Reference in New Issue
Block a user