Skip to content

Commit 98c3628

Browse files
committed
make sample more sane
1 parent 54e473d commit 98c3628

File tree

5 files changed

+17
-105
lines changed

5 files changed

+17
-105
lines changed

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ set(SRC_FILES
4444
${SRC_DIR}/Util/GameObject.cpp
4545

4646
${SRC_DIR}/App.cpp
47-
${SRC_DIR}/Triangle.cpp
4847
${SRC_DIR}/Giraffe.cpp
4948
)
5049
set(INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
@@ -75,7 +74,6 @@ set(INCLUDE_FILES
7574
${INCLUDE_DIR}Util/GameObject.hpp
7675

7776
${INCLUDE_DIR}/App.hpp
78-
${INCLUDE_DIR}/Triangle.hpp
7977
${INCLUDE_DIR}/Giraffe.hpp
8078
${INCLUDE_DIR}/config.hpp
8179
)

include/App.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "pch.hpp" // IWYU pragma: export
55

66
#include "Giraffe.hpp"
7-
#include "Triangle.hpp"
87

98
class App {
109
public:
@@ -23,8 +22,7 @@ class App {
2322
private:
2423
State m_CurrentState = State::START;
2524

26-
Triangle m_Triangle;
27-
std::shared_ptr<Giraffe> m_Giraffe= std::make_shared<Giraffe>();
25+
std::shared_ptr<Giraffe> m_Giraffe = std::make_shared<Giraffe>();
2826
};
2927

3028
#endif

include/Triangle.hpp

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/Giraffe.cpp

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,27 @@
11
#include "Giraffe.hpp"
2+
3+
#include <cmath>
4+
25
#include "Util/GameObject.hpp"
36
#include "Util/Image.hpp"
7+
#include "Util/Logger.hpp"
48
#include "Util/Text.hpp"
59
#include "Util/Time.hpp"
610
#include "Util/Transform.hpp"
11+
712
#include "config.hpp"
813

914
void GiraffeText::Update(const Util::Transform &transform) {
1015
auto &pos = m_Transform.translation;
1116
auto &scale = m_Transform.scale;
1217
auto &rotation = m_Transform.rotation;
1318

14-
pos += transform.translation;
15-
rotation += transform.rotation;
19+
pos = transform.translation;
20+
// rotation = std::fmod(rotation + 50.0F, 360.0F);
1621
scale = transform.scale;
1722

23+
LOG_DEBUG("{} {}", scale.x, scale.y);
24+
1825
m_Drawable->Draw(m_Transform, m_ZIndex);
1926
}
2027

@@ -31,10 +38,12 @@ void Giraffe::Update(const Util::Transform &transform) {
3138
auto &scale = m_Transform.scale;
3239
auto &rotation = m_Transform.rotation;
3340

34-
if (pos.y > WINDOW_HEIGHT || pos.y + WINDOW_HEIGHT < 0) {
41+
if (pos.y >= static_cast<float>(WINDOW_HEIGHT) / 2 ||
42+
pos.y + static_cast<float>(WINDOW_HEIGHT) / 2 <= 0) {
3543
dir.y *= -1;
3644
}
37-
if (pos.x > WINDOW_WIDTH || pos.x + WINDOW_WIDTH < 0) {
45+
if (pos.x >= static_cast<float>(WINDOW_WIDTH) / 2 ||
46+
pos.x + static_cast<float>(WINDOW_WIDTH) / 2 <= 0) {
3847
dir.x *= -1;
3948
}
4049

@@ -44,13 +53,12 @@ void Giraffe::Update(const Util::Transform &transform) {
4453
glm::vec2(1, 1) * (std::sin(rotation / 2) + 1.0F) * 100.0F};
4554

4655
pos += deltaTransform.translation;
47-
rotation += deltaTransform.rotation;
48-
scale = deltaTransform.scale;
49-
56+
rotation = std::fmod(rotation + deltaTransform.rotation, 360.0F);
57+
// scale = deltaTransform.scale;
5058

5159
m_Drawable->Draw(m_Transform, m_ZIndex);
5260
for (auto &child : m_Children) {
53-
child->Update(deltaTransform);
61+
child->Update(m_Transform);
5462
}
5563

5664
// LOG_DEBUG("GIRA: x: {}, y: {}", pos.x, pos.y);

src/Triangle.cpp

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)