Compare commits
5 Commits
0ea0eed1cc
...
15ec5f71d6
Author | SHA1 | Date | |
---|---|---|---|
|
15ec5f71d6 | ||
|
66956de068 | ||
|
5f6fb70475 | ||
|
0f2a5f4e15 | ||
|
497efc6fbf |
99
ProjectMorault/Morault_Canvas.cpp
Normal file
99
ProjectMorault/Morault_Canvas.cpp
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
#include "Morault_Canvas.h"
|
||||||
|
#include "Morault_Resources.h"
|
||||||
|
#include <raymath.h>
|
||||||
|
#include "pugixml.hpp"
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
|
void Morault::UI::Image::Draw(Morault::Gameplay::Player player)
|
||||||
|
{
|
||||||
|
using namespace Morault::Resources;
|
||||||
|
Vector2 anchorPosition;
|
||||||
|
if (anchor == BL) anchorPosition = { 0, (float)GetScreenHeight() };
|
||||||
|
if (anchor == BR) anchorPosition = { (float)GetScreenWidth(), (float)GetScreenHeight() };
|
||||||
|
if (anchor == TL) anchorPosition = { 0, 0 };
|
||||||
|
if (anchor == TR) anchorPosition = { (float)GetScreenWidth(), 0};
|
||||||
|
if (anchor == CN) anchorPosition = { (float)GetScreenWidth() / 2, (float)GetScreenHeight() / 2 };
|
||||||
|
Vector2 finalPosition = anchorPosition + Vector2((float)posx, (float)posy);
|
||||||
|
|
||||||
|
DrawTextureEx(std::get<Texture2D>(Textures(get(src))), finalPosition, 0, scale, WHITE);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Morault::UI::Text::Draw(Morault::Gameplay::Player player)
|
||||||
|
{
|
||||||
|
using namespace Morault::Resources;
|
||||||
|
Vector2 anchorPosition;
|
||||||
|
if (anchor == BL) anchorPosition = { 0, (float)GetScreenHeight() };
|
||||||
|
if (anchor == BR) anchorPosition = { (float)GetScreenWidth(), (float)GetScreenHeight() };
|
||||||
|
if (anchor == TL) anchorPosition = { 0, 0 };
|
||||||
|
if (anchor == TR) anchorPosition = { (float)GetScreenWidth(), 0 };
|
||||||
|
if (anchor == CN) anchorPosition = { (float)GetScreenWidth() / 2, (float)GetScreenHeight() / 2 };
|
||||||
|
Vector2 finalPosition = anchorPosition + Vector2((float)posx, (float)posy);
|
||||||
|
std::string temp = text;
|
||||||
|
temp.replace(temp.find("[PLAYERHP]"), std::string("[PLAYERHP]").size(), std::to_string(player.data.hp));
|
||||||
|
DrawText(temp.c_str(), finalPosition.x, finalPosition.y, size, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
Morault::UI::Canvas::Canvas()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
Morault::UI::Canvas::Canvas(std::string canvasfile)
|
||||||
|
{
|
||||||
|
pugi::xml_document doc;
|
||||||
|
pugi::xml_parse_result result = doc.load_file(canvasfile.c_str());
|
||||||
|
|
||||||
|
if (!result) throw;
|
||||||
|
|
||||||
|
pugi::xml_node root = doc.child("canvas");
|
||||||
|
|
||||||
|
for (const auto& img : root.children("img")) {
|
||||||
|
UI::Image newimg;
|
||||||
|
newimg.anchor = (std::string)img.attribute("anchor").as_string() == "bl" ? BL :
|
||||||
|
(std::string)img.attribute("anchor").as_string() == "br" ? BR :
|
||||||
|
(std::string)img.attribute("anchor").as_string() == "tl" ? TL :
|
||||||
|
(std::string)img.attribute("anchor").as_string() == "tr" ? TR :
|
||||||
|
CN;
|
||||||
|
newimg.posx = img.attribute("posx").as_int();
|
||||||
|
newimg.posy = img.attribute("posy").as_int();
|
||||||
|
|
||||||
|
|
||||||
|
newimg.scale = img.attribute("scale").as_float();
|
||||||
|
|
||||||
|
newimg.src = (std::string)img.attribute("src").as_string();
|
||||||
|
elements.push_back(std::make_shared<UI::Image>(newimg));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const auto& txt : root.children("text")) {
|
||||||
|
UI::Text newtxt;
|
||||||
|
newtxt.anchor = (std::string)txt.attribute("anchor").as_string() == "bl" ? BL :
|
||||||
|
(std::string)txt.attribute("anchor").as_string() == "br" ? BR :
|
||||||
|
(std::string)txt.attribute("anchor").as_string() == "tl" ? TL :
|
||||||
|
(std::string)txt.attribute("anchor").as_string() == "tr" ? TR :
|
||||||
|
CN;
|
||||||
|
newtxt.posx = txt.attribute("posx").as_int();
|
||||||
|
newtxt.posy = txt.attribute("posy").as_int();
|
||||||
|
newtxt.color.r = (unsigned char)std::stoi(txt.attribute("colr").as_string());
|
||||||
|
newtxt.color.g = (unsigned char)std::stoi(txt.attribute("colg").as_string());
|
||||||
|
newtxt.color.b = (unsigned char)std::stoi(txt.attribute("colb").as_string());
|
||||||
|
newtxt.color.a = (unsigned char)std::stoi(txt.attribute("cola").as_string());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
newtxt.size = txt.attribute("size").as_int();
|
||||||
|
|
||||||
|
newtxt.text = txt.child_value();
|
||||||
|
elements.push_back(std::make_shared<UI::Text>(newtxt));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void Morault::UI::Canvas::DrawCanvas(Morault::Gameplay::Player player)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < elements.size(); i++) elements[i]->Draw(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
Morault::UI::Canvas::~Canvas()
|
||||||
|
{
|
||||||
|
elements.clear();
|
||||||
|
}
|
48
ProjectMorault/Morault_Canvas.h
Normal file
48
ProjectMorault/Morault_Canvas.h
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <raylib.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include "Morault_Player.h"
|
||||||
|
#include <vector>
|
||||||
|
namespace Morault {
|
||||||
|
namespace UI {
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
BL, // bottom left
|
||||||
|
BR, // bottom right
|
||||||
|
TL, // top left
|
||||||
|
TR, // top right
|
||||||
|
CN // center
|
||||||
|
} Anchor;
|
||||||
|
class CanvasElement {
|
||||||
|
public:
|
||||||
|
int posx, posy;
|
||||||
|
Anchor anchor;
|
||||||
|
virtual void Draw(Morault::Gameplay::Player player) = 0;
|
||||||
|
};
|
||||||
|
class Image : public CanvasElement {
|
||||||
|
public:
|
||||||
|
int posx, posy;
|
||||||
|
Anchor anchor;
|
||||||
|
std::string src;
|
||||||
|
float scale;
|
||||||
|
void Draw(Morault::Gameplay::Player player);
|
||||||
|
};
|
||||||
|
class Text : public CanvasElement {
|
||||||
|
public:
|
||||||
|
int posx, posy;
|
||||||
|
Anchor anchor;
|
||||||
|
std::string text;
|
||||||
|
int size;
|
||||||
|
Color color;
|
||||||
|
void Draw(Morault::Gameplay::Player player);
|
||||||
|
};
|
||||||
|
class Canvas {
|
||||||
|
std::vector<std::shared_ptr<CanvasElement>> elements;
|
||||||
|
public:
|
||||||
|
Canvas();
|
||||||
|
Canvas(std::string canvasfile);
|
||||||
|
void DrawCanvas(Morault::Gameplay::Player player);
|
||||||
|
~Canvas();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -36,34 +36,161 @@ Morault::Gameplay::PlayerController::PlayerController(Vector3 position)
|
|||||||
camera.projection = CAMERA_PERSPECTIVE;
|
camera.projection = CAMERA_PERSPECTIVE;
|
||||||
rotation = { 1,0,0 };
|
rotation = { 1,0,0 };
|
||||||
}
|
}
|
||||||
int collfloor = 5;
|
float collfloor = 5;
|
||||||
|
float collceiling = INFINITY;
|
||||||
|
|
||||||
float gravity = 0;
|
float gravity = 0;
|
||||||
|
|
||||||
void Morault::Gameplay::PlayerController::UpdatePlayerController(bool focus)
|
bool qColl(float obesity, Vector3 futurePos, Morault::Maps::Map* map, float renderScale, Vector3 velocity) {
|
||||||
|
int currsec = -1;
|
||||||
|
Vector2 normalizedVelocity = Vector2Normalize({ velocity.x, velocity.z });
|
||||||
|
for (int i = 0; i < map->MapTriangles.size(); i++) {
|
||||||
|
|
||||||
|
if (CheckCollisionPointTriangle({ futurePos.x / renderScale, futurePos.z / renderScale }, map->MapTriangles[i].a, map->MapTriangles[i].b, map->MapTriangles[i].c)) {
|
||||||
|
currsec = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (currsec == -1) return true;
|
||||||
|
|
||||||
|
for (int i = 0; i < map->MapTriangles.size(); i++) {
|
||||||
|
// check wall collisions
|
||||||
|
if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, 300.0f, Vector2Multiply(map->MapTriangles[i].a, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].b, { renderScale,renderScale })) || CheckCollisionCircleLine({ futurePos.x, futurePos.z }, 300.0f, Vector2Multiply(map->MapTriangles[i].b, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].c, { renderScale,renderScale })) || CheckCollisionCircleLine({ futurePos.x, futurePos.z }, 300.0f, Vector2Multiply(map->MapTriangles[i].c, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].a, { renderScale,renderScale }))) {
|
||||||
|
|
||||||
|
if (
|
||||||
|
(map->MapTriangles[i].wallAB != "pms:none" ||
|
||||||
|
(map->MapTriangles[currsec].heightFloor < map->MapTriangles[i].heightFloor
|
||||||
|
? -(abs(map->MapTriangles[currsec].heightFloor) - abs(map->MapTriangles[i].heightFloor)) < 10 : false))
|
||||||
|
&& Vector2DotProduct({ -(map->MapTriangles[i].b.y - map->MapTriangles[i].a.y), (map->MapTriangles[i].b.x - map->MapTriangles[i].a.x) }, normalizedVelocity) > 0) {
|
||||||
|
|
||||||
|
int highestFloor = map->MapTriangles[i].heightFloor < map->MapTriangles[currsec].heightFloor ? map->MapTriangles[currsec].heightFloor : map->MapTriangles[i].heightFloor;
|
||||||
|
if (futurePos.y - 5 >= highestFloor * renderScale && map->MapTriangles[i].wallAB == "pms:none") {}
|
||||||
|
|
||||||
|
else if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, obesity, Vector2Multiply(map->MapTriangles[i].a, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].b, { renderScale,renderScale }))) {
|
||||||
|
// futurePos = camera.position;
|
||||||
|
|
||||||
|
// check which is highest
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
(map->MapTriangles[i].wallBC != "pms:none" ||
|
||||||
|
(map->MapTriangles[currsec].heightFloor < map->MapTriangles[i].heightFloor
|
||||||
|
? -(abs(map->MapTriangles[currsec].heightFloor) - abs(map->MapTriangles[i].heightFloor)) < 10 : false))
|
||||||
|
&& Vector2DotProduct({ -(map->MapTriangles[i].c.y - map->MapTriangles[i].b.y), (map->MapTriangles[i].c.x - map->MapTriangles[i].b.x) }, normalizedVelocity) > 0) {
|
||||||
|
int highestFloor = map->MapTriangles[i].heightFloor < map->MapTriangles[currsec].heightFloor ? map->MapTriangles[currsec].heightFloor : map->MapTriangles[i].heightFloor;
|
||||||
|
if (futurePos.y - 5 >= highestFloor * renderScale && map->MapTriangles[i].wallAB == "pms:none") {}
|
||||||
|
|
||||||
|
else if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, obesity, Vector2Multiply(map->MapTriangles[i].b, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].c, { renderScale,renderScale }))) {
|
||||||
|
|
||||||
|
// check which is highest
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
(map->MapTriangles[i].wallCA != "pms:none" ||
|
||||||
|
(map->MapTriangles[currsec].heightFloor < map->MapTriangles[i].heightFloor
|
||||||
|
? -(abs(map->MapTriangles[currsec].heightFloor) - abs(map->MapTriangles[i].heightFloor)) < 10 : false))
|
||||||
|
&& Vector2DotProduct({ -(map->MapTriangles[i].a.y - map->MapTriangles[i].c.y), (map->MapTriangles[i].a.x - map->MapTriangles[i].c.x) }, normalizedVelocity) > 0) {
|
||||||
|
int highestFloor = map->MapTriangles[i].heightFloor < map->MapTriangles[currsec].heightFloor ? map->MapTriangles[currsec].heightFloor : map->MapTriangles[i].heightFloor;
|
||||||
|
if (futurePos.y - 5 >= highestFloor * renderScale && map->MapTriangles[i].wallAB == "pms:none") {}
|
||||||
|
else if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, obesity, Vector2Multiply(map->MapTriangles[i].c, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].a, { renderScale,renderScale }))) {
|
||||||
|
|
||||||
|
// check which is highest
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Morault::Gameplay::PlayerController::UpdatePlayerController(bool focus, Morault::Maps::Map* map, float renderScale)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Vector3 futurePos = camera.position;
|
||||||
|
bool correctionNecessary = false;
|
||||||
if (focus) {
|
if (focus) {
|
||||||
rotation = Vector3RotateByAxisAngle(rotation, { 0,1,0 }, -GetMouseDelta().x * 0.05 * sensitivityMultiplier);
|
rotation = Vector3RotateByAxisAngle(rotation, { 0,1,0 }, -GetMouseDelta().x * 0.05 * sensitivityMultiplier);
|
||||||
rotation.y = Clamp(rotation.y - GetMouseDelta().y * 0.3 * sensitivityMultiplier, -15, 15);
|
rotation.y = Clamp(rotation.y - GetMouseDelta().y * 0.3 * sensitivityMultiplier, -15, 15);
|
||||||
|
|
||||||
camera.target = Vector3Add(camera.position, rotation);
|
|
||||||
if (IsKeyDown(KEY_W)) camera.position = Vector3Add(camera.position, Vector3Multiply({rotation.x, 0, rotation.z}, {GetFrameTime(), GetFrameTime(), GetFrameTime()}));
|
if (IsKeyDown(KEY_W)) futurePos = Vector3Add(futurePos, Vector3Multiply({rotation.x, 0, rotation.z}, {GetFrameTime(), GetFrameTime(), GetFrameTime()}));
|
||||||
if (IsKeyDown(KEY_S)) camera.position = Vector3Subtract(camera.position, Vector3Multiply({ rotation.x, 0, rotation.z }, { GetFrameTime(), GetFrameTime(), GetFrameTime() }));
|
if (IsKeyDown(KEY_S)) futurePos = Vector3Subtract(futurePos, Vector3Multiply({ rotation.x, 0, rotation.z }, { GetFrameTime(), GetFrameTime(), GetFrameTime() }));
|
||||||
|
|
||||||
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_A)) futurePos = Vector3Add(futurePos, 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 (IsKeyDown(KEY_D)) futurePos = Vector3Add(futurePos, Vector3Multiply(Vector3RotateByAxisAngle({ rotation.x, 0, rotation.z }, { 0,1,0 }, DEG2RAD * -90), { GetFrameTime(), GetFrameTime(), GetFrameTime() }));
|
||||||
if (IsKeyPressed(KEY_SPACE)) {
|
if (IsKeyPressed(KEY_SPACE)) {
|
||||||
gravity -= 5;
|
gravity -= 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
camera.position.y -= gravity*GetFrameTime();
|
else {
|
||||||
|
rotation = { 0,0,0 };
|
||||||
|
}
|
||||||
|
|
||||||
|
int currsec = -1;
|
||||||
|
|
||||||
|
for (int i = 0; i < map->MapTriangles.size(); i++) {
|
||||||
|
|
||||||
|
if (CheckCollisionPointTriangle({ futurePos.x / renderScale, futurePos.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;
|
||||||
|
currsec = i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(currsec != -1){
|
||||||
|
for (int i = 0; i < map->MapTriangles.size(); i++) {
|
||||||
|
// check wall collisions
|
||||||
|
if (CheckCollisionCircleLine({futurePos.x, futurePos.z}, 300.0f, Vector2Multiply(map->MapTriangles[i].a, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].b, { renderScale,renderScale })) || CheckCollisionCircleLine({ futurePos.x, futurePos.z }, 300.0f, Vector2Multiply(map->MapTriangles[i].b, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].c, { renderScale,renderScale })) || CheckCollisionCircleLine({ futurePos.x, futurePos.z }, 300.0f, Vector2Multiply(map->MapTriangles[i].c, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].a, { renderScale,renderScale }))) {
|
||||||
|
|
||||||
|
if (map->MapTriangles[i].wallAB != "pms:none" || (map->MapTriangles[currsec].heightFloor < map->MapTriangles[i].heightFloor ? abs(abs(map->MapTriangles[currsec].heightFloor) - abs(map->MapTriangles[i].heightFloor)) > 10 : false)) {
|
||||||
|
if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, obesity, Vector2Multiply(map->MapTriangles[i].a, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].b, { renderScale,renderScale }))) {
|
||||||
|
// futurePos = camera.position;
|
||||||
|
correctionNecessary = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (map->MapTriangles[i].wallBC != "pms:none" || (map->MapTriangles[currsec].heightFloor < map->MapTriangles[i].heightFloor ? abs(abs(map->MapTriangles[currsec].heightFloor) - abs(map->MapTriangles[i].heightFloor)) > 10 : false)) {
|
||||||
|
if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, obesity, Vector2Multiply(map->MapTriangles[i].b, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].c, { renderScale,renderScale }))) {
|
||||||
|
|
||||||
|
correctionNecessary = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (map->MapTriangles[i].wallCA != "pms:none" || (map->MapTriangles[currsec].heightFloor < map->MapTriangles[i].heightFloor ? abs(abs(map->MapTriangles[currsec].heightFloor) - abs(map->MapTriangles[i].heightFloor)) > 10 : false)) {
|
||||||
|
if (CheckCollisionCircleLine({ futurePos.x, futurePos.z }, obesity, Vector2Multiply(map->MapTriangles[i].c, { renderScale,renderScale }), Vector2Multiply(map->MapTriangles[i].a, { renderScale,renderScale }))) {
|
||||||
|
|
||||||
|
correctionNecessary = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (correctionNecessary) {
|
||||||
|
if (!qColl(obesity, futurePos, map, renderScale, Vector3Subtract(futurePos, camera.position))) futurePos = futurePos;
|
||||||
|
|
||||||
|
// else if (!qColl(obesity, Vector3Add(futurePos, Vector3Multiply(Vector3Subtract(camera.target, camera.position), {0.5, 0.5, 0.5})), map, renderScale, Vector3Subtract(futurePos, camera.position))) futurePos = Vector3Add(futurePos, Vector3Multiply(Vector3Subtract(camera.target, camera.position), { 0.01, 0.01, 0.01 }));
|
||||||
|
else futurePos = camera.position;
|
||||||
|
}
|
||||||
|
|
||||||
|
futurePos.y -= gravity*GetFrameTime();
|
||||||
gravity += 10*GetFrameTime();
|
gravity += 10*GetFrameTime();
|
||||||
if (camera.position.y < collfloor) {
|
if (futurePos.y < collfloor) {
|
||||||
camera.position.y = collfloor;
|
futurePos.y = collfloor;
|
||||||
gravity = 0;
|
gravity = 0;
|
||||||
}
|
}
|
||||||
|
if (futurePos.y > collceiling) {
|
||||||
|
futurePos.y = collceiling;
|
||||||
|
gravity = 0;
|
||||||
|
}
|
||||||
|
camera.position = futurePos;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
camera.target = Vector3Add(camera.position, rotation);
|
||||||
}
|
}
|
||||||
|
|
||||||
Morault::Gameplay::PlayerController::~PlayerController()
|
Morault::Gameplay::PlayerController::~PlayerController()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <raylib.h>
|
#include <raylib.h>
|
||||||
|
#include "Morault_Map.h"
|
||||||
namespace Morault {
|
namespace Morault {
|
||||||
namespace Gameplay {
|
namespace Gameplay {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -27,7 +27,8 @@ namespace Morault {
|
|||||||
Vector3 rotation;
|
Vector3 rotation;
|
||||||
Camera camera;
|
Camera camera;
|
||||||
float sensitivityMultiplier = 0.5;
|
float sensitivityMultiplier = 0.5;
|
||||||
void UpdatePlayerController(bool focus);
|
float obesity = 2;
|
||||||
|
void UpdatePlayerController(bool focus, Maps::Map *map, float renderScale);
|
||||||
~PlayerController();
|
~PlayerController();
|
||||||
};
|
};
|
||||||
class Player {
|
class Player {
|
||||||
|
@ -34,16 +34,16 @@ void Morault::Rendering::DrawFloor(Vector2 a, Vector2 b, Vector2 c, int heightFl
|
|||||||
rlNormal3f(0, 1, 0);
|
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);
|
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);
|
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);
|
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);
|
rlVertex3f(c.x * renderScale, heightFloor * renderScale, c.y * renderScale);
|
||||||
|
|
||||||
rlEnd();
|
rlEnd();
|
||||||
@ -61,16 +61,16 @@ void Morault::Rendering::DrawCeiling(Vector2 a, Vector2 b, Vector2 c, int height
|
|||||||
rlNormal3f(0, 1, 0);
|
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);
|
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);
|
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);
|
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);
|
rlVertex3f(b.x * renderScale, heightCeiling * renderScale, b.y * renderScale);
|
||||||
|
|
||||||
rlEnd();
|
rlEnd();
|
||||||
|
@ -3,5 +3,5 @@
|
|||||||
#include <winuser.h>
|
#include <winuser.h>
|
||||||
bool Morault::Safety::ConfirmQuitting()
|
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
|
||||||
}
|
}
|
||||||
|
@ -137,6 +137,7 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\deps\include\pugixml.cpp" />
|
<ClCompile Include="..\deps\include\pugixml.cpp" />
|
||||||
<ClCompile Include="main.cpp" />
|
<ClCompile Include="main.cpp" />
|
||||||
|
<ClCompile Include="Morault_Canvas.cpp" />
|
||||||
<ClCompile Include="Morault_Map.cpp" />
|
<ClCompile Include="Morault_Map.cpp" />
|
||||||
<ClCompile Include="Morault_Player.cpp" />
|
<ClCompile Include="Morault_Player.cpp" />
|
||||||
<ClCompile Include="Morault_Rendering.cpp" />
|
<ClCompile Include="Morault_Rendering.cpp" />
|
||||||
@ -146,6 +147,7 @@
|
|||||||
<ClCompile Include="Morault_Utils.cpp" />
|
<ClCompile Include="Morault_Utils.cpp" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<ClInclude Include="Morault_Canvas.h" />
|
||||||
<ClInclude Include="Morault_EngineInfo.h" />
|
<ClInclude Include="Morault_EngineInfo.h" />
|
||||||
<ClInclude Include="Morault_Map.h" />
|
<ClInclude Include="Morault_Map.h" />
|
||||||
<ClInclude Include="Morault_Player.h" />
|
<ClInclude Include="Morault_Player.h" />
|
||||||
|
@ -45,6 +45,9 @@
|
|||||||
<ClCompile Include="Morault_Safety.cpp">
|
<ClCompile Include="Morault_Safety.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="Morault_Canvas.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClInclude Include="Morault_Resources.h">
|
<ClInclude Include="Morault_Resources.h">
|
||||||
@ -71,5 +74,8 @@
|
|||||||
<ClInclude Include="Morault_Safety.h">
|
<ClInclude Include="Morault_Safety.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="Morault_Canvas.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
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 |
13
ProjectMorault/data/ui/gameui.canvas
Normal file
13
ProjectMorault/data/ui/gameui.canvas
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<canvas>
|
||||||
|
|
||||||
|
<canvasinfo>
|
||||||
|
<name>Game UI Canvas</name>
|
||||||
|
<author>Safariminer</author>
|
||||||
|
</canvasinfo>
|
||||||
|
|
||||||
|
<!-- different possible anchors: bl, br, tl, tr, cn -->
|
||||||
|
<img src="data/ui/health.png" posx="0" posy="-64" anchor="bl" scale="1" />
|
||||||
|
<text posx="66" posy="-62" size="64" anchor="bl" colr="0" colg="0" colb="0" cola="255">[PLAYERHP] HP</text>
|
||||||
|
<text posx="64" posy="-64" size="64" anchor="bl" colr="255" colg="255" colb="255" cola="255">[PLAYERHP] HP</text>
|
||||||
|
|
||||||
|
</canvas>
|
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 |
@ -9,6 +9,8 @@
|
|||||||
#include "Morault_Rendering.h"
|
#include "Morault_Rendering.h"
|
||||||
#include "Morault_Safety.h"
|
#include "Morault_Safety.h"
|
||||||
|
|
||||||
|
#include "Morault_Canvas.h"
|
||||||
|
|
||||||
#define MORAULT_MAP_RENDER_SCALE 0.1f
|
#define MORAULT_MAP_RENDER_SCALE 0.1f
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
@ -33,7 +35,7 @@ int main(int argc, char** argv) {
|
|||||||
bool running = true;
|
bool running = true;
|
||||||
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
|
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
|
||||||
InitWindow(1280, 720, "ProjectMorault");
|
InitWindow(1280, 720, "ProjectMorault");
|
||||||
SetTargetFPS(60);
|
// SetTargetFPS(60);
|
||||||
SetExitKey(0);
|
SetExitKey(0);
|
||||||
|
|
||||||
|
|
||||||
@ -57,8 +59,10 @@ int main(int argc, char** argv) {
|
|||||||
Textures(load("data/textures/test.png"));
|
Textures(load("data/textures/test.png"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Morault::UI::Canvas *canvas = new Morault::UI::Canvas("data/ui/gameui.canvas");
|
||||||
|
|
||||||
Vector2 editorOffset = { 0,0 };
|
Vector2 editorOffset = { 0,0 };
|
||||||
|
|
||||||
|
|
||||||
while (running) {
|
while (running) {
|
||||||
|
|
||||||
@ -74,12 +78,12 @@ int main(int argc, char** argv) {
|
|||||||
eState = EDITOR;
|
eState = EDITOR;
|
||||||
EnableCursor();
|
EnableCursor();
|
||||||
}
|
}
|
||||||
player.controller.UpdatePlayerController(!gamePaused);
|
player.controller.UpdatePlayerController(!gamePaused, map, MORAULT_MAP_RENDER_SCALE);
|
||||||
|
|
||||||
BeginDrawing();
|
BeginDrawing();
|
||||||
ClearBackground(BLACK);
|
ClearBackground(BLACK);
|
||||||
BeginMode3D(player.controller.camera);
|
BeginMode3D(player.controller.camera);
|
||||||
DrawGrid(100, 10);
|
// DrawGrid(100, 10);
|
||||||
|
|
||||||
for (int i = 0; i < map->MapTriangles.size(); i++) {
|
for (int i = 0; i < map->MapTriangles.size(); i++) {
|
||||||
if (map->MapTriangles[i].floorTexture != "pms:none") {
|
if (map->MapTriangles[i].floorTexture != "pms:none") {
|
||||||
@ -125,7 +129,11 @@ int main(int argc, char** argv) {
|
|||||||
|
|
||||||
|
|
||||||
EndMode3D();
|
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);
|
||||||
|
canvas->DrawCanvas(player);
|
||||||
DrawFPS(0, 0);
|
DrawFPS(0, 0);
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
} break;
|
} break;
|
||||||
@ -158,9 +166,9 @@ int main(int argc, char** argv) {
|
|||||||
if (IsKeyPressed(KEY_N)) {
|
if (IsKeyPressed(KEY_N)) {
|
||||||
|
|
||||||
Morault::Maps::MapTriangle tri;
|
Morault::Maps::MapTriangle tri;
|
||||||
tri.a = { -128 + editorOffset.x, -128 + editorOffset.y };
|
tri.a = { -128 - editorOffset.x, -128 - editorOffset.y };
|
||||||
tri.b = { 128 + editorOffset.x, 128 + editorOffset.y };
|
tri.b = { 128 - editorOffset.x, 128 - editorOffset.y };
|
||||||
tri.c = { 128 + editorOffset.x,-128 + editorOffset.y };
|
tri.c = { 128 - editorOffset.x,-128 - editorOffset.y };
|
||||||
tri.floorTexture = "data/textures/test.png";
|
tri.floorTexture = "data/textures/test.png";
|
||||||
tri.heightFloor = 0;
|
tri.heightFloor = 0;
|
||||||
tri.heightCeiling = 128;
|
tri.heightCeiling = 128;
|
||||||
@ -173,9 +181,9 @@ int main(int argc, char** argv) {
|
|||||||
if (IsKeyDown(KEY_LEFT_CONTROL)) {
|
if (IsKeyDown(KEY_LEFT_CONTROL)) {
|
||||||
map->MapTriangles[map->MapTriangles.size() - 1].wallAB = "pms:none";
|
map->MapTriangles[map->MapTriangles.size() - 1].wallAB = "pms:none";
|
||||||
|
|
||||||
tri.a = { -128 + editorOffset.x, -128 + editorOffset.y };
|
tri.a = { -128 - editorOffset.x, -128 - editorOffset.y };
|
||||||
tri.b = { -128 + editorOffset.x, 128 + editorOffset.y };
|
tri.b = { -128 - editorOffset.x, 128 - editorOffset.y };
|
||||||
tri.c = { 128 + editorOffset.x, 128 + editorOffset.y };
|
tri.c = { 128 - editorOffset.x, 128 - editorOffset.y };
|
||||||
tri.floorTexture = "data/textures/test.png";
|
tri.floorTexture = "data/textures/test.png";
|
||||||
tri.heightFloor = 0;
|
tri.heightFloor = 0;
|
||||||
tri.heightCeiling = 128;
|
tri.heightCeiling = 128;
|
||||||
@ -237,6 +245,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
|
if (IsKeyDown(KEY_LEFT_CONTROL) && IsKeyPressed(KEY_O)) { // open
|
||||||
std::cout << "What to open? (empty = cancel) >>> ";
|
std::cout << "What to open? (empty = cancel) >>> ";
|
||||||
|
@ -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.
|
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
|
### 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.
|
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