Last active
February 8, 2019 22:44
-
-
Save digitsensitive/a6859d702666d636294d062ffa1fdc5e to your computer and use it in GitHub Desktop.
Learn to create a HTML5 Game in 5 Minutes - Game Scene
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private addNewRowOfPipes(): void { | |
| // update the score | |
| this.registry.values.score += 1; | |
| this.scoreText.setText(this.registry.values.score); | |
| // randomly pick a number between 1 and 5 | |
| let hole = Math.floor(Math.random() * 5) + 1; | |
| // add 6 pipes with one big hole at position hole and hole + 1 | |
| for (let i = 0; i < 10; i++) { | |
| if (i !== hole && i !== hole + 1 && i !== hole + 2) { | |
| if (i === hole - 1) { | |
| this.addPipe(400, i * 60, 0); | |
| } else if (i === hole + 3) { | |
| this.addPipe(400, i * 60, 1); | |
| } else { | |
| this.addPipe(400, i * 60, 2); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment