Skip to content

Commit

Permalink
fix: Make sure game is possible (#40)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenjaminHalko authored Jun 20, 2024
1 parent 27a5476 commit 62d21e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 42 deletions.
29 changes: 0 additions & 29 deletions engine/include/engine/comp/timer.h

This file was deleted.

29 changes: 16 additions & 13 deletions src/entities/wallGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ float MultiWallGaps(int rotation, float dist) {
float SpinAround(int rotation, float dist) {
const float distBetween = WallStandardSize * 0.5f;
int dir = (RandomRange(0, 2) > 1) ? 1 : -1;
const float hallwaySize = WallStandardSize * 5.0f;
const float hallwaySize = WallStandardSize * 5.5f;

CreateWall(rotation + 1 * dir, dist, WallStandardSize);
CreateWall(rotation + 2 * dir, dist, WallStandardSize + hallwaySize / 4.0f);
Expand Down Expand Up @@ -84,7 +84,7 @@ float TightGaps(int rotation, float dist) {
dist += WallGaps(rotation + 1, dist) / 1.5f;
dist += WallGaps(rotation, dist) / 1.5f;
WallGaps(rotation + 1, dist);
return StandardDistanceBetweenSets * 3;
return StandardDistanceBetweenSets * 4.5f;;
}

float SideToSide(int rotation, float dist) {
Expand All @@ -110,7 +110,7 @@ float MoveSlowly(int rotation, float dist) {
dist += WallRing(rotation+3*dir, dist) / 1.5f;
dist += WallRing(rotation+4*dir, dist) / 1.5f;
WallRing(rotation+5*dir, dist);
return StandardDistanceBetweenSets * 4;
return StandardDistanceBetweenSets * 4.5f;
}

// Wall Generator
Expand All @@ -120,35 +120,36 @@ void UpdateWallGenerator(Entity& self) {
static const float startDistance = 1.0f;
static float delayTillNextSet = -0.2f;
static int lastShapePhase = 0;
static float spd = Global::wallSpd;

// Return if game over
if (Global::gameOver) {
delayTillNextSet = -0.2f;
return;
}

// Check if the shape phase has changed
// Check if the shape phase has changed and add a break
if (lastShapePhase != GetShapePhase()) {
lastShapePhase = GetShapePhase();
if (lastShapePhase != 0)
delayTillNextSet *= 1.5f;
else
delayTillNextSet = -0.2f;
delayTillNextSet += 0.1f;
}

// Create array of functions
std::vector<WallPatternFunc> wallSets;
if (RoundRunning() < 10) {
wallSets = {
WallRing,
WallGaps,
WallRing2Holes,
MultiWallGaps,
MultiWallRing
WallRing,
WallRing2Holes,
WallGaps,
MultiWallRing,
MultiWallGaps
};
} else if (RoundRunning() < 20) {
wallSets = {
WallRing2Holes,
WallRing,
WallGaps,
MultiWallRing,
MultiWallGaps,
SpinAround,
Expand All @@ -158,16 +159,18 @@ void UpdateWallGenerator(Entity& self) {
wallSets = {
MultiWallRing,
MultiWallGaps,
SideToSide,
SpinAround,
TightGaps,
MoveSlowly
};
}

// Create new set
delayTillNextSet -= TimeSystem::DeltaTime() * Global::wallSpd;
delayTillNextSet -= TimeSystem::DeltaTime() * spd;

if (delayTillNextSet <= 0) {
spd = Global::wallSpd;
int pattern = (int)RandomRange(0, (float)wallSets.size());
int rotation = (int)RandomRange(0, 6);
delayTillNextSet = wallSets[pattern](rotation, startDistance + delayTillNextSet);
Expand Down

0 comments on commit 62d21e1

Please sign in to comment.