Created
February 8, 2019 22:49
-
-
Save digitsensitive/f8c6cf1a2a4390d296982915a9e9d0b3 to your computer and use it in GitHub Desktop.
Learn to create a HTML5 Game in 5 Minutes - Bird
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
| update(): void { | |
| // handle angle change | |
| if (this.angle < 30) { | |
| this.angle += 2; | |
| } | |
| // handle input | |
| if (this.jumpKey.isDown && !this.isFlapping) { | |
| // flap | |
| this.isFlapping = true; | |
| this.body.setVelocityY(-350); | |
| this.scene.tweens.add({ | |
| targets: this, | |
| props: { angle: -20 }, | |
| duration: 150, | |
| ease: "Power0" | |
| }); | |
| } else if (this.jumpKey.isUp && this.isFlapping) { | |
| this.isFlapping = false; | |
| } | |
| // check if off the screen | |
| if (this.y + this.height > this.scene.sys.canvas.height) { | |
| this.isDead = true; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment