Add CMake build and cross-platform cleanup

This commit is contained in:
Bram Verhulst
2026-04-12 23:15:20 +02:00
parent 81746db9ae
commit 1ba1c1f2cc
25 changed files with 350 additions and 56 deletions

83
BUILDING.md Normal file
View File

@@ -0,0 +1,83 @@
# Building Motherload
This repository now supports both the original Visual Studio solution files and a CMake-based build.
## Supported build paths
### 1. CMake on Windows
Recommended if you want a modern, editor-friendly build setup.
Requirements:
- Visual Studio 2022 with Desktop development with C++
- CMake 3.21+
The repository already contains the required prebuilt Windows SDL packages in `Libraries/`.
Configure and build:
```bash
cmake -S . -B build -G "Visual Studio 17 2022" -A x64
cmake --build build --config Debug
```
### 2. CMake on Linux
Requirements:
- C++ compiler
- CMake 3.21+
- SDL2 development packages
- OpenGL development package
Ubuntu / Debian example:
```bash
sudo apt install build-essential cmake libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libgl1-mesa-dev
cmake -S . -B build
cmake --build build
```
### 3. Legacy Visual Studio solution
The existing `.sln` and `.vcxproj` files are still in the repo and can still be opened directly in Visual Studio.
## Build output
The CMake build writes the executable to:
- `build/bin/` for single-config generators
- the active configuration output folder for Visual Studio generators
Resource files from `Resources/` are copied automatically after a successful build.
## Notes about dependencies
### Windows
CMake uses the bundled SDL package config files from:
- `Libraries/SDLMain/.../cmake`
- `Libraries/SDLImage/.../cmake`
- `Libraries/SDLMixer/.../cmake`
- `Libraries/SDLTtf/.../cmake`
### Linux
CMake falls back to `pkg-config` and expects these packages to be installed:
- `sdl2`
- `SDL2_image`
- `SDL2_mixer`
- `SDL2_ttf`
## Troubleshooting
### CMake fails at `find_package(OpenGL REQUIRED)`
Install the OpenGL development package.
Ubuntu / Debian:
```bash
sudo apt install libgl1-mesa-dev
```
### CMake cannot find SDL packages on Linux
Install the SDL development packages listed above.
### The game starts but cannot find assets
Run the executable from the build output directory, not from the source directory root. The post-build step copies `Resources/` next to the executable.
### Why are the old MSVC `#pragma comment(lib, ...)` lines still in the code?
They are still there for the legacy Visual Studio project files, but the CMake build disables them explicitly so dependency management stays inside CMake.

169
CMakeLists.txt Normal file
View File

