Skip to content

Commit

Permalink
cmake & vcpkg
Browse files Browse the repository at this point in the history
  • Loading branch information
333fps committed Aug 10, 2024
1 parent 037aba4 commit f6c910c
Show file tree
Hide file tree
Showing 69 changed files with 1,107 additions and 562 deletions.
41 changes: 41 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
#AllowShortBlocksOnASingleLine: true
AllowShortFunctionsOnASingleLine: All
BasedOnStyle: Microsoft
BraceWrapping:
AfterClass: true
AfterControlStatement: true
AfterEnum: true
AfterNamespace: true
AfterStruct: true
AfterUnion: true
AfterCaseLabel : true
BeforeCatch: true
BeforeElse: true
IndentBraces: false
SplitEmptyFunction: true
SplitEmptyRecord: true
BreakBeforeBraces: Custom
ColumnLimit: 0
Cpp11BracedListStyle: false
FixNamespaceComments: false
IndentCaseLabels: true

IndentPPDirectives: AfterHash

IndentWidth: 4
MaxEmptyLinesToKeep: 10
NamespaceIndentation: All
PointerAlignment: Left
SortIncludes: false
SortUsingDeclarations: false
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
TabWidth: 4
UseTab: true
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
root = true

[*]
charset = utf-8
end_of_line = crlf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
indent_size = 4
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.vs/
.vscode/

out/
build/
_build/
76 changes: 44 additions & 32 deletions Android.cpp
Original file line number Diff line number Diff line change
@@ -1,88 +1,96 @@
#include "Android.h"

#include <SFML/Graphics.hpp>
#include <vector>
#include <string>
#include <iostream>
Android::Android(GameDataRef p_data, const sf::Vector2f& p_startPosition, std::vector<std::string>& p_path,
std::unique_ptr<std::vector<std::string>>& p_level, const sf::Vector2f* p_humanPostion, float p_dtOffset)
: Sprite(p_data, p_startPosition, p_path, p_level, p_humanPostion, p_dtOffset),
m_target(*p_humanPostion)
{
m_dtMax = 0.12f + p_dtOffset;
}

Android::~Android()
{
}

