diff --git a/src/assets/images/character_lion_48.png b/src/assets/images/character_lion_48.png index fb38584..0cfeb83 100644 Binary files a/src/assets/images/character_lion_48.png and b/src/assets/images/character_lion_48.png differ diff --git a/src/assets/images/tiles_grass_32.png b/src/assets/images/tiles_grass_32.png index 79f8b83..bbdbd23 100644 Binary files a/src/assets/images/tiles_grass_32.png and b/src/assets/images/tiles_grass_32.png differ diff --git a/src/game/game.zig b/src/game/game.zig index 9eb6e08..fc759b0 100644 --- a/src/game/game.zig +++ b/src/game/game.zig @@ -20,6 +20,7 @@ pub const Game = struct { health: i64 = 4, playerPosition: engine.PointF, + playerFallingAnimation: Animation, playerIdleAnimation: Animation, playerWalkingAnimation: Animation, playerDirection: Direction, @@ -37,6 +38,7 @@ pub const Game = struct { return Game{ .level = level, .playerPosition = playerPosition, + .playerFallingAnimation = Animation.initPartialLoop(renderer.sprites.get("character_lion_48").?, 0.2, 8, 12), .playerIdleAnimation = Animation.initPartialLoop(renderer.sprites.get("character_lion_48").?, 0.25, 0, 4), .playerWalkingAnimation = Animation.initPartialLoop(renderer.sprites.get("character_lion_48").?, 0.125, 4, 8), .playerDirection = Direction.Right, diff --git a/src/game_scene.zig b/src/game_scene.zig index 6e76a1e..7d5c8a3 100644 --- a/src/game_scene.zig +++ b/src/game_scene.zig @@ -51,11 +51,17 @@ pub const GameScene = struct { } // self.game.playerVelocity.y = std.math.min(maxFallVelocity, self.game.playerVelocity.y + self.game.playerAcceleration.y * dt); - if (self.game.playerVelocity.x != 0 and self.game.playerVelocity.y == 0) { + if (self.game.playerVelocity.y != 0) { + self.game.playerFallingAnimation.tick(t); + self.game.playerIdleAnimation.reset(); + self.game.playerWalkingAnimation.reset(); + } else if (self.game.playerVelocity.x != 0 and self.game.playerVelocity.y == 0) { self.game.playerWalkingAnimation.tick(t); + self.game.playerFallingAnimation.tick(t); self.game.playerIdleAnimation.reset(); } else if (self.game.playerVelocity.x == 0) { self.game.playerIdleAnimation.tick(t); + self.game.playerFallingAnimation.tick(t); self.game.playerWalkingAnimation.reset(); } self.game.movePlayer(dt); @@ -101,10 +107,14 @@ pub const GameScene = struct { 1 => { if (ordinals.right) offset = 0; if (ordinals.left) offset = 3; + if (ordinals.top) offset = 15; + if (ordinals.bottom) offset = 14; }, 2 => { if (ordinals.right and ordinals.left) offset = 1 + self.game.randomTileOffset(x, y, 2); if (ordinals.top and ordinals.bottom) offset = 12; + if (ordinals.top and ordinals.left) offset = 9; + if (ordinals.top and ordinals.right) offset = 8; if (ordinals.right and ordinals.bottom) offset = 4; if (ordinals.left and ordinals.bottom) offset = 5; }, @@ -131,8 +141,10 @@ pub const GameScene = struct { } } - const playerDirectionFrameOffset: usize = if (self.game.playerDirection == game.Game.Direction.Left) 0 else 8; - if (self.game.playerVelocity.x != 0 and self.game.playerVelocity.y == 0) { + const playerDirectionFrameOffset: usize = if (self.game.playerDirection == game.Game.Direction.Left) 0 else 12; + if (self.game.playerVelocity.y != 0) { + self.game.drawSpriteFrameP("character_lion_48", self.game.playerFallingAnimation.current + playerDirectionFrameOffset, self.game.playerPosition.add(engine.PointF.init(-0.25, -0.25))); + } else if (self.game.playerVelocity.x != 0 and self.game.playerVelocity.y == 0) { self.game.drawSpriteFrameP("character_lion_48", self.game.playerWalkingAnimation.current + playerDirectionFrameOffset, self.game.playerPosition.add(engine.PointF.init(-0.25, -0.25))); } else { self.game.drawSpriteFrameP("character_lion_48", self.game.playerIdleAnimation.current + playerDirectionFrameOffset, self.game.playerPosition.add(engine.PointF.init(-0.25, -0.25)));