1 decade ago by Cadence96
Hi,
I pretend to do the dead animation from NES Super Mario Bros 1 ( link)
Those are the steps I'm trying to do:
1 If life of the player reachs 0, execute deadAnimation().
2 deadAnimation() triggers after 2 seconds.
3 EntityPlayer is moved up with (
4 After that, the EntityPlayer falls to the bottom of the window (
In my EntityPlayer I've added this code
My problem is that the Entity starts a jump loop moving up and down.
Can I have a hint how to do this?
I pretend to do the dead animation from NES Super Mario Bros 1 ( link)
Those are the steps I'm trying to do:
1 If life of the player reachs 0, execute deadAnimation().
2 deadAnimation() triggers after 2 seconds.
3 EntityPlayer is moved up with (
this.vel.y -= this.pos.y - 200) (like jumping)4 After that, the EntityPlayer falls to the bottom of the window (
this.vel.y -= this.pos.y + 500;).In my EntityPlayer I've added this code
// gravity from main.js is 3000
friction: {x: 800, y: 0},
maxVel: {x: 800, y: 800},
jump: 300,
deadTimer: null,
update: function() {
if (this.health <= 0) {
this.deadAnimation();
}
},
deadAnimation: function() {
if ( this.deadTimer.delta() > 2) {
this.vel.y -= this.pos.y - 200;
if (this.pos.y == -200) {
this.vel.y -= this.pos.y + 500;
}
}
}
My problem is that the Entity starts a jump loop moving up and down.
Can I have a hint how to do this?
