Cleaning up game environments and code

This commit is contained in:
Safariminer 2025-09-04 21:49:33 -04:00
parent 5f57f10210
commit c6267745f4
28 changed files with 68 additions and 171 deletions

View File

@ -1,7 +0,0 @@
echo "GMTK 2025"
echo "Made with MPFW"
echo ""
show_cursor
disable_game
ui_show
ui_create_window "data/menus/mainmenu.wnd"

View File

@ -1,91 +0,0 @@
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.

View File

@ -1,22 +0,0 @@
<window>
<title>GMTK 2025</title>
<menubar>
<menu>
<title>File</title>
<item>
<title>New game</title>
<command mode="0">echo "this should be a new game"</command>
</item>
<item>
<title>Quit</title>
<command mode="0">quit</command>
</item>
</menu>
</menubar>
</window>

Binary file not shown.

View File

@ -1,3 +0,0 @@
vid_3d_renderer true
vid_3d_grid false
vid_2d_background false

View File

@ -1,8 +0,0 @@
[Window][Debug##Default]
Pos=60,60
Size=400,400
[Window][GMTK 2025]
Pos=57,64
Size=262,178

33
mpfw/MPFW_Atlasing.cpp Normal file
View File

@ -0,0 +1,33 @@
#include "MPFW_Atlasing.h"
int MPFW::Render::LoadTextureAtlasFromImages(std::vector<Image> images)
{
int largestWidth = 0;
int atlasHeight = 0;
for (int i = 0; i < images.size(); i++) {
if (images[i].width > largestWidth) largestWidth = images[i].width;
atlasHeight += images[i].height;
}
Image atlasImage = GenImageColor(largestWidth, atlasHeight, BLANK);
int currentImageHeight = 0;
for (int i = 0; i < images.size(); i++) {
ImageDraw(&atlasImage, images[i], { 0,0,(float)images[i].width, (float)images[i].height }, { 0,(float)currentImageHeight,(float)images[i].width, (float)images[i].height }, WHITE);
currentImageHeight += images[i].height;
}
// ExportImage(atlasImage, "testatlas.png");
return 0;
}

10
mpfw/MPFW_Atlasing.h Normal file
View File

@ -0,0 +1,10 @@
#pragma once
#include <raylib.h>
#include <vector>
namespace MPFW {
namespace Render {
int LoadTextureAtlasFromImages(std::vector<Image> images);
}
}

View File

@ -210,7 +210,7 @@ MPFW::Physics::CollisionMap MPFW::Physics::GenerateCollisionMap(std::vector<Poly
// std::lock_guard<std::mutex> guard(collSetMutex);
retval.collisionSets[vCount].collisionFaces.push_back(pStructs[p]);
}
std::print("v:{},p:{}\n", vCount, p);
// std::print("v:{},p:{}\n", vCount, p);
}
vCount++;

View File

