Skip to content
This repository has been archived by the owner on Dec 13, 2024. It is now read-only.

Commit

Permalink
Move Pipe spawning code into Pipe class
Browse files Browse the repository at this point in the history
  • Loading branch information
esotericenderman committed Aug 1, 2024
1 parent d98408f commit 397d0da
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 4 additions & 0 deletions Pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ class Pipe {
}
}

public static beginSpawningPipes() {
loops.everyInterval(8000, () => Pipe.spawnPipe());
}

public static spawnPipe() {
const squareLocations = [new Square(4, 0), new Square(4, 1), new Square(4, 2), new Square(4, 3), new Square(4, 4)];

Expand Down
10 changes: 8 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
const bird = new Bird();

let update = () => {
Pipe.beginSpawningPipes();

const update = () => {
if (bird.isGameOver) {
return;
}

basic.clearScreen();

bird.update();

for (const pipe of Pipe.pipes) {
Expand All @@ -10,4 +17,3 @@ let update = () => {
}

loops.everyInterval(1, update);
loops.everyInterval(8000, Pipe.spawnPipe);

0 comments on commit 397d0da

Please sign in to comment.