Skip to content

Instantly share code, notes, and snippets.

@digitsensitive
Created February 8, 2019 22:49
Show Gist options
  • Select an option

  • Save digitsensitive/f8c6cf1a2a4390d296982915a9e9d0b3 to your computer and use it in GitHub Desktop.

Select an option

Save digitsensitive/f8c6cf1a2a4390d296982915a9e9d0b3 to your computer and use it in GitHub Desktop.
Learn to create a HTML5 Game in 5 Minutes - Bird
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