diff --git a/ProjectMorault/Morault_Player.cpp b/ProjectMorault/Morault_Player.cpp index 2a80169..8d78e0d 100644 --- a/ProjectMorault/Morault_Player.cpp +++ b/ProjectMorault/Morault_Player.cpp @@ -36,11 +36,12 @@ Morault::Gameplay::PlayerController::PlayerController(Vector3 position) camera.projection = CAMERA_PERSPECTIVE; rotation = { 1,0,0 }; } -int collfloor = 5; +float collfloor = 5; +float collceiling = INFINITY; float gravity = 0; -void Morault::Gameplay::PlayerController::UpdatePlayerController(bool focus) +void Morault::Gameplay::PlayerController::UpdatePlayerController(bool focus, Morault::Maps::Map* map, float renderScale) { if (focus) { rotation = Vector3RotateByAxisAngle(rotation, { 0,1,0 }, -GetMouseDelta().x * 0.05 * sensitivityMultiplier); @@ -53,17 +54,30 @@ void Morault::Gameplay::PlayerController::UpdatePlayerController(bool focus) if (IsKeyDown(KEY_A)) camera.position = Vector3Add(camera.position, Vector3Multiply(Vector3RotateByAxisAngle({ rotation.x, 0, rotation.z }, {0,1,0}, DEG2RAD*90), {GetFrameTime(), GetFrameTime(), GetFrameTime()})); if (IsKeyDown(KEY_D)) camera.position = Vector3Add(camera.position, Vector3Multiply(Vector3RotateByAxisAngle({ rotation.x, 0, rotation.z }, { 0,1,0 }, DEG2RAD * -90), { GetFrameTime(), GetFrameTime(), GetFrameTime() })); if (IsKeyPressed(KEY_SPACE)) { - gravity -= 5; + gravity -= 10; } } + + for (int i = 0; i < map->MapTriangles.size(); i++) { + if (CheckCollisionPointTriangle({ camera.position.x / renderScale, camera.position.z / renderScale }, map->MapTriangles[i].a, map->MapTriangles[i].b, map->MapTriangles[i].c)) { + collfloor = map->MapTriangles[i].heightFloor * renderScale + 5; + collceiling = map->MapTriangles[i].heightCeiling * renderScale-2; + } + + } + camera.position.y -= gravity*GetFrameTime(); gravity += 10*GetFrameTime(); if (camera.position.y < collfloor) { camera.position.y = collfloor; gravity = 0; } + if (camera.position.y > collceiling) { + camera.position.y = collceiling; + gravity = 0; + } } Morault::Gameplay::PlayerController::~PlayerController() diff --git a/ProjectMorault/Morault_Player.h b/ProjectMorault/Morault_Player.h index 9c9f95b..c377d77 100644 --- a/ProjectMorault/Morault_Player.h +++ b/ProjectMorault/Morault_Player.h @@ -1,7 +1,7 @@ #pragma once #include #include - +#include "Morault_Map.h" namespace Morault { namespace Gameplay { typedef enum { @@ -27,7 +27,7 @@ namespace Morault { Vector3 rotation; Camera camera; float sensitivityMultiplier = 0.5; - void UpdatePlayerController(bool focus); + void UpdatePlayerController(bool focus, Maps::Map *map, float renderScale); ~PlayerController(); }; class Player { diff --git a/ProjectMorault/Morault_Rendering.cpp b/ProjectMorault/Morault_Rendering.cpp index f63a2cd..89335f4 100644 --- a/ProjectMorault/Morault_Rendering.cpp +++ b/ProjectMorault/Morault_Rendering.cpp @@ -34,16 +34,16 @@ void Morault::Rendering::DrawFloor(Vector2 a, Vector2 b, Vector2 c, int heightFl rlNormal3f(0, 1, 0); - rlTexCoord2f(0.0f, 1.0f); + rlTexCoord2f(a.x / 128, a.y / 128); rlVertex3f(a.x * renderScale, heightFloor * renderScale, a.y * renderScale); - rlTexCoord2f(0.0f, 0.0f); + rlTexCoord2f(b.x / 128, b.y / 128); rlVertex3f(b.x * renderScale, heightFloor * renderScale, b.y * renderScale); - rlTexCoord2f(1.0f, 0.0f); + rlTexCoord2f(c.x / 128, c.y / 128); rlVertex3f(c.x * renderScale, heightFloor * renderScale, c.y * renderScale); - rlTexCoord2f(1.0f, 0.0f); + rlTexCoord2f(c.x / 128, c.y / 128); rlVertex3f(c.x * renderScale, heightFloor * renderScale, c.y * renderScale); rlEnd(); @@ -61,16 +61,16 @@ void Morault::Rendering::DrawCeiling(Vector2 a, Vector2 b, Vector2 c, int height rlNormal3f(0, 1, 0); - rlTexCoord2f(0.0f, 1.0f); + rlTexCoord2f(a.x / 128, a.y / 128); rlVertex3f(a.x * renderScale, heightCeiling * renderScale, a.y * renderScale); - rlTexCoord2f(1.0f, 0.0f); + rlTexCoord2f(c.x / 128, c.y / 128); rlVertex3f(c.x * renderScale, heightCeiling * renderScale, c.y * renderScale); - rlTexCoord2f(0.0f, 0.0f); + rlTexCoord2f(b.x / 128, b.y / 128); rlVertex3f(b.x * renderScale, heightCeiling * renderScale, b.y * renderScale); - rlTexCoord2f(0.0f, 0.0f); + rlTexCoord2f(b.x / 128, b.y / 128); rlVertex3f(b.x * renderScale, heightCeiling * renderScale, b.y * renderScale); rlEnd(); diff --git a/ProjectMorault/Morault_Safety.cpp b/ProjectMorault/Morault_Safety.cpp index 5359a21..7604826 100644 --- a/ProjectMorault/Morault_Safety.cpp +++ b/ProjectMorault/Morault_Safety.cpp @@ -3,5 +3,5 @@ #include bool Morault::Safety::ConfirmQuitting() { - return MessageBoxA(NULL, "Are you sure you want to quit?", "ProjectMorault", MB_YESNO) == IDYES; // Windows-specific for now + return MessageBoxA(NULL, "Are you sure you want to quit?", "ProjectMorault", MB_YESNO | MB_DEFBUTTON2) == IDYES; // Windows-specific for now } diff --git a/ProjectMorault/data/maps/testoffice.shuman b/ProjectMorault/data/maps/testoffice.shuman new file mode 100644 index 0000000..14d07dd --- /dev/null +++ b/ProjectMorault/data/maps/testoffice.shuman @@ -0,0 +1,32 @@ + + + + +ProjectMorault DEBUG VERSION Jun 7 2025 +MSVC 1942 + + +-128-128 +128128 +128-128 +pms:none +data/textures/ambientcg/bricks094.png +data/textures/ambientcg/bricks094.png +data/textures/ambientcg/officeceiling001.png +data/textures/ambientcg/woodfloor051.png +128 +0 + + +-128-128 +-128128 +128128 +data/textures/ambientcg/bricks094.png +data/textures/ambientcg/bricks094.png +pms:none +data/textures/ambientcg/officeceiling001.png +data/textures/ambientcg/woodfloor051.png +128 +0 + + \ No newline at end of file diff --git a/ProjectMorault/data/textures/ambientcg/bricks094.png b/ProjectMorault/data/textures/ambientcg/bricks094.png new file mode 100644 index 0000000..4685d46 Binary files /dev/null and b/ProjectMorault/data/textures/ambientcg/bricks094.png differ diff --git a/ProjectMorault/data/textures/ambientcg/fabric040.png b/ProjectMorault/data/textures/ambientcg/fabric040.png new file mode 100644 index 0000000..7694d0d Binary files /dev/null and b/ProjectMorault/data/textures/ambientcg/fabric040.png differ diff --git a/ProjectMorault/data/textures/ambientcg/officeceiling001.png b/ProjectMorault/data/textures/ambientcg/officeceiling001.png new file mode 100644 index 0000000..bc9110b Binary files /dev/null and b/ProjectMorault/data/textures/ambientcg/officeceiling001.png differ diff --git a/ProjectMorault/data/textures/ambientcg/woodfloor051.png b/ProjectMorault/data/textures/ambientcg/woodfloor051.png new file mode 100644 index 0000000..383b6a1 Binary files /dev/null and b/ProjectMorault/data/textures/ambientcg/woodfloor051.png differ diff --git a/ProjectMorault/data/ui/health.png b/ProjectMorault/data/ui/health.png new file mode 100644 index 0000000..5e5d0d1 Binary files /dev/null and b/ProjectMorault/data/ui/health.png differ diff --git a/ProjectMorault/data/ui/health_big.png b/ProjectMorault/data/ui/health_big.png new file mode 100644 index 0000000..9042386 Binary files /dev/null and b/ProjectMorault/data/ui/health_big.png differ diff --git a/ProjectMorault/main.cpp b/ProjectMorault/main.cpp index fdd09de..692bff3 100644 --- a/ProjectMorault/main.cpp +++ b/ProjectMorault/main.cpp @@ -74,12 +74,12 @@ int main(int argc, char** argv) { eState = EDITOR; EnableCursor(); } - player.controller.UpdatePlayerController(!gamePaused); + player.controller.UpdatePlayerController(!gamePaused, map, MORAULT_MAP_RENDER_SCALE); BeginDrawing(); ClearBackground(BLACK); BeginMode3D(player.controller.camera); - DrawGrid(100, 10); + // DrawGrid(100, 10); for (int i = 0; i < map->MapTriangles.size(); i++) { if (map->MapTriangles[i].floorTexture != "pms:none") { @@ -125,7 +125,10 @@ int main(int argc, char** argv) { EndMode3D(); - + if (map->MapTriangles.size() == 0) DrawText("Map is empty, press E to open the map editor!", 0, GetScreenHeight()-94, 30, WHITE); + DrawTexture(std::get(Morault::Resources::Textures(Morault::Resources::get("data/ui/health.png"))), 0, GetScreenHeight() - 64, WHITE); + DrawText(TextFormat("%i", player.data.hp), 66, GetScreenHeight() - 62, 64, BLACK); + DrawText(TextFormat("%i", player.data.hp), 64, GetScreenHeight() - 64, 64, WHITE); DrawFPS(0, 0); EndDrawing(); } break; @@ -158,9 +161,9 @@ int main(int argc, char** argv) { if (IsKeyPressed(KEY_N)) { Morault::Maps::MapTriangle tri; - 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.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; @@ -173,9 +176,9 @@ int main(int argc, char** argv) { 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.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; @@ -237,6 +240,12 @@ int main(int argc, char** argv) { } } } + if (IsKeyDown(KEY_LEFT_SHIFT) && IsKeyDown(KEY_S) && IsKeyPressed(KEY_DELETE)) { + if (inSelection) { + map->MapTriangles.erase(map->MapTriangles.begin() + selection.sector); + inSelection = false; + } + } if (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_O)) { // open std::cout << "What to open? (empty = cancel) >>> "; diff --git a/readme.md b/readme.md index 990217a..f8839fe 100644 --- a/readme.md +++ b/readme.md @@ -31,4 +31,7 @@ Compiling on Windows with Visual Studio 2022 is relatively straight-forward. Sim 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 +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. + +## Licensing for game data +Textures that come from AmbientCG are under AmbientCG's license(a.k.a. CC0). The rest, which is custom-made for the game, is all-rights-reserved for now. \ No newline at end of file