feat: add dash animation

This commit is contained in:
Renge 2022-04-24 18:41:17 -04:00
parent 201bfccd85
commit b1028611f2
6 changed files with 50 additions and 18 deletions

View File

@ -310,23 +310,31 @@
"frames": [
{
"index": 46,
"duration": 5
"duration": 1
},
{
"index": 47,
"duration": 5
"duration": 1
},
{
"index": 48,
"duration": 5
"duration": 1
},
{
"index": 49,
"duration": 5
"duration": 2
},
{
"index": 50,
"duration": 10
"index": 48,
"duration": 1
},
{
"index": 47,
"duration": 1
},
{
"index": 46,
"duration": 1
}
]
}

View File

@ -2,6 +2,7 @@ import GameEvent from "../../../Wolfie2D/Events/GameEvent";
import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite";
import InAir from "./InAir";
import InputWrapper from "../../Tools/InputWrapper";
import PlayerState from "./PlayerState";
export default class Fall extends InAir {
owner: AnimatedSprite;
@ -11,12 +12,17 @@ export default class Fall extends InAir {
}
update(deltaT: number): void {
if (!PlayerState.dashTimer.isStopped()) {
this.owner.animation.playIfNotAlready("DASH");
}
else {
if (this.parent.invincible) {
this.owner.animation.playIfNotAlready("HURT");
}
else {
this.owner.animation.playIfNotAlready("FALL", true);
}
}
//TODO - testing doublejump, may have to move to InAir instead
// If we jump, move to the Jump state, give a burst of upwards velocity
if( this.parent.airjumps>0 && InputWrapper.isJumpJustPressed()){

View File

@ -1,6 +1,7 @@
import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite";
import { PlayerStates } from "../PlayerController";
import OnGround from "./OnGround";
import PlayerState from "./PlayerState";
export default class Idle extends OnGround {
owner: AnimatedSprite;
@ -13,7 +14,13 @@ export default class Idle extends OnGround {
update(deltaT: number): void {
//("idle anim");
if (!PlayerState.dashTimer.isStopped()) {
console.log("Playing dash");
this.owner.animation.playIfNotAlready("DASH");
}
else {
this.owner.animation.playIfNotAlready("IDLE", true);
}
let dir = this.getInputDirection();

View File

@ -6,6 +6,7 @@ import { Player_Events } from "../../sword_enums";
import InputWrapper from "../../Tools/InputWrapper";
import { PlayerStates } from "../PlayerController";
import InAir from "./InAir";
import PlayerState from "./PlayerState";
export default class Jump extends InAir {
owner: AnimatedSprite;
@ -17,12 +18,17 @@ export default class Jump extends InAir {
update(deltaT: number): void {
if (!PlayerState.dashTimer.isStopped()) {
this.owner.animation.playIfNotAlready("DASH");
}
else {
if (this.parent.invincible) {
this.owner.animation.playIfNotAlready("HURT");
}
else {
this.owner.animation.playIfNotAlready("JUMP", true);
}
}
if(this.owner.onCeiling){

View File

@ -24,7 +24,7 @@ export default abstract class PlayerState extends State {
this.owner = owner;
this.positionTimer = new Timer(250);
this.positionTimer.start();
PlayerState.dashTimer = new Timer(50);
PlayerState.dashTimer = new Timer(100);
PlayerState.dashCoolDownTimer = new Timer(600);
}

View File

@ -3,6 +3,7 @@ import { Player_Events } from "../../sword_enums";
import InputWrapper from "../../Tools/InputWrapper";
import { PlayerStates } from "../PlayerController";
import OnGround from "./OnGround";
import PlayerState from "./PlayerState";
export default class Walk extends OnGround {
owner: AnimatedSprite;
@ -14,13 +15,17 @@ export default class Walk extends OnGround {
update(deltaT: number): void {
if (!PlayerState.dashTimer.isStopped()) {
this.owner.animation.playIfNotAlready("DASH");
}
else {
if (this.parent.invincible) {
this.owner.animation.playIfNotAlready("HURT");
}
else {
this.owner.animation.playIfNotAlready("WALK", true);
}
}
let dir = this.getInputDirection();
if(dir.isZero()){