Fix rendering issues, show player health on screen, prioritize no in quitting on Windows, add ceiling and floor collisions dependent on the map, remove grid from rendering, add some textures from CC0
This commit is contained in:
parent
0ea0eed1cc
commit
497efc6fbf
@ -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()
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include <iostream>
|
||||
#include <raylib.h>
|
||||
|
||||
#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 {
|
||||
|
@ -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();
|
||||
|
@ -3,5 +3,5 @@
|
||||
#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
|
||||
return MessageBoxA(NULL, "Are you sure you want to quit?", "ProjectMorault", MB_YESNO | MB_DEFBUTTON2) == IDYES; // Windows-specific for now
|
||||
}
|
||||
|
32
ProjectMorault/data/maps/testoffice.shuman
Normal file
32
ProjectMorault/data/maps/testoffice.shuman
Normal file
@ -0,0 +1,32 @@
|
||||
<!-- 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>128</x><y>128</y></b>
|
||||
<c><x>128</x><y>-128</y></c>
|
||||
<wallab>pms:none</wallab>
|
||||
<wallbc>data/textures/ambientcg/bricks094.png</wallbc>
|
||||
<wallca>data/textures/ambientcg/bricks094.png</wallca>
|
||||
<ceiling>data/textures/ambientcg/officeceiling001.png</ceiling>
|
||||
<floor>data/textures/ambientcg/woodfloor051.png</floor>
|
||||
<ceilingheight>128</ceilingheight>
|
||||
<floorheight>0</floorheight>
|
||||
</triangle>
|
||||
<triangle>
|
||||
<a><x>-128</x><y>-128</y></a>
|
||||
<b><x>-128</x><y>128</y></b>
|
||||
<c><x>128</x><y>128</y></c>
|
||||
<wallab>data/textures/ambientcg/bricks094.png</wallab>
|
||||
<wallbc>data/textures/ambientcg/bricks094.png</wallbc>
|
||||
<wallca>pms:none</wallca>
|
||||
<ceiling>data/textures/ambientcg/officeceiling001.png</ceiling>
|
||||
<floor>data/textures/ambientcg/woodfloor051.png</floor>
|
||||
<ceilingheight>128</ceilingheight>
|
||||
<floorheight>0</floorheight>
|
||||
</triangle>
|
||||
</shuman>
|
BIN
ProjectMorault/data/textures/ambientcg/bricks094.png
Normal file
BIN
ProjectMorault/data/textures/ambientcg/bricks094.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.4 MiB |
BIN
ProjectMorault/data/textures/ambientcg/fabric040.png
Normal file
BIN
ProjectMorault/data/textures/ambientcg/fabric040.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.8 MiB |
BIN
ProjectMorault/data/textures/ambientcg/officeceiling001.png
Normal file
BIN
ProjectMorault/data/textures/ambientcg/officeceiling001.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 125 KiB |
BIN
ProjectMorault/data/textures/ambientcg/woodfloor051.png
Normal file
BIN
ProjectMorault/data/textures/ambientcg/woodfloor051.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.6 MiB |
BIN
ProjectMorault/data/ui/health.png
Normal file
BIN
ProjectMorault/data/ui/health.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.9 KiB |
BIN
ProjectMorault/data/ui/health_big.png
Normal file
BIN
ProjectMorault/data/ui/health_big.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 180 KiB |
@ -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<Texture2D>(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) >>> ";
|
||||
|
@ -32,3 +32,6 @@ First, download [raylib 5.5 built for x64 MSVC from GitHub](https://github.com/r
|
||||
|
||||
### 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.
|
||||
|
||||
## 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.
|
Loading…
x
Reference in New Issue
Block a user