diff --git a/src/shattered_sword/Player/PlayerStates/Idle.ts b/src/shattered_sword/Player/PlayerStates/Idle.ts index 1c73efe..e49309b 100644 --- a/src/shattered_sword/Player/PlayerStates/Idle.ts +++ b/src/shattered_sword/Player/PlayerStates/Idle.ts @@ -1,4 +1,5 @@ import AnimatedSprite from "../../../Wolfie2D/Nodes/Sprites/AnimatedSprite"; +import GameLevel from "../../Scenes/GameLevel"; import { PlayerStates } from "../PlayerController"; import OnGround from "./OnGround"; import PlayerState from "./PlayerState"; @@ -28,7 +29,12 @@ export default class Idle extends OnGround { this.finished(PlayerStates.WALK); } - this.parent.velocity.x = 0; + if (GameLevel.currentLevel === "snow") { + this.parent.velocity.x = Math.sign(this.parent.velocity.x)*(Math.abs(this.parent.velocity.x) - 5 < 0 ? 0 : Math.abs(this.parent.velocity.x) - 5); + } + else { + this.parent.velocity.x = 0; + } super.update(deltaT); } diff --git a/src/shattered_sword/Player/PlayerStates/Walk.ts b/src/shattered_sword/Player/PlayerStates/Walk.ts index 8338801..de757d1 100644 --- a/src/shattered_sword/Player/PlayerStates/Walk.ts +++ b/src/shattered_sword/Player/PlayerStates/Walk.ts @@ -6,6 +6,7 @@ import OnGround from "./OnGround"; import PlayerState from "./PlayerState"; import { GameEventType } from "../../../Wolfie2D/Events/GameEventType"; import { GameState } from "../../sword_enums"; +import GameLevel from "../../Scenes/GameLevel"; export default class Walk extends OnGround { owner: AnimatedSprite; @@ -37,8 +38,16 @@ export default class Walk extends OnGround { this.finished(PlayerStates.IDLE); } - this.parent.velocity.x = dir.x * (this.parent.speed ); - + if (GameLevel.currentLevel === "snow") { + this.parent.velocity.x += dir.x * 5; + if (this.parent.velocity.x > this.parent.speed) + this.parent.velocity.x = this.parent.speed; + if (this.parent.velocity.x < -1 * this.parent.speed) + this.parent.velocity.x = -1 * this.parent.speed; + } + else { + this.parent.velocity.x = dir.x * (this.parent.speed ); + } super.update(deltaT); } diff --git a/src/shattered_sword/Scenes/GameLevel.ts b/src/shattered_sword/Scenes/GameLevel.ts index 3406fbd..9365f62 100644 --- a/src/shattered_sword/Scenes/GameLevel.ts +++ b/src/shattered_sword/Scenes/GameLevel.ts @@ -142,6 +142,7 @@ export default class GameLevel extends Scene { protected gameStarted: boolean = false; protected timerLable: Label; protected levelEnded: boolean = false; + static currentLevel: string = ""; startpos: Vec2; loadScene(): void { @@ -184,6 +185,7 @@ export default class GameLevel extends Scene { this.load.spritesheet("test_dummy","shattered_sword_assets/spritesheets/test_dummy.json") this.enemies = new Array(); this.battleManager = new BattleManager(); + GameLevel.currentLevel = ""; } unloadScene(): void { diff --git a/src/shattered_sword/Scenes/Snow.ts b/src/shattered_sword/Scenes/Snow.ts index 63a3cf5..bdb8090 100644 --- a/src/shattered_sword/Scenes/Snow.ts +++ b/src/shattered_sword/Scenes/Snow.ts @@ -21,6 +21,7 @@ export default class Snow extends GameLevel { this.map = this.rmg.getMap(); console.log(this.map); this.load.tilemapFromObject("map", this.map); + GameLevel.currentLevel = "snow"; //load enemies