added extrajump and dash

This commit is contained in:
OfficialCHenry 2022-04-14 21:22:52 -04:00
parent f58333aaaa
commit 1c1744002f
9 changed files with 56 additions and 18 deletions

View File

@ -22,7 +22,7 @@ import WeaponTypeRegistry from "./shattered_sword/Registry/WeaponTypeRegistry";
{name: "down", keys: ["s"]},
{name: "jump", keys: ["x","space"]},
{name: "attack", keys: ["j","z","enter"]},
{name: "dash", keys: ["k","z"]},
{name: "dash", keys: ["k","x"]}, //
{name: "skill", keys: ["l","v"]},
{name: "inventory", keys: ["i","b"]},
{name: "pause", keys: ["escape"]},

View File

@ -40,7 +40,7 @@ export default class Patrol extends EnemyState {
//turn around
//console.log(this.parent.tilemap.getTileAtRowCol(colrow));
this.parent.direction *= -1;
console.log((<Sprite>this.owner).invertX);
//console.log((<Sprite>this.owner).invertX);
//(<Sprite>this.owner).invertX != (<Sprite>this.owner).invertX ;
//console.log("turn around cus wall in front");
}
@ -48,7 +48,7 @@ export default class Patrol extends EnemyState {
else if(!this.parent.tilemap.isTileCollidable(colrow.x+this.parent.direction,colrow.y+1)){
//turn around
this.parent.direction *=-1;
console.log((<Sprite>this.owner).invertX);
//console.log((<Sprite>this.owner).invertX);
//console.log("turn around cus no floor in front");
}
else{

View File

@ -70,6 +70,10 @@ export default class PlayerController extends StateMachineAI implements BattlerA
CURRENT_DEF: number = 100;
tilemap: OrthogonalTilemap;
//for doublejumps maybe = # of jumps in air allowed
MAX_airjumps: number = 1;
airjumps:number = 0;
// TODO -
damage(damage: number): void {
(<AnimatedSprite>this.owner).animation.play("HURT", false);
@ -222,10 +226,10 @@ export default class PlayerController extends StateMachineAI implements BattlerA
} else if(this.currentState instanceof Fall){
Debug.log("playerstate", "Player State: Fall");
}
Debug.log("playerspeed", "x: " + this.velocity.x + ", y:" + this.velocity.y);
Debug.log("player Coords:", this.owner.position );
Debug.log("player speed", "player speed: x: " + this.velocity.x + ", y:" + this.velocity.y);
Debug.log("player Coords:", "Player Coords:" +this.owner.position );
//testing the attacks here, may be moved to another place latera
//testing the attacks here, may be moved to another place later
if(Input.isJustPressed("attack")){
let item = this.inventory.getItem();
(<AnimatedSprite>this.owner).animation.playIfNotAlready("ATTACK", true);
@ -236,6 +240,7 @@ export default class PlayerController extends StateMachineAI implements BattlerA
item.use(this.owner, "player", this.lookDirection);
}
}
}

View File

