projects
/
ld40.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Reuse same tween for monster shaking
[ld40.git]
/
ld40.js
diff --git
a/ld40.js
b/ld40.js
index 53e41f87ce314147e88d5301a5a3b91ea399bfc0..7bf03d71da756c446f15d2f52cc77f4de7abcdbe 100644
(file)
--- a/
ld40.js
+++ b/
ld40.js
@@
-32,6
+32,9
@@
}
}, false);
}
}, false);
+ function sign(n) {
+ if (n >= 0) { return 1 } else { return -1 };
+ }
class Player extends Phaser.Text {
constructor(x, y) {
class Player extends Phaser.Text {
constructor(x, y) {
@@
-155,6
+158,7
@@
this.weapon = new JusticeBlaster(game, this);
this.weapon.bulletSpeed = SPEED_MPROJECTILE;
this.weapon.trackSprite(this);
this.weapon = new JusticeBlaster(game, this);
this.weapon.bulletSpeed = SPEED_MPROJECTILE;
this.weapon.trackSprite(this);
+ this.shaketween = game.add.tween(this).to({ x: this.x + (sign(Math.random() - 0.5)) * 5 }, 10, Phaser.Easing.Sinusoidal.InOut, false, 0, 8, true);
}
enablePhysics() {
}
enablePhysics() {
@@
-163,7
+167,7
@@
damage(amount) {
super.damage(amount);
damage(amount) {
super.damage(amount);
- if (this.alive) {
game.add.tween(this).to({ x: this.x + (Math.random() - 0.5) * 10 }, 10, Phaser.Easing.Sinusoidal.InOut, true, 0, 8, true
); }
+ if (this.alive) {
this.shaketween.start(
); }
}
kill() {
}
kill() {