@ -7,6 +7,7 @@
#include <string>
#include <iostream>
#include <algorithm>
#include "MPFW_Atlasing.h"
#include <rlgl.h>
@ -109,8 +110,6 @@ void MPFW::Quake::Maps::MapFile::LoadBSPMap(std::string path)
// we're loading models first because that's
// what the spec does <3
ds = Debug::MODELS;
#ifdef MPFW_QUAKE_SLOW_LOADING
data.models.resize(data.header.models.size / 64);
@ -160,8 +159,6 @@ void MPFW::Quake::Maps::MapFile::LoadBSPMap(std::string path)
// parsing vertices
ds = Debug::VERTICES;
#ifdef MPFW_QUAKE_SLOW_LOADING
verticesCDBG = 0;
data.vertices.resize(data.header.vertices.size / 12);
@ -182,15 +179,12 @@ void MPFW::Quake::Maps::MapFile::LoadBSPMap(std::string path)
}
#else
std::string verticesStr = Utils::Strings::IterativeStringExcerpt(buffer, data.header.vertices.offset, data.header.vertices.size);
data.vertices.resize(data.header.vertices.size / 12);
std::memcpy(data.vertices.data(), verticesStr.data(), data.header.vertices.size);
#endif
// parsing edges
ds = Debug::EDGES;
#ifdef MPFW_QUAKE_SLOW_LOADING
edgesCDBG = 0;
data.edges.resize(data.header.edges.size / 4);
@ -240,7 +234,6 @@ void MPFW::Quake::Maps::MapFile::LoadBSPMap(std::string path)
std::memcpy(data.texInfo.data(), texInfoStr.data(), data.header.texinfo.size);
#endif
ds = Debug::LEDGES;
#ifdef MPFW_QUAKE_SLOW_LOADING
for (int i = 0; i < data.header.ledges.size / 2; i++) {
int base = data.header.ledges.offset + (2 * i);
@ -261,10 +254,6 @@ void MPFW::Quake::Maps::MapFile::LoadBSPMap(std::string path)
// parsing faces
ds = Debug::FACES;
#ifdef MPFW_QUAKE_SLOW_LOADING
for (int i = 0; i < data.header.faces.size / 20; i++) {
@ -327,12 +316,12 @@ void MPFW::Quake::Maps::MapFile::LoadBSPMap(std::string path)
texOffsets.push_back(Utils::Strings::StringIndexToInteger_4b_le(buffer, data.header.miptex.offset + 4 + 4 * i));
}
for (int i = 0; i < cmh.numtex; i++) {
unsigned int base = static_cast<unsigned int>(texOffsets[i]) + (unsigned)data.header.miptex.offset;
// this shit is ¤ undocumented! ¤
// fuck the unofficial quake specs
// this stuff is ¤ undocumented! ¤
// screw the unofficial quake specs
if (texOffsets[i] == -1) {
// is a texoffset of 0xFFFFFFFF a reference to the fact that
// it starts right after the mipheader? probably not, but it
@ -534,16 +523,6 @@ void MPFW::Quake::Maps::MapFile::LoadBSPMap(std::string path)
Physics::CollisionMapGenParams cmgp;
*collMap = Physics::GenerateCollisionMap(collPolygons, totalRlVec, cmgp, std::format("{}", std::hash<std::string>{}(path)));
ds = Debug::DONE;
}
Vector3 MPFW::Quake::Maps::qVec2RLVec(Vector3 q) {
return { q.y / 2, q.z / 2, q.x / 2 };

View File

@ -15,6 +15,7 @@
#include <mutex>
#include "MPFW_Physics.h"
#define DISTANCE_FROM_FLOOR 15
#define DISTANCE_FROM_WALL 5
@ -156,7 +157,7 @@ void ___test___(T a, T b) {
bool consoleOn = false;
// #define SOLIPSE_TEST
int main() {
@ -185,6 +186,9 @@ int main() {
std::print("\nEnd of unit testing\n\n\n");
#endif
// if not already created...
std::filesystem::create_directories("data/cache/collisiondata");
@ -236,9 +240,9 @@ int main() {
while (!WindowShouldClose()) {
if (framebuffer < 5 && !uiRenderer.showCursorOnLaunch) {
if (framebuffer < 5) {
DisableCursor();
if(!uiRenderer.showCursorOnLaunch) DisableCursor();
framebuffer++;
}
@ -262,7 +266,7 @@ int main() {
ClearBackground(BLACK);
if(IsCursorHidden() && !consoleOn){
if(framebuffer > 5){
if(framebuffer >= 5){
if (chr.cvars["math_3d_floor_collision_work"] == "true") {
float potentialNewFloor = -FLT_MAX;
for (int b = 0; b < collisionMap.collisionSets.size(); b++) {
@ -478,7 +482,7 @@ int main() {
rlVertex3f(b.x, b.y, b.z);
rlTexCoord2f(ct.x, ct.y);
rlVertex3f(c.x, c.y, c.z);
rlVertex3f(c.x, c.y, c.z); // why does RLGL fuck up triangles? is there something i'm missing?
rlVertex3f(c.x, c.y, c.z); // why does RLGL screw up triangles? is there something i'm missing?
rlEnd();
@ -488,12 +492,6 @@ int main() {
}
/*for (int i = 0; i < collisionMap.collisionSets.size(); i++) {
BoundingBox b; b.min = collisionMap.collisionSets[i].size.min;
b.max = collisionMap.collisionSets[i].size.max;
DrawBoundingBox(b, RED);
}*/
EndMode3D();
}

View File

@ -147,6 +147,7 @@
<ClCompile Include="..\deps\include\pugixml.cpp" />
<ClCompile Include="..\deps\include\rlImGui.cpp" />
<ClCompile Include="main.cpp" />
<ClCompile Include="MPFW_Atlasing.cpp" />
<ClCompile Include="MPFW_Backend_raylib.cpp" />
<ClCompile Include="MPFW_Console.cpp" />
<ClCompile Include="MPFW_HL.cpp" />
@ -157,6 +158,7 @@
<ClCompile Include="MPFW_Utils.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="MPFW_Atlasing.h" />
<ClInclude Include="MPFW_BackendDefinition.h" />
<ClInclude Include="MPFW_Backend_raylib.h" />
<ClInclude Include="MPFW_Console.h" />

View File

@ -69,6 +69,9 @@
<ClCompile Include="MPFW_Physics.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MPFW_Atlasing.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="MPFW_HL.h">
@ -101,5 +104,8 @@
<ClInclude Include="MPFW_Physics.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MPFW_Atlasing.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
</Project>

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerWorkingDirectory>$(SolutionDir)/techdemo</LocalDebuggerWorkingDirectory>
<LocalDebuggerWorkingDirectory>$(SolutionDir)/gameenv</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerWorkingDirectory>$(SolutionDir)/techdemo</LocalDebuggerWorkingDirectory>
<LocalDebuggerWorkingDirectory>$(SolutionDir)/gameenv</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
</PropertyGroup>
</Project>