@@ -0,0 +1,169 @@
cmake_minimum_required(VERSION 3.21)
project(Motherload LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
option(MOTHERLOAD_USE_BUNDLED_WINDOWS_SDL "Use the bundled prebuilt SDL packages on Windows" ON)
option(MOTHERLOAD_ENABLE_WARNINGS "Enable compiler warnings" ON)
if(WIN32 AND MOTHERLOAD_USE_BUNDLED_WINDOWS_SDL)
list(PREPEND CMAKE_PREFIX_PATH
"${CMAKE_SOURCE_DIR}/Libraries/SDLMain/SDL2-2.26.3/cmake"
"${CMAKE_SOURCE_DIR}/Libraries/SDLImage/SDL2_image-2.6.3/cmake"
"${CMAKE_SOURCE_DIR}/Libraries/SDLMixer/SDL2_mixer-2.6.3/cmake"
"${CMAKE_SOURCE_DIR}/Libraries/SDLTtf/SDL2_ttf-2.20.2/cmake"
)
endif()
find_package(OpenGL REQUIRED)
function(motherload_import_pkgconfig_target imported_target pkg_name pkg_prefix)
if(TARGET "${imported_target}")
return()
endif()
find_package(PkgConfig REQUIRED)
pkg_check_modules(${pkg_prefix} REQUIRED IMPORTED_TARGET "${pkg_name}")
add_library("${imported_target}" INTERFACE IMPORTED)
target_link_libraries("${imported_target}" INTERFACE "PkgConfig::${pkg_prefix}")
endfunction()
function(motherload_enable_warnings target_name)
if(NOT MOTHERLOAD_ENABLE_WARNINGS)
return()
endif()
if(MSVC)
target_compile_options(${target_name} PRIVATE /W4 /permissive-)
else()
target_compile_options(${target_name} PRIVATE -Wall -Wextra -Wpedantic)
endif()
endfunction()
find_package(SDL2 QUIET CONFIG)
find_package(SDL2_image QUIET CONFIG)
find_package(SDL2_mixer QUIET CONFIG)
find_package(SDL2_ttf QUIET CONFIG)
motherload_import_pkgconfig_target(SDL2::SDL2 sdl2 SDL2_PC)
motherload_import_pkgconfig_target(SDL2_image::SDL2_image SDL2_image SDL2_IMAGE_PC)
motherload_import_pkgconfig_target(SDL2_mixer::SDL2_mixer SDL2_mixer SDL2_MIXER_PC)
motherload_import_pkgconfig_target(SDL2_ttf::SDL2_ttf SDL2_ttf SDL2_TTF_PC)
if(NOT TARGET SDL2::SDL2main)
find_library(SDL2MAIN_LIBRARY NAMES SDL2main)
if(SDL2MAIN_LIBRARY)
add_library(SDL2::SDL2main UNKNOWN IMPORTED)
set_target_properties(SDL2::SDL2main PROPERTIES IMPORTED_LOCATION "${SDL2MAIN_LIBRARY}")
endif()
endif()
set(ENGINE_SOURCES
Engine/BaseGame.cpp
Engine/Collision.cpp
Engine/Matrix2x3.cpp
Engine/SVGParser.cpp
Engine/SoundEffect.cpp
Engine/SoundStream.cpp
Engine/Text.cpp
Engine/Texture.cpp
Engine/Vector2f.cpp
Engine/structs.cpp
Engine/utils.cpp
)
set(GAME_SOURCES
Game/Animations/Animation.cpp
Game/Camera.cpp
Game/Game.cpp
Game/GameManager.cpp
Game/GridSystem/GroundTileTypeManager.cpp
Game/GridSystem/WorldGridManager.cpp
Game/GridSystem/WorldTile.cpp
Game/Gui/GuiButton.cpp
Game/Gui/GuiElement.cpp
Game/Gui/GuiMeter.cpp
Game/Gui/GuiText.cpp
Game/Gui/Screen.cpp
Game/Gui/Screens/FuelScreen/FuelScreen.cpp
Game/Gui/Screens/GameOver/GameOverScreen.cpp
Game/Gui/Screens/MainScreen.cpp
Game/Gui/Screens/ScreenManager.cpp
Game/Gui/Screens/SellScreen/SellScreen.cpp
Game/Gui/Screens/SellScreen/SellSreenRow.cpp
Game/Inventory/PlayerInventory.cpp
Game/Levels/Level.cpp
Game/Levels/MainMenu/MainMenuLevel.cpp
Game/Levels/World/Building.cpp
Game/Levels/World/OrbitingObject.cpp
Game/Levels/World/WorldLevel.cpp
Game/Particle/Particle.cpp
Game/Player.cpp
Game/TextureManager.cpp
Game/main.cpp
Game/pch.cpp
)
add_library(Engine STATIC ${ENGINE_SOURCES})
target_include_directories(Engine
PUBLIC
"${CMAKE_SOURCE_DIR}/Engine"
)
target_compile_definitions(Engine
PUBLIC
MOTHERLOAD_DISABLE_MSVC_LINK_PRAGMAS=1
)
target_link_libraries(Engine
PUBLIC
OpenGL::GL
SDL2::SDL2
SDL2_image::SDL2_image
SDL2_mixer::SDL2_mixer
SDL2_ttf::SDL2_ttf
)
motherload_enable_warnings(Engine)
add_executable(Motherload ${GAME_SOURCES})
target_include_directories(Motherload
PRIVATE
"${CMAKE_SOURCE_DIR}/Game"
"${CMAKE_SOURCE_DIR}/Engine"
)
target_link_libraries(Motherload
PRIVATE
Engine
OpenGL::GL
SDL2::SDL2
SDL2_image::SDL2_image
SDL2_mixer::SDL2_mixer
SDL2_ttf::SDL2_ttf
)
if(TARGET SDL2::SDL2main)
target_link_libraries(Motherload PRIVATE SDL2::SDL2main)
endif()
motherload_enable_warnings(Motherload)
source_group(TREE "${CMAKE_SOURCE_DIR}" FILES ${ENGINE_SOURCES} ${GAME_SOURCES})
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT Motherload)
set_property(TARGET Motherload PROPERTY VS_DEBUGGER_WORKING_DIRECTORY "$<TARGET_FILE_DIR:Motherload>")
add_custom_command(TARGET Motherload POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
"${CMAKE_SOURCE_DIR}/Resources"
"$<TARGET_FILE_DIR:Motherload>"
)
if(WIN32)
add_custom_command(TARGET Motherload POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_RUNTIME_DLLS:Motherload>
$<TARGET_FILE_DIR:Motherload>
COMMAND_EXPAND_LISTS
)
endif()

