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