Skip to content

Commit

Permalink
feat: make it nice again
Browse files Browse the repository at this point in the history
  • Loading branch information
developer239 committed Dec 24, 2023
1 parent a2c432f commit b8e9384
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
6 changes: 3 additions & 3 deletions src/apps/day14/src/strategies/ECSStrategy.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ std::string filePath = "assets/input.txt";

class MinimalLoopStrategy : public Core::IStrategy {
public:
float scale = 20.0f;
float scale = 50.0f;
int numRows = 0;
int numCols = 0;

Expand Down Expand Up @@ -135,7 +135,7 @@ class MinimalLoopStrategy : public Core::IStrategy {

ECS::Registry::Instance().AddComponent<TextComponent>(
cubeShapedRockEntity,
"",
"#",
SDL_Color{0, 0, 255, 255},
6
);
Expand Down Expand Up @@ -173,7 +173,7 @@ class MinimalLoopStrategy : public Core::IStrategy {

ECS::Registry::Instance().AddComponent<TextComponent>(
cubeShapedRockEntity,
"",
"O",
SDL_Color{0, 0, 255, 255},
6
);
Expand Down
10 changes: 10 additions & 0 deletions src/apps/day14/src/systems/CollisionSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ class CollisionSystem : public ECS::System {
rigidBodyA.velocity.y = 0;
rigidBodyB.velocity.x = 0;
rigidBodyB.velocity.y = 0;

// fix position and round to step scale (px)
rigidBodyA.position.x =
std::round(rigidBodyA.position.x / scale) * scale;
rigidBodyA.position.y =
std::round(rigidBodyA.position.y / scale) * scale;
rigidBodyB.position.x =
std::round(rigidBodyB.position.x / scale) * scale;
rigidBodyB.position.y =
std::round(rigidBodyB.position.y / scale) * scale;
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions src/apps/day14/src/systems/PuzzleSolverSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ class PuzzleSolverSystem : public ECS::System {
// including the row the rock is on. (Cube-shaped rocks (#) don't
// contribute to load.) So, the amount of load caused by each rock in
// each row is as follows:
if(*simulationStarted) {
return;
}

const float SCALE = scale;
int HEIGHT = numRows + 1;
Expand Down Expand Up @@ -117,7 +114,7 @@ class PuzzleSolverSystem : public ECS::System {

totalLoad += totalRoundedDiff;

// textComponent.text = std::string("O ") + std::to_string(totalRoundedDiff);
textComponent.text = std::string("O ") + std::to_string(totalRoundedDiff);
}

auto& tiltTrackerTextComponent =
Expand Down Expand Up @@ -156,7 +153,7 @@ class PuzzleSolverSystem : public ECS::System {
for (auto entity : entities) {
auto& rigidBody =
ECS::Registry::Instance().GetComponent<RigidBodyComponent>(entity);
rigidBody.velocity.y = -0.5;
rigidBody.velocity.y = -5;
}
}

Expand Down

0 comments on commit b8e9384

Please sign in to comment.