(de)Serialized Shuman
This commit is contained in:
parent
6c36706f77
commit
0ea0eed1cc
15
ProjectMorault/Morault_EngineInfo.h
Normal file
15
ProjectMorault/Morault_EngineInfo.h
Normal file
@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
|
||||
#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
|
@ -1,4 +1,10 @@
|
||||
#include "Morault_Map.h"
|
||||
#include "Morault_EngineInfo.h"
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <sstream>
|
||||
#include <pugixml.hpp>
|
||||
|
||||
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 << "<!-- MANUAL OUTPUTTER -->\n\n";
|
||||
out << "<shuman>\n";
|
||||
out << "<engineinfo> <!-- For Debugging Purposes -->\n";
|
||||
out << "<engineversion>" << MORAULT_ENGINE_VERSION << "</engineversion>\n";
|
||||
out << "<enginecompiler>" << MORAULT_ENGINE_COMPILER << "</enginecompiler>\n";
|
||||
out << "</engineinfo>\n";
|
||||
|
||||
for (int i = 0; i < MapTriangles.size(); i++) {
|
||||
out << "<triangle>\n";
|
||||
out << "<a><x>" << MapTriangles[i].a.x << "</x><y>" << MapTriangles[i].a.y << "</y></a>\n";
|
||||
out << "<b><x>" << MapTriangles[i].b.x << "</x><y>" << MapTriangles[i].b.y << "</y></b>\n";
|
||||
out << "<c><x>" << MapTriangles[i].c.x << "</x><y>" << MapTriangles[i].c.y << "</y></c>\n";
|
||||
out << "<wallab>" << MapTriangles[i].wallAB << "</wallab>\n";
|
||||
out << "<wallbc>" << MapTriangles[i].wallBC << "</wallbc>\n";
|
||||
out << "<wallca>" << MapTriangles[i].wallCA << "</wallca>\n";
|
||||
out << "<ceiling>" << MapTriangles[i].ceilingTexture << "</ceiling>\n";
|
||||
out << "<floor>" << MapTriangles[i].floorTexture << "</floor>\n";
|
||||
|
||||
out << "<ceilingheight>" << MapTriangles[i].heightCeiling << "</ceilingheight>\n";
|
||||
out << "<floorheight>" << MapTriangles[i].heightFloor << "</floorheight>\n";
|
||||
out << "</triangle>\n";
|
||||
}
|
||||
|
||||
out << "</shuman>";
|
||||
out.close();
|
||||
}
|
||||
|
||||
Morault::Maps::Map::~Map()
|
||||
{
|
||||
}
|
||||
|
@ -23,7 +23,8 @@ namespace Morault {
|
||||
std::vector<MapTriangle> MapTriangles;
|
||||
Map();
|
||||
Map(std::string path);
|
||||
|
||||
void LoadMap(std::string path);
|
||||
void SaveMap(std::string path);
|
||||
~Map();
|
||||
};
|
||||
}
|
||||
|
79
ProjectMorault/Morault_Rendering.cpp
Normal file
79
ProjectMorault/Morault_Rendering.cpp
Normal file
@ -0,0 +1,79 @@
|
||||
#include "Morault_Rendering.h"
|
||||
#include <rlgl.h>
|
||||
|
||||
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);
|
||||
}
|
11
ProjectMorault/Morault_Rendering.h
Normal file
11
ProjectMorault/Morault_Rendering.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <raylib.h>
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -69,6 +69,7 @@ std::variant<Texture2D, bool> 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:
|
||||
|
7
ProjectMorault/Morault_Safety.cpp
Normal file
7
ProjectMorault/Morault_Safety.cpp
Normal file
@ -0,0 +1,7 @@
|
||||
#include "Morault_Safety.h"
|
||||
#include <Windows.h>
|
||||
#include <winuser.h>
|
||||
bool Morault::Safety::ConfirmQuitting()
|
||||
{
|
||||
return MessageBoxA(NULL, "Are you sure you want to quit?", "ProjectMorault", MB_YESNO) == IDYES; // Windows-specific for now
|
||||
}
|
7
ProjectMorault/Morault_Safety.h
Normal file
7
ProjectMorault/Morault_Safety.h
Normal file
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
namespace Morault {
|
||||
namespace Safety {
|
||||
bool ConfirmQuitting();
|
||||
}
|
||||
}
|
@ -135,17 +135,23 @@
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\deps\include\pugixml.cpp" />
|
||||
<ClCompile Include="main.cpp" />
|
||||
<ClCompile Include="Morault_Map.cpp" />
|
||||
<ClCompile Include="Morault_Player.cpp" />
|
||||
<ClCompile Include="Morault_Rendering.cpp" />
|
||||
<ClCompile Include="Morault_Resources.cpp" />
|
||||
<ClCompile Include="Morault_Safety.cpp" />
|
||||
<ClCompile Include="Morault_UDMF.cpp" />
|
||||
<ClCompile Include="Morault_Utils.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Morault_EngineInfo.h" />
|
||||
<ClInclude Include="Morault_Map.h" />
|
||||
<ClInclude Include="Morault_Player.h" />
|
||||
<ClInclude Include="Morault_Rendering.h" />
|
||||
<ClInclude Include="Morault_Resources.h" />
|
||||
<ClInclude Include="Morault_Safety.h" />
|
||||
<ClInclude Include="Morault_UDMF.h" />
|
||||
<ClInclude Include="Morault_Utils.h" />
|
||||
</ItemGroup>
|
||||
|
@ -13,6 +13,9 @@
|
||||
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
|
||||
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="Ext">
|
||||
<UniqueIdentifier>{0c91bd51-a86a-44f3-a6cb-b5d7b38e6b69}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="main.cpp">
|
||||
@ -33,6 +36,15 @@
|
||||
<ClCompile Include="Morault_Map.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Morault_Rendering.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\deps\include\pugixml.cpp">
|
||||
<Filter>Ext</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Morault_Safety.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Morault_Resources.h">
|
||||
@ -50,5 +62,14 @@
|
||||
<ClInclude Include="Morault_Map.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Morault_Rendering.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Morault_EngineInfo.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Morault_Safety.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
176
ProjectMorault/data/maps/test.shuman
Normal file
176
ProjectMorault/data/maps/test.shuman
Normal file
@ -0,0 +1,176 @@
|
||||
<!-- MANUAL OUTPUTTER -->
|
||||
|
||||
<shuman>
|
||||
<engineinfo> <!-- For Debugging Purposes -->
|
||||
<engineversion>ProjectMorault DEBUG VERSION Jun 7 2025</engineversion>
|
||||
<enginecompiler>MSVC 1942</enginecompiler>
|
||||
</engineinfo>
|
||||
<triangle>
|
||||
<a><x>-128</x><y>-128</y></a>
|
||||
<b><x>66</x><y>159</y></b>
|
||||
<c><x>131</x><y>-127</y></c>
|
||||
<wallab>pms:none</wallab>
|
||||
<wallbc>data/textures/cta.png</wallbc>
|
||||
<wallca>pms:none</wallca>
|
||||
<ceiling>pms:SKY</ceiling>
|
||||
<floor>data/textures/test.png</floor>
|
||||
<ceilingheight>128</ceilingheight>
|
||||
<floorheight>0</floorheight>
|
||||
</triangle>
|
||||
<triangle>
|
||||
<a><x>-128</x><y>-128</y></a>
|
||||
<b><x>-306</x><y>146</y></b>
|
||||
<c><x>66</x><y>159</y></c>
|
||||
<wallab>data/textures/test.png</wallab>
|
||||
<wallbc>pms:none</wallbc>
|
||||
<wallca>pms:none</wallca>
|
||||
<ceiling>data/textures/woodfloor051.png</ceiling>
|
||||
<floor>data/textures/fabric040.png</floor>
|
||||
<ceilingheight>128</ceilingheight>
|
||||
<floorheight>0</floorheight>
|
||||
</triangle>
|
||||
<triangle>
|
||||
<a><x>-128</x><y>-128</y></a>
|
||||
<b><x>131</x><y>-127</y></b>
|
||||
<c><x>118</x><y>-419</y></c>
|
||||
<wallab>pms:none</wallab>
|
||||
<wallbc>pms:none</wallbc>
|
||||
<wallca>data/textures/teki.png</wallca>
|
||||
<ceiling>pms:SKY</ceiling>
|
||||
<floor>data/textures/test.png</floor>
|
||||
<ceilingheight>128</ceilingheight>
|
||||
<floorheight>0</floorheight>
|
||||
</triangle>
|
||||
<triangle>
|
||||
<a><x>118</x><y>-419</y></a>
|
||||
<b><x>131</x><y>-127</y></b>
|
||||
<c><x>399</x><y>-372</y></c>
|
||||
<wallab>pms:none</wallab>
|
||||
<wallbc>pms:none</wallbc>
|
||||
<wallca>data/textures/bean consume.png</wallca>
|
||||
<ceiling>data/textures/bricks094.png</ceiling>
|
||||
<floor>data/textures/woodfloor051.png</floor>
|
||||
<ceilingheight>128</ceilingheight>
|
||||
<floorheight>0</floorheight>
|
||||
</triangle>
|
||||
<triangle>
|
||||
<a><x>399</x><y>-372</y></a>
|
||||
<b><x>131</x><y>-127</y></b>
|
||||
<c><x>499</x><y>-285</y></c>
|
||||
<wallab>pms:none</wallab>
|
||||
<wallbc>data/textures/test.png</wallbc>
|
||||
<wallca>pms:none</wallca>
|
||||
<ceiling>data/textures/bricks094.png</ceiling>
|
||||
<floor>data/textures/woodfloor051.png</floor>
|
||||
<ceilingheight>128</ceilingheight>
|
||||
<floorheight>0</floorheight>
|
||||
</triangle>
|
||||
<triangle>
|
||||
<a><x>-306</x><y>146</y></a>
|
||||
<b><x>-188</x><y>391</y></b>
|
||||
<c><x>66</x><y>159</y></c>
|
||||
<wallab>data/textures/test.png</wallab>
|
||||
<wallbc>pms:none</wallbc>
|
||||
<wallca>pms:none</wallca>
|
||||
<ceiling>pms:SKY</ceiling>
|
||||
<floor>data/textures/test.png</floor>
|
||||
<ceilingheight>128</ceilingheight>
|
||||
<floorheight>0</floorheight>
|
||||
</triangle>
|
||||
<triangle>
|
||||
<a><x>66</x><y>159</y></a>
|
||||
<b><x>-188</x><y>391</y></b>
|
||||
<c><x>427</x><y>230</y></c>
|
||||
<wallab>pms:none</wallab>
|
||||
<wallbc>pms:none</wallbc>
|
||||
<wallca>data/textures/bf68c0f91f7f3b92.png</wallca>
|
||||
<ceiling>data/textures/fabric040.png</ceiling>
|
||||
<floor>data/textures/test.png</floor>
|
||||
<ceilingheight>128</ceilingheight>
|
||||
<floorheight>0</floorheight>
|
||||
</triangle>
|
||||
<triangle>
|
||||
<a><x>-188</x><y>391</y></a>
|
||||
<b><x>431</x><y>379</y></b>
|
||||
<c><x>427</x><y>230</y></c>
|
||||
<wallab>data/textures/gun.png</wallab>
|
||||
<wallbc>pms:none</wallbc>
|
||||
<wallca>pms:none</wallca>
|
||||
<ceiling>data/textures/fabric040.png</ceiling>
|
||||
<floor>data/textures/test.png</floor>
|
||||
<ceilingheight>128</ceilingheight>
|
||||
<floorheight>0</floorheight>
|
||||
</triangle>
|
||||
<triangle>
|
||||
<a><x>399</x><y>-372</y></a>
|
||||
<b><x>499</x><y>-285</y></b>
|
||||
<c><x>806</x><y>-399</y></c>
|
||||
<wallab>pms:none</wallab>
|
||||
<wallbc>pms:none</wallbc>
|
||||
<wallca>data/textures/test.png</wallca>
|
||||
<ceiling>pms:SKY</ceiling>
|
||||
<floor>data/textures/test.png</floor>
|
||||
<ceilingheight>128</ceilingheight>
|
||||
<floorheight>0</floorheight>
|
||||
</triangle>
|
||||
<triangle>
|
||||
<a><x>499</x><y>-285</y></a>
|
||||
<b><x>931</x><y>-146</y></b>
|
||||
<c><x>806</x><y>-399</y></c>
|
||||
<wallab>pms:none</wallab>
|
||||
<wallbc>data/textures/test.png</wallbc>
|
||||
<wallca>pms:none</wallca>
|
||||
<ceiling>data/textures/fabric040.png</ceiling>
|
||||
<floor>data/textures/bricks094.png</floor>
|
||||
<ceilingheight>128</ceilingheight>
|
||||
<floorheight>0</floorheight>
|
||||
</triangle>
|
||||
<triangle>
|
||||
<a><x>499</x><y>-285</y></a>
|
||||
<b><x>443</x><y>106</y></b>
|
||||
<c><x>931</x><y>-146</y></c>
|
||||
<wallab>data/textures/test.png</wallab>
|
||||
<wallbc>pms:none</wallbc>
|
||||
<wallca>pms:none</wallca>
|
||||
<ceiling>data/textures/fabric040.png</ceiling>
|
||||
<floor>data/textures/teki.png</floor>
|
||||
<ceilingheight>300</ceilingheight>
|
||||
<floorheight>-40</floorheight>
|
||||
</triangle>
|
||||
<triangle>
|
||||
<a><x>443</x><y>106</y></a>
|
||||
<b><x>966</x><y>185</y></b>
|
||||
<c><x>931</x><y>-146</y></c>
|
||||
<wallab>pms:none</wallab>
|
||||
<wallbc>data/textures/gun.png</wallbc>
|
||||
<wallca>pms:none</wallca>
|
||||
<ceiling>pms:SKY</ceiling>
|
||||
<floor>data/textures/test.png</floor>
|
||||
<ceilingheight>128</ceilingheight>
|
||||
<floorheight>0</floorheight>
|
||||
</triangle>
|
||||
<triangle>
|
||||
<a><x>443</x><y>106</y></a>
|
||||
<b><x>427</x><y>230</y></b>
|
||||
<c><x>966</x><y>185</y></c>
|
||||
<wallab>data/textures/bricks094.png</wallab>
|
||||
<wallbc>pms:none</wallbc>
|
||||
<wallca>pms:none</wallca>
|
||||
<ceiling>pms:SKY</ceiling>
|
||||
<floor>data/textures/test.png</floor>
|
||||
<ceilingheight>128</ceilingheight>
|
||||
<floorheight>0</floorheight>
|
||||
</triangle>
|
||||
<triangle>
|
||||
<a><x>427</x><y>230</y></a>
|
||||
<b><x>431</x><y>379</y></b>
|
||||
<c><x>966</x><y>185</y></c>
|
||||
<wallab>pms:none</wallab>
|
||||
<wallbc>data/textures/bricks094.png</wallbc>
|
||||
<wallca>pms:none</wallca>
|
||||
<ceiling>pms:SKY</ceiling>
|
||||
<floor>data/textures/test.png</floor>
|
||||
<ceilingheight>128</ceilingheight>
|
||||
<floorheight>0</floorheight>
|
||||
</triangle>
|
||||
</shuman>
|
@ -6,6 +6,8 @@
|
||||
#include <raymath.h>
|
||||
#include <rlgl.h>
|
||||
#include <string>
|
||||
#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<Texture2D>(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<Texture2D>(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<Texture2D>(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<Texture2D>(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<Texture2D>(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;
|
||||
|
@ -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.
|
||||
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.
|
Loading…
x
Reference in New Issue
Block a user