Skip to content

Commit 9e6ba92

Browse files
committed
Fixed some Bugs.
- Gap between the backgrounds - Accidentally returning directly to the main menu after dying - Fixed NullPointerException (or something like this) - Music always started when starting a game resulting song played multiple times at the same time - Lowered spawn height - Made spawn padding higher
1 parent fa1d242 commit 9e6ba92

File tree

5 files changed

+22
-8
lines changed

5 files changed

+22
-8
lines changed

src/game/custom_classes/Background.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,8 @@ function moveBackground(): void {
142142
backgroundB.x -= backgroundSpeed * globalConsts.backgroundSpeed;
143143
backgroundA.x -= backgroundSpeed * globalConsts.backgroundSpeed;
144144

145-
if (backgroundA.x - backgroundA.displayWidth <= -backgroundA.displayWidth) backgroundA.x = backgroundB.x + 3 + backgroundB.displayWidth;
146-
if (backgroundB.x - backgroundB.displayWidth <= -backgroundB.displayWidth) backgroundB.x = backgroundA.x + 3 + backgroundA.displayWidth;
145+
if (backgroundA.x - backgroundA.displayWidth <= -backgroundA.displayWidth) backgroundA.x = backgroundB.x + backgroundB.displayWidth;
146+
if (backgroundB.x - backgroundB.displayWidth <= -backgroundB.displayWidth) backgroundB.x = backgroundA.x + backgroundA.displayWidth;
147147
}
148148

149149

src/game/scenes/GameOver.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ let leaderboardIsLoaded: boolean = false;
2929
let savedScore: boolean = false;
3030
let buttonManager: ButtonManager;
3131
let gamePad: Gamepad;
32+
let backBlocker: boolean
3233

3334
// Scene class
3435
export class GameOver extends Scene {
@@ -69,6 +70,13 @@ export class GameOver extends Scene {
6970
new Button(globalConsts.gameWidth * 0.04, globalConsts.gameHeight * 0.58, calculateScale(5), "button_jumpsLeft", this.scene.scene).button.setOrigin(0, 0.5);
7071
this.add.text(globalConsts.gameWidth * 0.25, globalConsts.gameHeight * 0.57, localStorage.getItem("last.jumpsLeft") ?? "0", style).setOrigin(0, 0).setScale(calculateScale(1));
7172

73+
// Resets Saved Button
74+
savedScore = false;
75+
name = undefined;
76+
77+
// Sets blocker
78+
backBlocker = true;
79+
7280
// Renders leaderboard
7381
renderLeaderboard().then();
7482

@@ -109,8 +117,11 @@ export class GameOver extends Scene {
109117

110118
// 3 -> back
111119
if (get3(gamePad)) {
120+
if (backBlocker) return;
112121
exit();
113122
return
123+
} else {
124+
if (backBlocker) backBlocker = false
114125
}
115126
}
116127
}
@@ -190,7 +201,7 @@ function prompt(): void {
190201
function clearsLeaderboardLine(): void {
191202
// Clears array
192203
for (let i: number = 0; i < leaderboardLines.length; i++) {
193-
leaderboardLines[i].destroy(true);
204+
leaderboardLines[i]?.destroy(true);
194205
delete leaderboardLines[i];
195206
}
196207

src/game/thatFolder/ThatGame.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ export class ThatGame extends Phaser.Scene {
3232
// Displays debug
3333
displayDebug(this.scene.scene);
3434

35+
// Resets music
36+
this.sound.stopAll()
37+
3538
// Plays music if wanted
3639
if (localStorage.getItem("isActive.music") == "true") this.sound.play('gameMusic');
3740

src/game/thatFolder/ThatObstacle.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ interface obstacleProperties {
3535
// Settings for every obstacle
3636
export const obstaclePropertiesMap: Record<obstacleType, obstacleProperties> = {
3737
[obstacleType.BIRDBLUE]: {
38-
y: () => getRandomInt(globalConsts.gameHeight * 0.4, globalConsts.gameHeight * 0.8),
38+
y: () => getRandomInt(globalConsts.gameHeight * 0.4, globalConsts.gameHeight * 0.822),
3939
sprites: ["birdBlue"],
4040
width: 16,
4141
height: 6,
@@ -45,7 +45,7 @@ export const obstaclePropertiesMap: Record<obstacleType, obstacleProperties> = {
4545
weight: 100
4646
},
4747
[obstacleType.BIRDPINK]: {
48-
y: () => getRandomInt(globalConsts.gameHeight * 0.4, globalConsts.gameHeight * 0.8),
48+
y: () => getRandomInt(globalConsts.gameHeight * 0.4, globalConsts.gameHeight * 0.822),
4949
sprites: ["birdPink"],
5050
width: 16,
5151
height: 6,
@@ -55,7 +55,7 @@ export const obstaclePropertiesMap: Record<obstacleType, obstacleProperties> = {
5555
weight: 100
5656
},
5757
[obstacleType.SNOWMAN]: {
58-
y: () => getRandomInt(globalConsts.gameHeight * 0.866, globalConsts.gameHeight * 0.89),
58+
y: () => getRandomInt(globalConsts.gameHeight * 0.871, globalConsts.gameHeight * 0.89),
5959
sprites: ["snowman"],
6060
width: 6,
6161
height: 12,
@@ -65,7 +65,7 @@ export const obstaclePropertiesMap: Record<obstacleType, obstacleProperties> = {
6565
weight: 100
6666
},
6767
[obstacleType.ROCKS]: {
68-
y: () => getRandomInt(globalConsts.gameHeight * 0.87, globalConsts.gameHeight * 0.89),
68+
y: () => getRandomInt(globalConsts.gameHeight * 0.874, globalConsts.gameHeight * 0.89),
6969
sprites: ["stone"],
7070
width: 164,
7171
height: 100,

src/game/thatFolder/ThatSection.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export class ThatSection {
1515
readonly breakProbability: number = 25;
1616
readonly giftProbability: number = 3;
1717
readonly postionOverflowLimit: number = 100;
18-
readonly obstaclePadding: number = 120;
18+
readonly obstaclePadding: number = 150;
1919
readonly maxVoidout: number = -200;
2020
readonly minVoidout: number = -10;
2121

0 commit comments

Comments
 (0)