From 0ea0eed1cce5c17b8c971ac0c669b89074d8fdd7 Mon Sep 17 00:00:00 2001 From: Safariminer Date: Sat, 7 Jun 2025 13:38:18 -0400 Subject: [PATCH] (de)Serialized Shuman --- ProjectMorault/Morault_EngineInfo.h | 15 ++ ProjectMorault/Morault_Map.cpp | 74 ++++++ ProjectMorault/Morault_Map.h | 3 +- ProjectMorault/Morault_Rendering.cpp | 79 ++++++ ProjectMorault/Morault_Rendering.h | 11 + ProjectMorault/Morault_Resources.cpp | 1 + ProjectMorault/Morault_Safety.cpp | 7 + ProjectMorault/Morault_Safety.h | 7 + ProjectMorault/ProjectMorault.vcxproj | 6 + ProjectMorault/ProjectMorault.vcxproj.filters | 21 ++ ProjectMorault/data/maps/test.shuman | 176 +++++++++++++ ProjectMorault/main.cpp | 233 +++++++----------- readme.md | 6 +- 13 files changed, 496 insertions(+), 143 deletions(-) create mode 100644 ProjectMorault/Morault_EngineInfo.h create mode 100644 ProjectMorault/Morault_Rendering.cpp create mode 100644 ProjectMorault/Morault_Rendering.h create mode 100644 ProjectMorault/Morault_Safety.cpp create mode 100644 ProjectMorault/Morault_Safety.h create mode 100644 ProjectMorault/data/maps/test.shuman diff --git a/ProjectMorault/Morault_EngineInfo.h b/ProjectMorault/Morault_EngineInfo.h new file mode 100644 index 0000000..174e368 --- /dev/null +++ b/ProjectMorault/Morault_EngineInfo.h @@ -0,0 +1,15 @@ +#pragma once +#include +#include + +#ifdef _DEBUG +#define MORAULT_ENGINE_VERSION ("ProjectMorault DEBUG VERSION " + std::string(__DATE__)) +#else +#define MORAULT_ENGINE_VERSION ("ProjectMorault Release Pre-Alpha " + std::string(__DATE__)) +#endif + +#ifdef __INTEL_COMPILER +#define MORAULT_ENGINE_COMPILER "Intel OneAPI Compiler" +#elif _MSC_VER +#define MORAULT_ENGINE_COMPILER ("MSVC " + std::to_string(_MSC_VER)) +#endif \ No newline at end of file diff --git a/ProjectMorault/Morault_Map.cpp b/ProjectMorault/Morault_Map.cpp index 4c6e3a8..ad05ad4 100644 --- a/ProjectMorault/Morault_Map.cpp +++ b/ProjectMorault/Morault_Map.cpp @@ -1,4 +1,10 @@ #include "Morault_Map.h" +#include "Morault_EngineInfo.h" +#include +#include +#include +#include +#include Morault::Maps::Map::Map() { @@ -8,6 +14,74 @@ Morault::Maps::Map::Map(std::string path) { } +void Morault::Maps::Map::LoadMap(std::string path) +{ + MapTriangles.clear(); + pugi::xml_document doc; + pugi::xml_parse_result result = doc.load_file(path.c_str()); + if (result) { + pugi::xml_node root = doc.child("shuman"); + for (const auto& triangle : root.children("triangle")) { + MapTriangle newTri; + + newTri.a.x = std::stof(triangle.child("a").child("x").child_value()); + newTri.a.y = std::stof(triangle.child("a").child("y").child_value()); + newTri.b.x = std::stof(triangle.child("b").child("x").child_value()); + newTri.b.y = std::stof(triangle.child("b").child("y").child_value()); + newTri.c.x = std::stof(triangle.child("c").child("x").child_value()); + newTri.c.y = std::stof(triangle.child("c").child("y").child_value()); + + newTri.wallAB = triangle.child("wallab").child_value(); + newTri.wallBC = triangle.child("wallbc").child_value(); + newTri.wallCA = triangle.child("wallca").child_value(); + + newTri.ceilingTexture = triangle.child("ceiling").child_value(); + newTri.floorTexture = triangle.child("floor").child_value(); + + + newTri.heightCeiling = std::stoi(triangle.child("ceilingheight").child_value()); + newTri.heightFloor = std::stoi(triangle.child("floorheight").child_value()); + + + + MapTriangles.push_back(newTri); + } + } + else { + throw std::runtime_error("can't open file " + path + "!\n"); + } +} + +void Morault::Maps::Map::SaveMap(std::string path) +{ + std::ofstream out(path); + out << "\n\n"; + out << "\n"; + out << " \n"; + out << "" << MORAULT_ENGINE_VERSION << "\n"; + out << "" << MORAULT_ENGINE_COMPILER << "\n"; + out << "\n"; + + for (int i = 0; i < MapTriangles.size(); i++) { + out << "\n"; + out << "" << MapTriangles[i].a.x << "" << MapTriangles[i].a.y << "\n"; + out << "" << MapTriangles[i].b.x << "" << MapTriangles[i].b.y << "\n"; + out << "" << MapTriangles[i].c.x << "" << MapTriangles[i].c.y << "\n"; + out << "" << MapTriangles[i].wallAB << "\n"; + out << "" << MapTriangles[i].wallBC << "\n"; + out << "" << MapTriangles[i].wallCA << "\n"; + out << "" << MapTriangles[i].ceilingTexture << "\n"; + out << "" << MapTriangles[i].floorTexture << "\n"; + + out << "" << MapTriangles[i].heightCeiling << "\n"; + out << "" << MapTriangles[i].heightFloor << "\n"; + out << "\n"; + } + + out << ""; + out.close(); +} + Morault::Maps::Map::~Map() { } diff --git a/ProjectMorault/Morault_Map.h b/ProjectMorault/Morault_Map.h index 885db3e..a8f2ea3 100644 --- a/ProjectMorault/Morault_Map.h +++ b/ProjectMorault/Morault_Map.h @@ -23,7 +23,8 @@ namespace Morault { std::vector MapTriangles; Map(); Map(std::string path); - + void LoadMap(std::string path); + void SaveMap(std::string path); ~Map(); }; } diff --git a/ProjectMorault/Morault_Rendering.cpp b/ProjectMorault/Morault_Rendering.cpp new file mode 100644 index 0000000..f63a2cd --- /dev/null +++ b/ProjectMorault/Morault_Rendering.cpp @@ -0,0 +1,79 @@ +#include "Morault_Rendering.h" +#include + +void Morault::Rendering::DrawWall(Vector2 a, Vector2 b, int heightFloor, int heightCeiling, Texture2D texture, float renderScale) +{ + rlSetTexture(texture.id); + rlBegin(RL_QUADS); + rlColor4ub(255, 255, 255, 255); + rlNormal3f(-(b.y - a.y), 0, (b.x - a.x)); + + rlTexCoord2f(1.0f, 0.0f); rlVertex3f(a.x * renderScale, + heightCeiling * renderScale, + a.y * renderScale); + rlTexCoord2f(0.0f, 0.0f); rlVertex3f(b.x * renderScale, + heightCeiling * renderScale, + b.y * renderScale); + rlTexCoord2f(0.0f, 1.0f); rlVertex3f(b.x * renderScale, + heightFloor * renderScale, + b.y * renderScale); + rlTexCoord2f(1.0f, 1.0f); rlVertex3f(a.x * renderScale, + heightFloor * renderScale, + a.y * renderScale); + rlEnd(); + rlSetTexture(0); +} + +void Morault::Rendering::DrawFloor(Vector2 a, Vector2 b, Vector2 c, int heightFloor, Texture2D texture, float renderScale) +{ + rlSetTexture(texture.id); + + rlBegin(RL_QUADS); // workaround because triangles were stubborn with textures + + rlColor4ub(255, 255, 255, 255); + rlNormal3f(0, 1, 0); + + + rlTexCoord2f(0.0f, 1.0f); + rlVertex3f(a.x * renderScale, heightFloor * renderScale, a.y * renderScale); + + rlTexCoord2f(0.0f, 0.0f); + rlVertex3f(b.x * renderScale, heightFloor * renderScale, b.y * renderScale); + + rlTexCoord2f(1.0f, 0.0f); + rlVertex3f(c.x * renderScale, heightFloor * renderScale, c.y * renderScale); + + rlTexCoord2f(1.0f, 0.0f); + rlVertex3f(c.x * renderScale, heightFloor * renderScale, c.y * renderScale); + + rlEnd(); + + rlSetTexture(0); +} + +void Morault::Rendering::DrawCeiling(Vector2 a, Vector2 b, Vector2 c, int heightCeiling, Texture2D texture, float renderScale) +{ + rlSetTexture(texture.id); + + rlBegin(RL_QUADS); // workaround because triangles were stubborn with textures + + rlColor4ub(255, 255, 255, 255); + rlNormal3f(0, 1, 0); + + + rlTexCoord2f(0.0f, 1.0f); + rlVertex3f(a.x * renderScale, heightCeiling * renderScale, a.y * renderScale); + + rlTexCoord2f(1.0f, 0.0f); + rlVertex3f(c.x * renderScale, heightCeiling * renderScale, c.y * renderScale); + + rlTexCoord2f(0.0f, 0.0f); + rlVertex3f(b.x * renderScale, heightCeiling * renderScale, b.y * renderScale); + + rlTexCoord2f(0.0f, 0.0f); + rlVertex3f(b.x * renderScale, heightCeiling * renderScale, b.y * renderScale); + + rlEnd(); + + rlSetTexture(0); +} diff --git a/ProjectMorault/Morault_Rendering.h b/ProjectMorault/Morault_Rendering.h new file mode 100644 index 0000000..30fc810 --- /dev/null +++ b/ProjectMorault/Morault_Rendering.h @@ -0,0 +1,11 @@ +#pragma once + +#include + +namespace Morault { + namespace Rendering { + void DrawWall(Vector2 a, Vector2 b, int heightFloor, int heightCeiling, Texture2D texture, float renderScale); + void DrawFloor(Vector2 a, Vector2 b, Vector2 c, int heightFloor, Texture2D texture, float renderScale); + void DrawCeiling(Vector2 a, Vector2 b, Vector2 c, int heightCeiling, Texture2D texture, float renderScale); + } +} \ No newline at end of file diff --git a/ProjectMorault/Morault_Resources.cpp b/ProjectMorault/Morault_Resources.cpp index 6e757be..3600026 100644 --- a/ProjectMorault/Morault_Resources.cpp +++ b/ProjectMorault/Morault_Resources.cpp @@ -69,6 +69,7 @@ std::variant Morault::Resources::Textures(_ResourceRequest requ return true; break; case GET: + if (__textures_map.find(request.req) == __textures_map.end()) __textures_map[request.req] = LoadTexture(request.req.c_str()); return __textures_map[request.req]; break; case UNLOAD: diff --git a/ProjectMorault/Morault_Safety.cpp b/ProjectMorault/Morault_Safety.cpp new file mode 100644 index 0000000..5359a21 --- /dev/null +++ b/ProjectMorault/Morault_Safety.cpp @@ -0,0 +1,7 @@ +#include "Morault_Safety.h" +#include +#include +bool Morault::Safety::ConfirmQuitting() +{ + return MessageBoxA(NULL, "Are you sure you want to quit?", "ProjectMorault", MB_YESNO) == IDYES; // Windows-specific for now +} diff --git a/ProjectMorault/Morault_Safety.h b/ProjectMorault/Morault_Safety.h new file mode 100644 index 0000000..c0bd99a --- /dev/null +++ b/ProjectMorault/Morault_Safety.h @@ -0,0 +1,7 @@ +#pragma once + +namespace Morault { + namespace Safety { + bool ConfirmQuitting(); + } +} \ No newline at end of file diff --git a/ProjectMorault/ProjectMorault.vcxproj b/ProjectMorault/ProjectMorault.vcxproj index 4215563..e7200b5 100644 --- a/ProjectMorault/ProjectMorault.vcxproj +++ b/ProjectMorault/ProjectMorault.vcxproj @@ -135,17 +135,23 @@ + + + + + + diff --git a/ProjectMorault/ProjectMorault.vcxproj.filters b/ProjectMorault/ProjectMorault.vcxproj.filters index 3310e54..ef94c02 100644 --- a/ProjectMorault/ProjectMorault.vcxproj.filters +++ b/ProjectMorault/ProjectMorault.vcxproj.filters @@ -13,6 +13,9 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + {0c91bd51-a86a-44f3-a6cb-b5d7b38e6b69} + @@ -33,6 +36,15 @@ Source Files + + Source Files + + + Ext + + + Source Files + @@ -50,5 +62,14 @@ Header Files + + Header Files + + + Header Files + + + Header Files + \ No newline at end of file diff --git a/ProjectMorault/data/maps/test.shuman b/ProjectMorault/data/maps/test.shuman new file mode 100644 index 0000000..ecf0f77 --- /dev/null +++ b/ProjectMorault/data/maps/test.shuman @@ -0,0 +1,176 @@ + + + + +ProjectMorault DEBUG VERSION Jun 7 2025 +MSVC 1942 + + +-128-128 +66159 +131-127 +pms:none +data/textures/cta.png +pms:none +pms:SKY +data/textures/test.png +128 +0 + + +-128-128 +-306146 +66159 +data/textures/test.png +pms:none +pms:none +data/textures/woodfloor051.png +data/textures/fabric040.png +128 +0 + + +-128-128 +131-127 +118-419 +pms:none +pms:none +data/textures/teki.png +pms:SKY +data/textures/test.png +128 +0 + + +118-419 +131-127 +399-372 +pms:none +pms:none +data/textures/bean consume.png +data/textures/bricks094.png +data/textures/woodfloor051.png +128 +0 + + +399-372 +131-127 +499-285 +pms:none +data/textures/test.png +pms:none +data/textures/bricks094.png +data/textures/woodfloor051.png +128 +0 + + +-306146 +-188391 +66159 +data/textures/test.png +pms:none +pms:none +pms:SKY +data/textures/test.png +128 +0 + + +66159 +-188391 +427230 +pms:none +pms:none +data/textures/bf68c0f91f7f3b92.png +data/textures/fabric040.png +data/textures/test.png +128 +0 + + +-188391 +431379 +427230 +data/textures/gun.png +pms:none +pms:none +data/textures/fabric040.png +data/textures/test.png +128 +0 + + +399-372 +499-285 +806-399 +pms:none +pms:none +data/textures/test.png +pms:SKY +data/textures/test.png +128 +0 + + +499-285 +931-146 +806-399 +pms:none +data/textures/test.png +pms:none +data/textures/fabric040.png +data/textures/bricks094.png +128 +0 + + +499-285 +443106 +931-146 +data/textures/test.png +pms:none +pms:none +data/textures/fabric040.png +data/textures/teki.png +300 +-40 + + +443106 +966185 +931-146 +pms:none +data/textures/gun.png +pms:none +pms:SKY +data/textures/test.png +128 +0 + + +443106 +427230 +966185 +data/textures/bricks094.png +pms:none +pms:none +pms:SKY +data/textures/test.png +128 +0 + + +427230 +431379 +966185 +pms:none +data/textures/bricks094.png +pms:none +pms:SKY +data/textures/test.png +128 +0 + + \ No newline at end of file diff --git a/ProjectMorault/main.cpp b/ProjectMorault/main.cpp index d0150c4..fdd09de 100644 --- a/ProjectMorault/main.cpp +++ b/ProjectMorault/main.cpp @@ -6,6 +6,8 @@ #include #include #include +#include "Morault_Rendering.h" +#include "Morault_Safety.h" #define MORAULT_MAP_RENDER_SCALE 0.1f @@ -28,6 +30,8 @@ struct EditorSelection { SectorLineSelection line; }; int main(int argc, char** argv) { + bool running = true; + SetConfigFlags(FLAG_WINDOW_RESIZABLE); InitWindow(1280, 720, "ProjectMorault"); SetTargetFPS(60); SetExitKey(0); @@ -56,8 +60,13 @@ int main(int argc, char** argv) { Vector2 editorOffset = { 0,0 }; - while (!WindowShouldClose()) { - + while (running) { + + if (WindowShouldClose()) { + if (Morault::Safety::ConfirmQuitting()) running = false; + } + + if (IsKeyDown(KEY_LEFT_ALT) && IsKeyPressed(KEY_ENTER)) ToggleFullscreen(); switch(eState){ case GAME: { @@ -73,149 +82,41 @@ int main(int argc, char** argv) { DrawGrid(100, 10); for (int i = 0; i < map->MapTriangles.size(); i++) { - DrawTriangle3D( - { - map->MapTriangles[i].a.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightFloor * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].a.y * MORAULT_MAP_RENDER_SCALE - }, - { - map->MapTriangles[i].b.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightFloor * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].b.y * MORAULT_MAP_RENDER_SCALE - }, - { - map->MapTriangles[i].c.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightFloor * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].c.y * MORAULT_MAP_RENDER_SCALE - }, - RED - ); - DrawTriangle3D( - { - map->MapTriangles[i].a.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightCeiling * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].a.y * MORAULT_MAP_RENDER_SCALE - }, - { - map->MapTriangles[i].c.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightCeiling * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].c.y * MORAULT_MAP_RENDER_SCALE - }, - { - map->MapTriangles[i].b.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightCeiling * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].b.y * MORAULT_MAP_RENDER_SCALE - }, - RED - ); + if (map->MapTriangles[i].floorTexture != "pms:none") { + Morault::Rendering::DrawFloor(map->MapTriangles[i].a, map->MapTriangles[i].b, map->MapTriangles[i].c, map->MapTriangles[i].heightFloor, std::get(Morault::Resources::Textures(Morault::Resources::get(map->MapTriangles[i].floorTexture))), MORAULT_MAP_RENDER_SCALE); + } + if (map->MapTriangles[i].ceilingTexture != "pms:none" && map->MapTriangles[i].ceilingTexture != "pms:SKY") { + Morault::Rendering::DrawCeiling(map->MapTriangles[i].a, map->MapTriangles[i].b, map->MapTriangles[i].c, map->MapTriangles[i].heightCeiling, std::get(Morault::Resources::Textures(Morault::Resources::get(map->MapTriangles[i].ceilingTexture))), MORAULT_MAP_RENDER_SCALE); + } if (map->MapTriangles[i].wallAB != "pms:none") { - DrawTriangle3D({ - map->MapTriangles[i].a.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightCeiling * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].a.y * MORAULT_MAP_RENDER_SCALE - }, - { - map->MapTriangles[i].b.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightCeiling * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].b.y * MORAULT_MAP_RENDER_SCALE - }, - { - map->MapTriangles[i].a.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightFloor * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].a.y * MORAULT_MAP_RENDER_SCALE - }, - BLUE - ); - DrawTriangle3D({ - map->MapTriangles[i].a.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightFloor * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].a.y * MORAULT_MAP_RENDER_SCALE - }, - { - map->MapTriangles[i].b.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightCeiling * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].b.y * MORAULT_MAP_RENDER_SCALE - }, - { - map->MapTriangles[i].b.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightFloor * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].b.y * MORAULT_MAP_RENDER_SCALE - }, - BLUE + Morault::Rendering::DrawWall( + map->MapTriangles[i].a, + map->MapTriangles[i].b, + map->MapTriangles[i].heightFloor, + map->MapTriangles[i].heightCeiling, + std::get(Morault::Resources::Textures(Morault::Resources::get(map->MapTriangles[i].wallAB))), + MORAULT_MAP_RENDER_SCALE ); } if (map->MapTriangles[i].wallBC != "pms:none") { - DrawTriangle3D({ - map->MapTriangles[i].b.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightCeiling * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].b.y * MORAULT_MAP_RENDER_SCALE - }, - { - map->MapTriangles[i].c.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightCeiling * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].c.y * MORAULT_MAP_RENDER_SCALE - }, - { - map->MapTriangles[i].b.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightFloor * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].b.y * MORAULT_MAP_RENDER_SCALE - }, - GREEN - ); - DrawTriangle3D({ - map->MapTriangles[i].b.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightFloor * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].b.y * MORAULT_MAP_RENDER_SCALE - }, - { - map->MapTriangles[i].c.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightCeiling * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].c.y * MORAULT_MAP_RENDER_SCALE - }, - { - map->MapTriangles[i].c.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightFloor * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].c.y * MORAULT_MAP_RENDER_SCALE - }, - GREEN + Morault::Rendering::DrawWall( + map->MapTriangles[i].b, + map->MapTriangles[i].c, + map->MapTriangles[i].heightFloor, + map->MapTriangles[i].heightCeiling, + std::get(Morault::Resources::Textures(Morault::Resources::get(map->MapTriangles[i].wallBC))), + MORAULT_MAP_RENDER_SCALE ); } if (map->MapTriangles[i].wallCA != "pms:none") { - DrawTriangle3D({ - map->MapTriangles[i].c.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightCeiling * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].c.y * MORAULT_MAP_RENDER_SCALE - }, - { - map->MapTriangles[i].a.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightCeiling * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].a.y * MORAULT_MAP_RENDER_SCALE - }, - { - map->MapTriangles[i].c.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightFloor * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].c.y * MORAULT_MAP_RENDER_SCALE - }, - PURPLE - ); - DrawTriangle3D({ - map->MapTriangles[i].c.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightFloor * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].c.y * MORAULT_MAP_RENDER_SCALE - }, - { - map->MapTriangles[i].a.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightCeiling * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].a.y * MORAULT_MAP_RENDER_SCALE - }, - { - map->MapTriangles[i].a.x * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].heightFloor * MORAULT_MAP_RENDER_SCALE, - map->MapTriangles[i].a.y * MORAULT_MAP_RENDER_SCALE - }, - PURPLE + Morault::Rendering::DrawWall( + map->MapTriangles[i].c, + map->MapTriangles[i].a, + map->MapTriangles[i].heightFloor, + map->MapTriangles[i].heightCeiling, + std::get(Morault::Resources::Textures(Morault::Resources::get(map->MapTriangles[i].wallCA))), + MORAULT_MAP_RENDER_SCALE ); } @@ -255,10 +156,11 @@ int main(int argc, char** argv) { } if (IsKeyDown(KEY_LEFT_SHIFT)) { if (IsKeyPressed(KEY_N)) { + Morault::Maps::MapTriangle tri; - tri.a = { -128, -128 }; - tri.b = { 128,128 }; - tri.c = { 128,-128 }; + tri.a = { -128 + editorOffset.x, -128 + editorOffset.y }; + tri.b = { 128 + editorOffset.x, 128 + editorOffset.y }; + tri.c = { 128 + editorOffset.x,-128 + editorOffset.y }; tri.floorTexture = "data/textures/test.png"; tri.heightFloor = 0; tri.heightCeiling = 128; @@ -268,6 +170,22 @@ int main(int argc, char** argv) { tri.wallBC = "data/textures/test.png"; tri.wallCA = "data/textures/test.png"; map->MapTriangles.push_back(tri); + if (IsKeyDown(KEY_LEFT_CONTROL)) { + map->MapTriangles[map->MapTriangles.size() - 1].wallAB = "pms:none"; + + tri.a = { -128 + editorOffset.x, -128 + editorOffset.y }; + tri.b = { -128 + editorOffset.x, 128 + editorOffset.y }; + tri.c = { 128 + editorOffset.x, 128 + editorOffset.y }; + tri.floorTexture = "data/textures/test.png"; + tri.heightFloor = 0; + tri.heightCeiling = 128; + tri.hasFloor = true; + tri.hasCeiling = false; + tri.wallAB = "data/textures/test.png"; + tri.wallBC = "data/textures/test.png"; + tri.wallCA = "pms:none"; + map->MapTriangles.push_back(tri); + } } } @@ -320,7 +238,40 @@ int main(int argc, char** argv) { } } - if (IsKeyPressed(KEY_T) && selection.line != NOLINE) { + if (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_O)) { // open + std::cout << "What to open? (empty = cancel) >>> "; + std::string path; + std::getline(std::cin, path); + if (path != "") map->LoadMap(path); + } + + if (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_S)) { // save + std::cout << "Where to save? (empty = cancel) >>> "; + std::string path; + std::getline(std::cin, path); + if (path != "") map->SaveMap(path); + } + + if (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_T)) { + if (inSelection) { + if (IsKeyDown(KEY_LEFT_SHIFT)) { + std::cout << "Texture for ceiling " << selection.sector << "? (current texture is: " << map->MapTriangles[selection.sector].ceilingTexture << ") >>>"; + + std::string texture; + std::getline(std::cin, texture); + if (texture != "") map->MapTriangles[selection.sector].ceilingTexture = texture; + } + else{ + std::cout << "Texture for floor " << selection.sector << "? (current texture is: " << map->MapTriangles[selection.sector].floorTexture << ") >>>"; + + std::string texture; + std::getline(std::cin, texture); + if (texture != "") map->MapTriangles[selection.sector].floorTexture = texture; + } + } + } + + if (IsKeyPressed(KEY_T) && selection.line != NOLINE && !IsKeyDown(KEY_LEFT_CONTROL)) { std::cout << "Texture for line " << selection.sector << ":" << (selection.line == AB ? "AB" : selection.line == BC ? "BC" : "CA") << "? (current texture is: " << (selection.line == AB ? map->MapTriangles[selection.sector].wallAB : selection.line == BC ? map->MapTriangles[selection.sector].wallBC : map->MapTriangles[selection.sector].wallCA) << ") >>>"; std::string texture; diff --git a/readme.md b/readme.md index ba898f0..990217a 100644 --- a/readme.md +++ b/readme.md @@ -22,9 +22,13 @@ Collaboration is more or less only open to other tilde.town users for the time b ## Dependencies - C++20 - raylib 5.5 +- pugixml 1.15 ## Building for Windows (VS2022) Compiling on Windows with Visual Studio 2022 is relatively straight-forward. Simply clone the repository, then create a ``deps`` folder at the root of the repo. Inside your new folder, create an ``include`` folder and a ``lib`` folder. Then, follow the instructions for each dependency. Afterwards, simply open the ``ProjectMorault.sln`` solution using Visual Studio 2022 and run. ### raylib 5.5 -First, download [raylib 5.5 built for x64 MSVC from GitHub](https://github.com/raysan5/raylib/releases/download/5.5/raylib-5.5_win64_msvc16.zip). Then, place the contents of the ``include`` folder of the archive within your ``deps/include`` folder. Then, place the contents of the ``lib`` folder of the archive within your ``deps/lib`` folder. \ No newline at end of file +First, download [raylib 5.5 built for x64 MSVC from GitHub](https://github.com/raysan5/raylib/releases/download/5.5/raylib-5.5_win64_msvc16.zip). Then, place the contents of the ``include`` folder of the archive within your ``deps/include`` folder. Then, place the contents of the ``lib`` folder of the archive within your ``deps/lib`` folder. + +### pugixml 1.15 +First, download pugixml 1.15 from the GitHub repository at gh:zeux/pugixml. Then, place the contents of the archive's ``src`` folder in your ``deps/include`` folder. \ No newline at end of file