Add CMake build and cross-platform cleanup
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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&) {
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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 {};
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user