void Android::NextMotion()
{
//DOWN
// DOWN
if (m_target.y > m_presentPosition.y)
{
//DOWN LEFT
// DOWN LEFT
if (m_target.x > m_presentPosition.x)
{
if (m_path[((int)m_presentPosition.y + 8) / 8][(int)m_presentPosition.x / 16] != 'w')
if (m_path[((size_t)m_presentPosition.y + 8) / 8][(size_t)m_presentPosition.x / 16] != 'w')
{
m_nextPosition.x = m_presentPosition.x + 16.0f;
}
if (m_path[((int)m_presentPosition.y + 8) / 8][(int)m_presentPosition.x / 16] == 'w')
if (m_path[((size_t)m_presentPosition.y + 8) / 8][(size_t)m_presentPosition.x / 16] == 'w')
{
m_nextPosition.y = m_presentPosition.y + 8.0f;
}
}
//DOWN RIGHT
// DOWN RIGHT
if (m_target.x < m_presentPosition.x)
{
if (m_path[((int)m_presentPosition.y + 8) / 8][(int)m_presentPosition.x / 16] != 'w')
if (m_path[((size_t)m_presentPosition.y + 8) / 8][(size_t)m_presentPosition.x / 16] != 'w')
{
m_nextPosition.x = m_presentPosition.x - 16.0f;
}
if (m_path[((int)m_presentPosition.y + 8) / 8][(int)m_presentPosition.x / 16] == 'w')
if (m_path[((size_t)m_presentPosition.y + 8) / 8][(size_t)m_presentPosition.x / 16] == 'w')
{
m_nextPosition.y = m_presentPosition.y + 8.0f;
}
}
}
//UP

// UP
if (m_target.y < m_presentPosition.y)
{
//UP RIGHT
// UP RIGHT
if (m_target.x > m_presentPosition.x)
{
if (m_path[((int)m_presentPosition.y - 8) / 8][(int)m_presentPosition.x / 16] != 'w')
if (m_path[((size_t)m_presentPosition.y - 8) / 8][(size_t)m_presentPosition.x / 16] != 'w')
{
m_nextPosition.x = m_presentPosition.x + 16.0f;
}
if (m_path[((int)m_presentPosition.y - 8) / 8][(int)m_presentPosition.x / 16] == 'w')
if (m_path[((size_t)m_presentPosition.y - 8) / 8][(size_t)m_presentPosition.x / 16] == 'w')
{
m_nextPosition.y = m_presentPosition.y - 8.0f;
}
}
//UP LEFT
// UP LEFT
if (m_target.x < m_presentPosition.x)
{
if (m_path[((int)m_presentPosition.y - 8) / 8][(int)m_presentPosition.x / 16] != 'w')
if (m_path[((size_t)m_presentPosition.y - 8) / 8][(size_t)m_presentPosition.x / 16] != 'w')
{
m_nextPosition.x = m_presentPosition.x - 16.0f;
}
if (m_path[((int)m_presentPosition.y - 8) / 8][(int)m_presentPosition.x / 16] == 'w')
if (m_path[((size_t)m_presentPosition.y - 8) / 8][(size_t)m_presentPosition.x / 16] == 'w')
{
m_nextPosition.y = m_presentPosition.y - 8.0f;
}
}
}

//LEFT
// LEFT
if (m_target.x <= m_presentPosition.x && m_target.y == m_presentPosition.y)
{
m_nextPosition.x = m_presentPosition.x - 16.0f;
}

//RIGHT
// RIGHT
if (m_target.x >= m_presentPosition.x && m_target.y == m_presentPosition.y)
{
m_nextPosition.x = m_presentPosition.x + 16.0f;
}

//up
// up
if (m_target.x == m_presentPosition.x && m_target.y <= m_presentPosition.y)
{
m_nextPosition.y = m_presentPosition.y - 8.0f;
}

//down
// down
if (m_target.x == m_presentPosition.x && m_target.y >= m_presentPosition.y)
{
m_nextPosition.y = m_presentPosition.y + 8.0f;
Expand All @@ -109,20 +117,20 @@ void Android::Update(float p_deltaTime)
m_presentPosition = m_spriteShape.getPosition();

// In hole
if (m_level[((int)m_presentPosition.y) / 16][((int)m_presentPosition.x) / 16] == 'x')
if (m_level[((size_t)m_presentPosition.y) / 16][((size_t)m_presentPosition.x) / 16] == 'x')
{
if (m_level[((int)m_presentPosition.y) / 16][((int)m_presentPosition.x + 16) / 16] == '@' && m_level[((int)m_presentPosition.y) / 16][((int)m_presentPosition.x - 16) / 16] == '@')
if (m_level[((size_t)m_presentPosition.y) / 16][((size_t)m_presentPosition.x + 16) / 16] == '@' && m_level[((size_t)m_presentPosition.y) / 16][((size_t)m_presentPosition.x - 16) / 16] == '@')
{
if (m_presentPosition.y < 328)
{
if (m_level[((int)m_presentPosition.y + 16) / 16][((int)m_presentPosition.x) / 16] != ' ')
if (m_level[((size_t)m_presentPosition.y + 16) / 16][((size_t)m_presentPosition.x) / 16] != ' ')
{
m_level[((int)m_presentPosition.y) / 16][((int)m_presentPosition.x) / 16] = 'T';
m_level[((size_t)m_presentPosition.y) / 16][((size_t)m_presentPosition.x) / 16] = 'T';
}
}
else
{
m_level[((int)m_presentPosition.y) / 16][((int)m_presentPosition.x) / 16] = 'T';
m_level[((size_t)m_presentPosition.y) / 16][((size_t)m_presentPosition.x) / 16] = 'T';
}
}
}
Expand All @@ -133,10 +141,14 @@ void Android::Update(float p_deltaTime)
{
if (!m_isFalling)
{
if (!m_isInWall) NextMotion();
if (!IsInBounds())m_nextPosition = m_presentPosition;
if (!IsOnPath())m_nextPosition = m_presentPosition;
if (m_isInWall && m_presentPosition.y > 8.0f) m_nextPosition.y = m_presentPosition.y - 8.0f;
if (!m_isInWall)
NextMotion();
if (!IsInBounds())
m_nextPosition = m_presentPosition;
if (!IsOnPath())
m_nextPosition = m_presentPosition;
if (m_isInWall && m_presentPosition.y > 8.0f)
m_nextPosition.y = m_presentPosition.y - 8.0f;
}
else
{
Expand All @@ -153,4 +165,4 @@ void Android::Update(float p_deltaTime)
m_totalTime = 0;
m_spriteShape.setPosition(m_nextPosition);
}
}
}
19 changes: 7 additions & 12 deletions Android.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,13 @@
class Android : public Sprite
{
public:
Android(GameDataRef p_data, sf::Vector2f& p_startPosition, std::vector<std::string>& p_path, std::unique_ptr<std::vector<std::string>>& p_level, const sf::Vector2f* p_humanPostion, float p_dtOffset) : //Androids
Sprite(p_data, p_startPosition, p_path, p_level, p_humanPostion, p_dtOffset),
m_target(*p_humanPostion)
{
//std::cout << "Android Created\t\t\t" << this << std::endl;

m_dtMax = 0.12f + p_dtOffset;
}
~Android()
{
//std::cout << "**Android Destroyed\t\t" << this << std::endl;
}
Android(GameDataRef p_data, const sf::Vector2f& p_startPosition, std::vector<std::string>& p_path,
std::unique_ptr<std::vector<std::string>>& p_level, const sf::Vector2f* p_humanPostion, float p_dtOffset);

Android(Android&) = delete;
Android& operator=(Android&) = delete;

virtual ~Android();

private:
const sf::Vector2f& m_target;
Expand Down
24 changes: 16 additions & 8 deletions AndroidDemo.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
#include "AndroidDemo.h"

#include <SFML/Graphics.hpp>
#include <vector>
#include <string>
#include <iostream>
AndroidDemo::AndroidDemo(GameDataRef p_data, sf::Vector2f& p_startPosition, std::vector<std::string>& p_path,
std::unique_ptr<std::vector<std::string>>& p_level)
: Sprite(p_data, p_startPosition, p_path, p_level)
{
}

AndroidDemo::~AndroidDemo()
{
}

void AndroidDemo::NextMotion()
{
Expand Down Expand Up @@ -81,9 +86,12 @@ void AndroidDemo::Update(float p_deltaTime)
if (!m_isFalling)
{
NextMotion();
if (!IsInBounds())m_nextPosition = m_presentPosition;
if (!IsOnPath())m_nextPosition = m_presentPosition;
if (m_isInWall) m_nextPosition.y = m_presentPosition.y - 8.0f;
if (!IsInBounds())
m_nextPosition = m_presentPosition;
if (!IsOnPath())
m_nextPosition = m_presentPosition;
if (m_isInWall)
m_nextPosition.y = m_presentPosition.y - 8.0f;
}
else
{
Expand All @@ -95,4 +103,4 @@ void AndroidDemo::Update(float p_deltaTime)
}

m_spriteShape.setPosition(m_nextPosition);
}
}
19 changes: 8 additions & 11 deletions AndroidDemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@
#include <SFML/Graphics.hpp>
#include <vector>
#include <string>
#include <iostream>

class AndroidDemo : public Sprite
{
public:
AndroidDemo(GameDataRef p_data, sf::Vector2f& p_startPosition, std::vector<std::string>& p_path, std::unique_ptr<std::vector<std::string>>& p_level) :
Sprite(p_data, p_startPosition, p_path, p_level)
{
//std::cout << "Android Demo Created\t\t" << this << std::endl;
}
~AndroidDemo()
{
//std::cout << "**Android Demo Destroyed\t" << this << std::endl;
}
AndroidDemo(GameDataRef p_data, sf::Vector2f& p_startPosition, std::vector<std::string>& p_path,
std::unique_ptr<std::vector<std::string>>& p_level);

AndroidDemo(AndroidDemo&) = delete;
AndroidDemo& operator=(AndroidDemo&) = delete;

virtual ~AndroidDemo();

private:
void NextMotion();
Expand All @@ -28,4 +25,4 @@ class AndroidDemo : public Sprite
void Update(float p_deltaTime);
};

#endif // !_ANDROID_DEMO_H_
#endif // !_ANDROID_DEMO_H_
21 changes: 13 additions & 8 deletions AssetManager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
#include "AssetManager.h"

AssetManager::AssetManager()
{
}

AssetManager::~AssetManager()
{
m_sounds.clear();
}

void AssetManager::LoadTexture(std::string p_textureName, std::string p_fileName)
{
sf::Texture texture;
Expand Down Expand Up @@ -33,15 +42,11 @@ sf::IntRect AssetManager::GetRect(std::string p_rectName)

void AssetManager::LoadSound(std::string p_soundName, std::string p_fileName)
{
sf::SoundBuffer buffer;

if (buffer.loadFromFile(p_fileName))
{
this->m_sounds[p_soundName] = buffer;
}
auto& buff = m_sounds[p_soundName];
buff.loadFromFile(p_fileName);
}

sf::SoundBuffer& AssetManager::GetSound(std::string p_soundName)
const sf::SoundBuffer& AssetManager::GetSound(std::string p_soundName)
{
return this->m_sounds.at(p_soundName);
}
Expand All @@ -59,4 +64,4 @@ void AssetManager::LoadFont(std::string p_fontName, std::string p_fileName)
sf::Font& AssetManager::GetFont(std::string name)
{
return this->m_fonts.at(name);
}
}
6 changes: 3 additions & 3 deletions AssetManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
class AssetManager
{
public:
AssetManager() { }
~AssetManager() { }
AssetManager();
~AssetManager();

void LoadTexture(std::string p_textureName, std::string p_fileName);
sf::Texture& GetTexture(std::string p_textureName);
Expand All @@ -19,7 +19,7 @@ class AssetManager
sf::IntRect GetRect(std::string p_rectName);

void LoadSound(std::string p_soundName, std::string p_fileName);
sf::SoundBuffer& GetSound(std::string p_soundName);
const sf::SoundBuffer& GetSound(std::string p_soundName);

void LoadFont(std::string p_fontName, std::string p_fileName);
sf::Font& GetFont(std::string p_fontName);
Expand Down
Loading

0 comments on commit f6c910c

Please sign in to comment.