diff --git a/dist/shattered_sword_assets/spritesheets/Hiro.json b/dist/shattered_sword_assets/spritesheets/Hiro.json index bc3ec3f..28bfc5a 100644 --- a/dist/shattered_sword_assets/spritesheets/Hiro.json +++ b/dist/shattered_sword_assets/spritesheets/Hiro.json @@ -210,13 +210,65 @@ "name": "HURT", "repeat": false, "frames": [ + { + "index": 39, + "duration": 5 + }, { "index": 0, - "duration": 500 + "duration": 5 }, { "index": 39, - "duration": 500 + "duration": 5 + }, + { + "index": 0, + "duration": 5 + }, + { + "index": 39, + "duration": 5 + }, + { + "index": 0, + "duration": 5 + }, + { + "index": 39, + "duration": 5 + }, + { + "index": 0, + "duration": 5 + }, + { + "index": 39, + "duration": 5 + }, + { + "index": 0, + "duration": 5 + }, + { + "index": 39, + "duration": 5 + }, + { + "index": 0, + "duration": 5 + }, + { + "index": 39, + "duration": 5 + }, + { + "index": 0, + "duration": 5 + }, + { + "index": 39, + "duration": 5 } ] }, diff --git a/public/shattered_sword_assets/spritesheets/Hiro.json b/public/shattered_sword_assets/spritesheets/Hiro.json index 009acfd..b7c4b4c 100644 --- a/public/shattered_sword_assets/spritesheets/Hiro.json +++ b/public/shattered_sword_assets/spritesheets/Hiro.json @@ -200,15 +200,63 @@ }, { "name": "HURT", - "repeat": true, + "repeat": false, "frames": [ { "index": 0, - "duration": 50 + "duration": 5 }, { "index": 39, - "duration": 50 + "duration": 5 + }, + { + "index": 0, + "duration": 5 + }, + { + "index": 39, + "duration": 5 + }, + { + "index": 0, + "duration": 5 + }, + { + "index": 39, + "duration": 5 + }, + { + "index": 0, + "duration": 5 + }, + { + "index": 39, + "duration": 5 + }, + { + "index": 0, + "duration": 5 + }, + { + "index": 39, + "duration": 5 + }, + { + "index": 0, + "duration": 5 + }, + { + "index": 39, + "duration": 5 + }, + { + "index": 0, + "duration": 5 + }, + { + "index": 39, + "duration": 5 } ] }, diff --git a/src/shattered_sword/AI/EnemyAI.ts b/src/shattered_sword/AI/EnemyAI.ts index e8ba915..794ba11 100644 --- a/src/shattered_sword/AI/EnemyAI.ts +++ b/src/shattered_sword/AI/EnemyAI.ts @@ -112,6 +112,7 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI { activate(options: Record): void { } damage(damage: number): void { + console.log(damage +" damage taken, "+this.CURRENT_HP+" hp left"); this.CURRENT_HP -= damage; //TODO - this.owner.animation.play("HURT",false); diff --git a/src/shattered_sword/Player/PlayerController.ts b/src/shattered_sword/Player/PlayerController.ts index b3f2f49..7e84c4e 100644 --- a/src/shattered_sword/Player/PlayerController.ts +++ b/src/shattered_sword/Player/PlayerController.ts @@ -19,6 +19,7 @@ import AnimatedSprite from "../../Wolfie2D/Nodes/Sprites/AnimatedSprite"; import InputWrapper from "../Tools/InputWrapper"; import EnemyAI from "../AI/EnemyAI"; import Timer from "../../Wolfie2D/Timing/Timer"; +import PlayerState from "./PlayerStates/PlayerState"; export enum PlayerType { @@ -233,7 +234,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA if (this.godMode) { return; } - if( !this.invincible){ + if( !this.invincible && !PlayerState.dashTimer.isStopped()){ //i frame here PlayerController.invincibilityTimer.start(); this.invincible = true; diff --git a/src/shattered_sword/Player/PlayerStates/Fall.ts b/src/shattered_sword/Player/PlayerStates/Fall.ts index 5c9f0a4..c4a16fc 100644 --- a/src/shattered_sword/Player/PlayerStates/Fall.ts +++ b/src/shattered_sword/Player/PlayerStates/Fall.ts @@ -7,20 +7,25 @@ export default class Fall extends InAir { owner: AnimatedSprite; onEnter(options: Record): void { - this.owner.animation.play("FALL", true); + // this.owner.animation.play("FALL", true); } update(deltaT: number): void { - super.update(deltaT); - + 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()){ this.parent.airjumps --; this.finished("jump"); this.parent.velocity.y = -600; // basically jump height - } + + super.update(deltaT); } onExit(): Record { this.owner.animation.stop(); diff --git a/src/shattered_sword/Player/PlayerStates/Jump.ts b/src/shattered_sword/Player/PlayerStates/Jump.ts index a758272..dcabfbe 100644 --- a/src/shattered_sword/Player/PlayerStates/Jump.ts +++ b/src/shattered_sword/Player/PlayerStates/Jump.ts @@ -17,9 +17,13 @@ export default class Jump extends InAir { update(deltaT: number): void { - super.update(deltaT); + if (this.parent.invincible) { + this.owner.animation.playIfNotAlready("HURT"); + } + else { + this.owner.animation.playIfNotAlready("JUMP", true); + } - this.owner.animation.play("JUMP", true); if(this.owner.onCeiling){ this.parent.velocity.y = 0; @@ -38,6 +42,7 @@ export default class Jump extends InAir { if(this.parent.velocity.y >= 0){ this.finished(PlayerStates.FALL); } + super.update(deltaT); } onExit(): Record { diff --git a/src/shattered_sword/Player/PlayerStates/OnGround.ts b/src/shattered_sword/Player/PlayerStates/OnGround.ts index f7c892e..4e5a8e8 100644 --- a/src/shattered_sword/Player/PlayerStates/OnGround.ts +++ b/src/shattered_sword/Player/PlayerStates/OnGround.ts @@ -1,6 +1,8 @@ import GameEvent from "../../../Wolfie2D/Events/GameEvent"; +import Game from "../../../Wolfie2D/Loop/Game"; import Sprite from "../../../Wolfie2D/Nodes/Sprites/Sprite"; import MathUtils from "../../../Wolfie2D/Utils/MathUtils"; +import { GameState } from "../../sword_enums"; import InputWrapper from "../../Tools/InputWrapper"; import PlayerState from "./PlayerState"; @@ -31,7 +33,7 @@ export default class OnGround extends PlayerState { this.parent.velocity.y = -600; // basically jump height } - else if(!this.owner.onGround){ + else if(!this.owner.onGround && InputWrapper.getState() === GameState.GAMING){ this.finished("fall"); } super.update(deltaT); diff --git a/src/shattered_sword/Player/PlayerStates/Walk.ts b/src/shattered_sword/Player/PlayerStates/Walk.ts index af79454..09c1e50 100644 --- a/src/shattered_sword/Player/PlayerStates/Walk.ts +++ b/src/shattered_sword/Player/PlayerStates/Walk.ts @@ -9,12 +9,17 @@ export default class Walk extends OnGround { onEnter(options: Record): void { this.parent.speed = this.parent.MIN_SPEED; + } update(deltaT: number): void { - console.log("walking anim"); - this.owner.animation.playIfNotAlready("WALK", true); + if (this.parent.invincible) { + this.owner.animation.playIfNotAlready("HURT"); + } + else { + this.owner.animation.playIfNotAlready("WALK", true); + } let dir = this.getInputDirection();