This commit is contained in:
OfficialCHenry 2022-04-20 14:04:35 -04:00
commit 5618e95940
8 changed files with 134 additions and 15 deletions

View File

@ -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
}
]
},

View File

@ -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
}
]
},

View File

@ -112,6 +112,7 @@ export default class EnemyAI extends StateMachineGoapAI implements BattlerAI {
activate(options: Record<string, any>): 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);

View File

@ -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;

View File

@ -7,20 +7,25 @@ export default class Fall extends InAir {
owner: AnimatedSprite;
onEnter(options: Record<string, any>): 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<string, any> {
this.owner.animation.stop();

View File

@ -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<string, any> {

View File

@ -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);

View File

@ -9,12 +9,17 @@ export default class Walk extends OnGround {
onEnter(options: Record<string, any>): 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();