summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSarah B <git@sarahduck.ca>2023-12-19 23:50:53 -0800
committerSarah B <git@sarahduck.ca>2023-12-19 23:50:53 -0800
commitc4dd5d6fe58a21f9cab5ce271cd3554c2fe791e3 (patch)
treeba1a204ecda939c5307498314a65e3ae2c5059ef
parent3026b6eba152a84f5e26dd094bc486f60503b94d (diff)
Animation speed properly implemented
-rw-r--r--Oneko.cs11
1 files changed, 6 insertions, 5 deletions
diff --git a/Oneko.cs b/Oneko.cs
index a75c8ca..5b28ca4 100644
--- a/Oneko.cs
+++ b/Oneko.cs
@@ -75,10 +75,11 @@ class Oneko : Drawable
Position += TargetDirection;
if (InactivityTimer > 3f) Animation = ScratchSelf;
- if (InactivityTimer > 5f) Animation = Sleep;
+ if (InactivityTimer > 5f) Animation = Yawn;
+ if (InactivityTimer > 6f) Animation = Sleep;
FrameCounter = (FrameCounter+1)%(Animation.AnimSpeed+1);
- Frame = FrameCounter/Animation.AnimSpeed;
+ Frame = (int)MathF.Round((float)FrameCounter/(float)Animation.AnimSpeed);
}
public override void Dispose()
@@ -87,9 +88,9 @@ class Oneko : Drawable
base.Dispose();
}
- struct OnekoAnimation(Rectangle frame1, Rectangle frame2, int animSpeed)
+ struct OnekoAnimation(Rectangle frame1, Rectangle frame2, byte animSpeed)
{
- public int AnimSpeed = animSpeed;
+ public byte AnimSpeed = animSpeed;
Rectangle Frame1 = frame1;
Rectangle Frame2 = frame2;
@@ -153,7 +154,7 @@ class Oneko : Drawable
static readonly OnekoAnimation Yawn = new(Yawn1, Yawn1, 1);
static readonly OnekoAnimation Clean = new(Clean1, Clean1, 1);
static readonly OnekoAnimation ScratchSelf = new(Scratch1, Scratch2, 1);
- static readonly OnekoAnimation Sleep = new(Sleep1, Sleep2, 4);
+ static readonly OnekoAnimation Sleep = new(Sleep1, Sleep2, 10);
static readonly OnekoAnimation RunUp = new(RunUp1, RunUp2, 1);
static readonly OnekoAnimation RunUpLeft = new(RunUpLeft1, RunUpLeft2, 1);
static readonly OnekoAnimation RunLeft = new(RunLeft1, RunLeft2, 1);