diff --git a/GreatSpringGameJam/Content/Textures/Player.aseprite b/GreatSpringGameJam/Content/Textures/Player.aseprite index b7895e6..2f17180 100644 Binary files a/GreatSpringGameJam/Content/Textures/Player.aseprite and b/GreatSpringGameJam/Content/Textures/Player.aseprite differ diff --git a/GreatSpringGameJam/Content/Textures/Player.png b/GreatSpringGameJam/Content/Textures/Player.png index 69161d1..fe9360b 100644 Binary files a/GreatSpringGameJam/Content/Textures/Player.png and b/GreatSpringGameJam/Content/Textures/Player.png differ diff --git a/GreatSpringGameJam/Player.cs b/GreatSpringGameJam/Player.cs index 56fd4eb..f45eee5 100644 --- a/GreatSpringGameJam/Player.cs +++ b/GreatSpringGameJam/Player.cs @@ -18,7 +18,7 @@ using RectangleF = MLEM.Misc.RectangleF; namespace GreatSpringGameJam { public class Player : Entity { - private static readonly UniformTextureAtlas PlayerTexture = new(MlemGame.LoadContent("Textures/Player"), 4, 1); + private static readonly UniformTextureAtlas PlayerTexture = new(MlemGame.LoadContent("Textures/Player"), 4, 3); public RectangleF Bounds => new(this.Position + new Vector2(4 / 16F, 0), new Vector2(9 / 16F, 1)); @@ -35,8 +35,14 @@ namespace GreatSpringGameJam { public Player(Map map, Vector2 position) : base(map, position) { this.animations = new SpriteAnimationGroup(); - this.animations.Add(new SpriteAnimation(0.15F, PlayerTexture[1], PlayerTexture[2], PlayerTexture[3], PlayerTexture[0]), () => this.walking); + // walking animations this.animations.Add(new SpriteAnimation(1, PlayerTexture[0]), () => !this.walking); + this.animations.Add(new SpriteAnimation(0.15F, PlayerTexture[1], PlayerTexture[2], PlayerTexture[3], PlayerTexture[0]), () => this.walking); + // jumping animation + this.animations.Add(new SpriteAnimation(1, PlayerTexture[0, 1]), () => this.jumpTime > TimeSpan.Zero || !this.onGround, 1); + // climbing animations + this.animations.Add(new SpriteAnimation(1, PlayerTexture[0, 2]), () => this.climbingVine && !this.walking, 2); + this.animations.Add(new SpriteAnimation(0.18F, PlayerTexture[1, 2], PlayerTexture[2, 2], PlayerTexture[3, 2], PlayerTexture[0, 2]), () => this.climbingVine && this.walking, 2); this.facingRight = true; } @@ -140,22 +146,29 @@ namespace GreatSpringGameJam { public override void Draw(GameTime time, SpriteBatch batch) { if (this.invisible) return; + var pos = this.Position * this.Map.TileSize; + + void DrawHeldItem() { + var tex = this.heldItem switch { + HeldItem.SnowBlower => StuffTexture[0, 0], + HeldItem.WateringCan => StuffTexture[2, 0], + _ => null + }; + var origin = new Vector2(tex.Width * 0.25F, tex.Height / 2); + var rot = this.GetHeldRotation(); + var flip = rot >= MathHelper.PiOver2 && rot <= MathHelper.Pi * 1.5F ? SpriteEffects.FlipVertically : SpriteEffects.None; + batch.Draw(tex, pos + this.Map.TileSize / 2, Color.White, rot, origin, 1, flip, 0); + } + + if(this.climbingVine) + DrawHeldItem(); // draw self - var pos = this.Position * this.Map.TileSize; var effects = this.facingRight ? SpriteEffects.FlipHorizontally : SpriteEffects.None; batch.Draw(this.animations.CurrentRegion, pos, Color.White, 0, Vector2.Zero, 1, effects, 0); - - // draw held item - var tex = this.heldItem switch { - HeldItem.SnowBlower => StuffTexture[0, 0], - HeldItem.WateringCan => StuffTexture[2, 0], - _ => null - }; - var origin = new Vector2(tex.Width * 0.25F, tex.Height / 2); - var rot = this.GetHeldRotation(); - var flip = rot >= MathHelper.PiOver2 && rot <= MathHelper.Pi * 1.5F ? SpriteEffects.FlipVertically : SpriteEffects.None; - batch.Draw(tex, pos + this.Map.TileSize / 2, Color.White, rot, origin, 1, flip, 0); + + if(!this.climbingVine) + DrawHeldItem(); } private float GetHeldRotation() {