@ -1,6 +1,7 @@
import GameEvent from "../../../Wolfie2D/Events/GameEvent";
import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite";
import InAir from "./InAir";
import Input from "../../../Wolfie2D/Input/Input";
export default class Fall extends InAir {
owner: AnimatedSprite;
@ -9,6 +10,18 @@ export default class Fall extends InAir {
this.owner.animation.play("FALL", true);
}
update(deltaT: number): void {
super.update(deltaT);
//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 && Input.isJustPressed("jump")){
this.parent.airjumps --;
this.finished("jump");
this.parent.velocity.y = -600; // basically jump height
}
}
onExit(): Record<string, any> {
this.owner.animation.stop();
return {};

View File

@ -15,7 +15,7 @@ export default abstract class InAir extends PlayerState {
(<Sprite>this.owner).invertX = MathUtils.sign(dir.x) < 0;
}
this.parent.velocity.x += dir.x * this.parent.speed/3.5 - 0.3*this.parent.velocity.x;
this.parent.velocity.x += dir.x * (this.parent.speed+this.parent.CURRENT_BUFFS.speed)/3.5 - 0.3*this.parent.velocity.x;
this.owner.move(this.parent.velocity.scaled(deltaT));

View File

@ -5,6 +5,7 @@ import { EaseFunctionType } from "../../../Wolfie2D/Utils/EaseFunctions";
import { Player_Events } from "../../sword_enums";
import { PlayerStates } from "../PlayerController";
import InAir from "./InAir";
import Input from "../../../Wolfie2D/Input/Input";
export default class Jump extends InAir {
owner: AnimatedSprite;
@ -24,6 +25,15 @@ export default class Jump extends InAir {
this.parent.velocity.y = 0;
}
//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 && Input.isJustPressed("jump")){
this.parent.airjumps --;
this.finished("jump");
this.parent.velocity.y = -600; // basically jump height
}
// If we're falling, go to the fall state
if(this.parent.velocity.y >= 0){
this.finished(PlayerStates.FALL);

View File

@ -8,9 +8,14 @@ export default class OnGround extends PlayerState {
onEnter(options: Record<string, any>): void {}
update(deltaT: number): void {
//reset airjumps
this.parent.airjumps = this.parent.MAX_airjumps;
if(this.parent.velocity.y > 0){
this.parent.velocity.y = 0;
}
super.update(deltaT);
let direction = this.getInputDirection();
@ -19,12 +24,14 @@ export default class OnGround extends PlayerState {
(<Sprite>this.owner).invertX = MathUtils.sign(direction.x) < 0;
}
// If we jump, move to the Jump state, give a burst of upwards velocity
if(Input.isJustPressed("jump")){
this.finished("jump");
this.parent.velocity.y = -600; // basically jump height
} else if(!this.owner.onGround){
}
else if(!this.owner.onGround){
this.finished("fall");
}

View File

@ -22,8 +22,16 @@ export default class Walk extends OnGround {
if(dir.isZero()){
this.finished(PlayerStates.IDLE);
}
this.parent.velocity.x = dir.x * this.parent.speed
this.parent.velocity.x = dir.x * (this.parent.speed + this.parent.CURRENT_BUFFS.speed);
//TODO - decide how to implement dash - could be a flash - maybe allow in air as well
if(Input.isJustPressed("dash")){
//play dash anim maybe
//TODO - might give buffed speed stat to dash speed
this.parent.velocity.x = dir.x * 1000; //give sidewards velocity
//TODO - give player i frame
}
this.owner.move(this.parent.velocity.scaled(deltaT));
}

View File

@ -170,9 +170,6 @@ export default class GameLevel extends Scene {
updateScene(deltaT: number){
let clickpos = Input.getMousePosition();
if(Input.isMouseJustPressed())
console.log("mouse pos: " +clickpos);
// Handle events and update the UI if needed
while(this.receiver.hasNextEvent()){
let event = this.receiver.getNextEvent();
@ -184,8 +181,6 @@ export default class GameLevel extends Scene {
//remove enemy from enemies
this.enemies = this.enemies.filter(item => item !== event.data.get("ai"));
this.battleManager.removeEnemy(event.data.get("ai"));
console.log("enemy destroyed");
node.destroy();
//TODO - this is for testing, add some chance here later
this.emitter.fireEvent(Player_Events.GIVE_BUFF);
@ -197,7 +192,7 @@ export default class GameLevel extends Scene {
this.buffButton2.text = "Increase "+this.buffs[1].type + " by "+this.buffs[1].value;
this.buffButton3.text = "Increase "+this.buffs[2].type + " by "+this.buffs[2].value;
//pause game here
this.buffLayer.enable();
break;
@ -527,7 +522,7 @@ export default class GameLevel extends Scene {
case "snake": //snake enemies drop from sky("trees")? or could just be very abundant
this.addEnemy("snake", enemy.position.scale(32), {
player: this.player,
health: 100,
health: 50,
tilemap: "Main",
//actions:actions,
goal: Statuses.REACHED_GOAL,
@ -536,7 +531,7 @@ export default class GameLevel extends Scene {
case "tiger": //tiger can be miniboss for now?
this.addEnemy("tiger", enemy.position.scale(32), {
player: this.player,
health: 100,
health: 200,
tilemap: "Main",
//actions:actions,
goal: Statuses.REACHED_GOAL,