From c2acdd9fadde7295757760953317d7a06e57b223 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 13 Mar 2021 16:59:36 +0100 Subject: [PATCH] added climbing and jumping animations --- .../Content/Textures/Player.aseprite | Bin 997 -> 1194 bytes .../Content/Textures/Player.png | Bin 487 -> 772 bytes GreatSpringGameJam/Player.cs | 41 ++++++++++++------ 3 files changed, 27 insertions(+), 14 deletions(-) diff --git a/GreatSpringGameJam/Content/Textures/Player.aseprite b/GreatSpringGameJam/Content/Textures/Player.aseprite index b7895e6c348c17765fe7cc88ec7b7d48d345d06e..2f171800dfca86806150db6cb87865a32473fddf 100644 GIT binary patch delta 485 zcmaFLzKWB36$=BygQYAC0t^Ndxl0)jPHg-ke}aL5fmMNlfrWvQ;Xf0Q0|p!n`V19w zk`o*zUuV*+7uM!qH1TT8>F}TYhi*KXy?xfd@HrX0#}o=n_8M5GnErTj@$m60MHlN+ zdVJ-iXGi?>*#GDMjT;IJbf5l}Z@GB$3ftnB&1Nr|V|nKG%iT9HjEH&Ml^=AOQTMU9 z*u5Kv=1s8KB~|n3#uEpI`EfJqBK9P8?>{)_zaxX?x`{U#4)Awsai0Y`>eoj`h7=&p z2*i7V802VHAdPS|JA?k@0_ME<*>^M~_BGu4$v@5f!e>r9%aY2Nq8E=88oc>^Z zd~WFVS>8&TWx{8EJIk0#fmm4vz6OR1$AD%b+p!I92U@^PzQ~jx-rp4Hz_lRtU;9(n zoS)Ose6Z8t$|rjch3A!D{_rzc>}3Ca4b5zjU64RWc0VW3{klvgmO!%&E;PhF<=6TD zSWCYnuz6kI1gV%$3JxcDW>{|6)H&@bzYnjOnV#v6Q-V*7IHpV0qzW)JrE#_Z0G33n A3IG5A delta 205 zcmZ3*`IMdeDKi7ZgQYAC0t^BZxl0*aCN}U7k@Aa1^@s6p-X%p00001b5ch_0Itp)=>Px%zDYzuRA_8m@ISEiz=ZxXXe@Ax!lcn5k&v3S1!D=$b*?tAx_6)yY z-_s5E>Q@$ko50TLaRdM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); + 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() {