View File

@@ -16,23 +16,23 @@ public:
void Run();
virtual void Update(float elapsedSec) {
virtual void Update(float) {
}
virtual void Draw() const {
}
// Event handling
virtual void ProcessKeyDownEvent(const SDL_KeyboardEvent& e) {
virtual void ProcessKeyDownEvent(const SDL_KeyboardEvent&) {
}
virtual void ProcessKeyUpEvent(const SDL_KeyboardEvent& e) {
virtual void ProcessKeyUpEvent(const SDL_KeyboardEvent&) {
}
virtual void ProcessMouseMotionEvent(const SDL_MouseMotionEvent& e) {
virtual void ProcessMouseMotionEvent(const SDL_MouseMotionEvent&) {
}
virtual void ProcessMouseDownEvent(const SDL_MouseButtonEvent& e) {
virtual void ProcessMouseDownEvent(const SDL_MouseButtonEvent&) {
}
virtual void ProcessMouseUpEvent(const SDL_MouseButtonEvent& e) {
virtual void ProcessMouseUpEvent(const SDL_MouseButtonEvent&) {
}
virtual void ProcessMouseWheelEvent(const SDL_MouseWheelEvent& e) {
virtual void ProcessMouseWheelEvent(const SDL_MouseWheelEvent&) {
}

View File

@@ -108,8 +108,8 @@ void Matrix2x3::SetAsIdentity()
void Matrix2x3::SetAsRotate(float degrees)
{
float radians = degrees * 3.1415926535f / 180;
dirX = Vector2f{ cos( radians ), sin( radians ) };
dirY = Vector2f{ -sin( radians ), cos( radians ) };
dirX = Vector2f{ std::cos( radians ), std::sin( radians ) };
dirY = Vector2f{ -std::sin( radians ), std::cos( radians ) };
orig = Vector2f{ 0, 0 };
}
void Matrix2x3::SetAsTranslate(float tx, float ty)
@@ -141,7 +141,7 @@ void Matrix2x3::SetAsScale(float scale)
Matrix2x3 Matrix2x3::CreateRotationMatrix(float degrees)
{
float radians = degrees * 3.1415926535f / 180;
return Matrix2x3( Vector2f{ cos( radians ), sin( radians ) }, Vector2f{ -sin(radians), cos( radians ) }, Vector2f{} );
return Matrix2x3( Vector2f{ std::cos( radians ), std::sin( radians ) }, Vector2f{ -std::sin(radians), std::cos( radians ) }, Vector2f{} );
}
Matrix2x3 Matrix2x3::CreateIdentityMatrix()
@@ -199,4 +199,3 @@ std::ostream& operator<<(std::ostream& os, const Matrix2x3& matrix )
os << matrix.ToString( );
return os;
}

View File

@@ -198,7 +198,7 @@ bool SVGParser::GetVerticesFromPathData( const std::string& pathData, std::vecto
isOpen = false;
break;
}
// Fallthrough when isOpen
[[fallthrough]];
case ( 'L' )://lineto
case ( 'l' ):
vertex = NextSvgPoint( ss, cursor, cmd, isOpen, true );

View File

@@ -20,7 +20,7 @@ bool SoundEffect::IsLoaded() const {
void SoundEffect::Play(const int loops) const {
if (m_pMixChunk != nullptr) {
const int channel { Mix_PlayChannel(m_Channel, m_pMixChunk, loops) };
Mix_PlayChannel(m_Channel, m_pMixChunk, loops);
}
else {
std::cout << "SoundEffect::Play() failed, sound effect not loaded\n";

View File

@@ -1,7 +1,7 @@
#pragma once
//ML Detection Extension
#ifdef _DEBUG
#if defined(_MSC_VER) && defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
#include <cstdlib>
#include <crtdbg.h>
@@ -9,6 +9,7 @@
#define new DEBUG_NEW
#endif
#if defined(_MSC_VER) && !defined(MOTHERLOAD_DISABLE_MSVC_LINK_PRAGMAS)
// SDL libs
#pragma comment(lib, "SDL2.lib")
#pragma comment(lib, "SDL2main.lib")
@@ -21,16 +22,21 @@
#pragma comment(lib, "SDL2_image.lib")
#pragma comment(lib, "SDL2_ttf.lib")
#pragma comment(lib, "SDL2_mixer.lib")
#endif
// SDL and OpenGL Includes
#if defined(_MSC_VER)
#pragma warning(disable : 26812)
#pragma warning(disable : 4820)
#endif
#include <SDL.h>
#include <SDL_opengl.h>
#include <SDL_ttf.h>
#include <SDL_mixer.h>
#include <SDL_image.h>
#if defined(_MSC_VER)
#pragma warning(default : 26812)
#pragma warning(default : 4820)
#endif
#include "structs.h"

View File

@@ -233,15 +233,15 @@ void utils::FillPolygon(const std::vector<Vector2f>& vertices) {
void utils::DrawArrow(const Vector2f& start, const Vector2f& end, float lineWidth, float arrowSize) {
// Origin is bottom left
utils::DrawLine(start, end);
utils::DrawLine(start, end, lineWidth);
const float arrowAngle = atan2f(end.y - start.y, end.x - start.x);
const float arrowAngle1 = arrowAngle + g_Pi + 0.4f;
const float arrowAngle2 = arrowAngle + g_Pi - 0.4f;
const Vector2f arrow1 { end.x + arrowSize * cosf(arrowAngle1), end.y + arrowSize * sinf(arrowAngle1) };
const Vector2f arrow2 { end.x + arrowSize * cosf(arrowAngle2), end.y + arrowSize * sinf(arrowAngle2) };
utils::DrawLine(end, arrow1);
utils::DrawLine(end, arrow2);
utils::DrawLine(end, arrow1, lineWidth);
utils::DrawLine(end, arrow2, lineWidth);
}
void utils::FillPolygon(const Vector2f* pVertices, size_t nrVertices) {
@@ -610,11 +610,14 @@ bool utils::IsRectInRect(const Rectf& r1, const Rectf& r2) {
bool utils::RayVsRect(const Vector2f& rayOrigin, const Vector2f& rayDir, const Rectf& target,
Vector2f& contactPoint, Vector2f& contactNormal, float& t_hit_near) {
// Vector2f t_near = Vector2f{(target.BottomLeft() - rayOrigin).x / rayDir.x, (target.BottomLeft() - rayOrigin).y / rayDir.y};
// Vector2f t_far = Vector2f{(target.BottomLeft() + Vector2f{target.width, target.height} - rayOrigin).x / rayDir.x, (target.BottomLeft() + Vector2f{target.width, target.height} - rayOrigin).y / rayDir.y};
Vector2f t_near {};
Vector2f t_far {};
Vector2f t_near {
(target.left - rayOrigin.x) / rayDir.x,
(target.bottom - rayOrigin.y) / rayDir.y
};
Vector2f t_far {
(target.left + target.width - rayOrigin.x) / rayDir.x,
(target.bottom + target.height - rayOrigin.y) / rayDir.y
};
if (std::isnan(t_far.y) || std::isnan(t_far.x))
return false;
@@ -757,4 +760,3 @@ bool utils::isMouseDown(int button) {
}
//utils::getScrollMovement()

View File

@@ -5,7 +5,7 @@
#include "utils.h"
Animation::Animation(Texture* pTexture, int frames, float frameDuration, Rectf srcRect, bool isLooping): m_pTexture(pTexture), m_SrcRect(srcRect), m_Frames(frames),
m_IsLooping(isLooping), m_FrameDuration(frameDuration) {
m_FrameDuration(frameDuration), m_IsLooping(isLooping) {
}
void Animation::Update(float elapsedSec) {
@@ -28,7 +28,7 @@ void Animation::Draw(const Vector2f& pos) const {
Draw(pos, Rectf { pos.x, pos.y, m_SrcRect.width, m_SrcRect.height });
}
void Animation::Draw(const Vector2f& pos, const Rectf& dst) const {
void Animation::Draw(const Vector2f&, const Rectf& dst) const {
Rectf src = m_SrcRect;
src.left += static_cast<float>(m_CurrentFrame) * src.width;

View File

@@ -36,8 +36,6 @@ void Game::Cleanup() {
}
void Game::Update(float elapsedSec) {
const Uint8* pStates = SDL_GetKeyboardState(nullptr);
if (m_IsRightMouseDown) {
const Vector2f newCameraPos = Vector2f { m_MousePosition.x + m_MouseOffset.x, m_MousePosition.y + m_MouseOffset.y };
m_Camera.SetPosition(Vector2f { -newCameraPos.x, -newCameraPos.y });
@@ -62,7 +60,7 @@ void Game::ProcessKeyDownEvent(const SDL_KeyboardEvent& e) {
}
}
void Game::ProcessKeyUpEvent(const SDL_KeyboardEvent& e) {
void Game::ProcessKeyUpEvent(const SDL_KeyboardEvent&) {
}
void Game::ProcessMouseMotionEvent(const SDL_MouseMotionEvent& e) {

View File

@@ -69,7 +69,7 @@ int GameManager::GetMoney() const {
void GameManager::IncreaseMoney(int money) {
m_Money += money;
}
void GameManager::Update(float elapsedSecs) {
void GameManager::Update(float) {
m_pMainScreen->SetFuelMeterValue(this->GetMaxFuel() - m_Fuel);
m_pMainScreen->SetHullMeterValue((float)m_HullIntegrity);
m_pMainScreen->SetScore(std::to_string(m_Score));
@@ -104,4 +104,3 @@ GameManager::GameManager() {

View File

@@ -35,7 +35,6 @@ GroundTileType * getRandomGroundTile() {
return GroundTileTypeManager::GetInstance()->AIR; // Default value
}
void InitializeGroundTiles() {
Tiles tiles {};
GroundTileTypeManager::GetInstance()->AIR = new GroundTileType("", GroundTileTypes::Air, 0);
GroundTileTypeManager::GetInstance()->DIRT = new RandomGroundTile("tiles/dirt/dirt[0].png", GroundTileTypes::Dirt, 5, 250);

View File

@@ -96,7 +96,6 @@ public:
}
std::string GetPath() const override {
int variant = utils::randRange(1, m_maxRandom);
std::string toReplace { "[0]" };
std::string replacement = std::to_string(utils::randRange(1, m_maxRandom));

View File

@@ -20,7 +20,7 @@ void GuiButton::Draw() const {
}
}
void GuiButton::Update(float elapsedSec) {
void GuiButton::Update(float) {
Vector2f mousePos = utils::GetMousePos();
Rectf buttonRect = Rectf(m_Position, m_Size);

View File

@@ -19,7 +19,7 @@ void GuiMeter::Draw() const {
m_Animation->Draw(m_Position, Rectf{m_Position, m_DrawSize});
// utils::DrawRect(Rectf { m_Position, m_DrawSize});
}
void GuiMeter::Update(float elapsedSec) {
void GuiMeter::Update(float) {
const int frame = static_cast<int>(utils::map(m_Value, 0.0f, m_MaxValue, 0, (float)m_Animation->GetFrameCount()));
m_Animation->SetFrame(frame);
}

View File

@@ -16,7 +16,7 @@ void GuiText::Draw() const {
m_Text->Draw(m_Position);
}
void GuiText::Update(float elapsedSec) {
void GuiText::Update(float) {
}
void GuiText::ChangeText(const std::string& text) const {

View File

@@ -29,7 +29,7 @@ void SellSreenRow::Draw() const {
// utils::SetColor(Colors::GREEN);
// utils::DrawRect(Rectf { m_Pos, m_Size });
}
void SellSreenRow::Update(float elapsedSecs) {
void SellSreenRow::Update(float) {
// m_NameText->ChangeText("EXAMPLE");
// m_CalculationText->ChangeText(std::to_string(m_Item.m_Quantity));
GenerateCalcString();

View File

@@ -13,7 +13,7 @@ MainMenuLevel::~MainMenuLevel() {
delete m_TextNewGame;
delete m_TextExit;
}
void MainMenuLevel::Update(float elapsedSec) {
void MainMenuLevel::Update(float) {
}
void MainMenuLevel::Draw() const {
m_TextMotherload->Draw(Vector2f(200, 100));
@@ -21,5 +21,5 @@ void MainMenuLevel::Draw() const {
m_TextExit->Draw(Vector2f(200, 300));
}
void MainMenuLevel::MouseMove(const Vector2f& mousePos) {
void MainMenuLevel::MouseMove(const Vector2f&) {
}

View File

@@ -22,7 +22,7 @@ void Building::Draw() const {
// temp.bottom += m_Position.y;
// utils::DrawRect(temp);
}
void Building::Update(float dt, const Rectf& objectBoundingBox) {
void Building::Update(float, const Rectf& objectBoundingBox) {
if (IsObjectInHitbox(objectBoundingBox)) {
Player* player = GameManager::GetInstance().GetPlayer();
float speed = player->GetVelocity().Length();

View File

@@ -1,8 +1,9 @@
#include "pch.h"
#include "OrbitingObject.h"
#include <cmath>
#include <iostream>
OrbitingObject::OrbitingObject(const Vector2f& orbit, float distance, float speed, Texture* texture, float offset): m_Texture(texture), m_Orbit(orbit), m_Speed(speed), m_Distance(distance), m_currentCycle(offset) {
OrbitingObject::OrbitingObject(const Vector2f& orbit, float distance, float speed, Texture* texture, float offset): m_Texture(texture), m_Orbit(orbit), m_Distance(distance), m_Speed(speed), m_currentCycle(offset) {
}
void OrbitingObject::Update(float elapsedSecs) {
m_Position = Vector2f(m_Orbit.x + cosf(m_currentCycle) * m_Distance, m_Orbit.y + sinf(m_currentCycle) * m_Distance);

View File

@@ -1,6 +1,6 @@
#include "pch.h"
#include "Particle.h"
Particle::Particle(const Vector2f& pos, const Vector2f& velocity,const Vector2f& gravity, float lifetime, Texture* pTexture): m_Position { pos }, m_Velocity { velocity }, m_LifeTime { lifetime }, m_Gravity(gravity),
Particle::Particle(const Vector2f& pos, const Vector2f& velocity,const Vector2f& gravity, float lifetime, Texture* pTexture): m_Position { pos }, m_Velocity { velocity }, m_Gravity(gravity), m_LifeTime { lifetime },
m_pTexture { pTexture } {
}
void Particle::Update(float elapsedSec) {

View File

@@ -136,7 +136,7 @@ void Player::Die() {
m_CurrentAnimation = m_DieStartAnimation;
m_HasPlayedDeathAnimation = false;
}
void Player::Dig(Collision::CollisionDirection dir, WorldLevel& level) {
void Player::Dig(Collision::CollisionDirection dir, WorldLevel&) {
m_State = PlayerState::Digging;
m_DigProgress = 0;
m_DigTile = m_ContactMap[dir];
@@ -157,7 +157,7 @@ void Player::Dig(Collision::CollisionDirection dir, WorldLevel& level) {
m_ContactMap[dir] = nullptr;
}
bool Player::CanDig(Collision::CollisionDirection dir, WorldLevel& level) {
bool Player::CanDig(Collision::CollisionDirection dir, WorldLevel&) {
WorldTile* tile = m_ContactMap[dir];
if (tile == nullptr) {
return false;
@@ -371,7 +371,7 @@ void Player::Update(float elapsedTime, WorldLevel& level) {
m_ContactMap[Collision::CollisionDirection::Right] = nullptr;
m_Grounded = false;
float t = 0, min_t = INFINITY;
float t = 0;
Vector2f intersectionPoint, normal;
std::vector<std::pair<int, float>> contactTimes {};

View File

@@ -7,7 +7,7 @@ void DumpMemoryLeaks();
Vector2f Viewport { 900.f, 500.f };
int SDL_main(int argv, char** args) {
int SDL_main(int, char**) {
srand(static_cast<unsigned int>(time(nullptr)));
StartHeapControl();
@@ -21,7 +21,7 @@ int SDL_main(int argv, char** args) {
void StartHeapControl() {
#if defined(DEBUG) | defined(_DEBUG)
#if defined(_MSC_VER) && defined(_DEBUG)
// Notify user if heap is corrupt
HeapSetInformation(NULL, HeapEnableTerminationOnCorruption, NULL, 0);
@@ -34,7 +34,7 @@ void StartHeapControl() {
}
void DumpMemoryLeaks() {
#if defined(DEBUG) | defined(_DEBUG)
#if defined(_MSC_VER) && defined(_DEBUG)
_CrtDumpMemoryLeaks();
#endif
}

View File

@@ -1,6 +1,6 @@
#pragma once
//ML Detection Extension
#ifdef _DEBUG
#if defined(_MSC_VER) && defined(_DEBUG)
#define _CRTDBG_MAP_ALLOC
#include <cstdlib>
#include <crtdbg.h>
@@ -8,13 +8,18 @@
#define new DEBUG_NEW
#endif
// SDL and OpenGL Includes
#if defined(_MSC_VER)
#pragma warning(disable : 26812)
#pragma warning(disable : 4820)
#endif
#include <SDL.h>
#include <SDL_opengl.h>
#include <SDL_ttf.h>
#include <SDL_mixer.h>
#include <SDL_image.h>
#if defined(_MSC_VER)
#pragma warning(default : 26812)
#pragma warning(default : 4820)
#endif
#include "structs.h"

View File

@@ -79,18 +79,52 @@ This section gives a clear and detailed overview of which parts of the original
<!-- GETTING STARTED -->
## Getting Started
Detailed instructions on how to run your game project are in this section.
This project now includes a CMake build in addition to the original Visual Studio solution files.
For the longer version, troubleshooting, and platform notes, see [`BUILDING.md`](BUILDING.md).
### Prerequisites
This is an example of how to list things you need to use the software and how to install them.
* Visual Studio 2022 Or Jetbrains Rider
#### Windows
* Visual Studio 2022 with the Desktop development with C++ workload
* CMake 3.21 or newer
### How to run the project
The repository already contains prebuilt SDL2 / SDL2_image / SDL2_mixer / SDL2_ttf Windows packages in `Libraries/`, and the CMake build will use those by default.
1. Download the Repo.
2. Open the project in Visual Studio 2022 or Jetbrains Rider.
3. Run the project.
#### Linux
Install the development packages first.
Ubuntu / Debian example:
```bash
sudo apt install build-essential cmake libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libgl1-mesa-dev
```
### Build with CMake
#### Windows, Visual Studio 2022
```bash
cmake -S . -B build -G "Visual Studio 17 2022" -A x64
cmake --build build --config Debug
```
The executable will be generated in `build/bin/` or the selected Visual Studio configuration output folder. Resource files are copied automatically after the build.
#### Linux
```bash
cmake -S . -B build
cmake --build build
```
The executable will be generated in `build/bin/`. Resource files are copied automatically after the build.
### Run the game
After building, run the generated executable from the build output directory so that the copied resource files are next to it.
### Notes
* The original `.sln` and `.vcxproj` files are still present and can still be used in Visual Studio.
* The CMake build creates the same two logical targets as the solution: `Engine` and `Motherload`.
* On non-Windows platforms, SDL dependencies are expected to come from the system package manager.
<p align="right">(<a href="#readme-top">back to top</a>)</p>