summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Oneko.cs47
1 files changed, 25 insertions, 22 deletions
diff --git a/Oneko.cs b/Oneko.cs
index 742d8c0..a75c8ca 100644
--- a/Oneko.cs
+++ b/Oneko.cs
@@ -14,6 +14,7 @@ class Oneko : Drawable
float updateTimer = 0f;
const float updateRate = 1f/5f;
int Frame = 0;
+ int FrameCounter = 0;
float InactivityTimer = 0f;
@@ -73,10 +74,11 @@ class Oneko : Drawable
else Animation = Idle;
Position += TargetDirection;
- Frame = (Frame + 1) % 2;
-
if (InactivityTimer > 3f) Animation = ScratchSelf;
if (InactivityTimer > 5f) Animation = Sleep;
+
+ FrameCounter = (FrameCounter+1)%(Animation.AnimSpeed+1);
+ Frame = FrameCounter/Animation.AnimSpeed;
}
public override void Dispose()
@@ -85,9 +87,10 @@ class Oneko : Drawable
base.Dispose();
}
- struct OnekoAnimation(Rectangle frame1, Rectangle frame2)
+ struct OnekoAnimation(Rectangle frame1, Rectangle frame2, int animSpeed)
{
- public Rectangle Frame1 = frame1;
+ public int AnimSpeed = animSpeed;
+ Rectangle Frame1 = frame1;
Rectangle Frame2 = frame2;
public readonly Rectangle GetFrame(int frame) {
@@ -145,24 +148,24 @@ class Oneko : Drawable
static readonly Rectangle ScratchRight1 = new(32*2, 32*2, 32, 32);
static readonly Rectangle ScratchRight2 = new(32*2, 32*3, 32, 32);
- static readonly OnekoAnimation Idle = new(Idle1, Idle1);
- static readonly OnekoAnimation Alert = new(Alert1, Alert1);
- static readonly OnekoAnimation Yawn = new(Yawn1, Yawn1);
- static readonly OnekoAnimation Clean = new(Clean1, Clean1);
- static readonly OnekoAnimation ScratchSelf = new(Scratch1, Scratch2);
- static readonly OnekoAnimation Sleep = new(Sleep1, Sleep2);
- static readonly OnekoAnimation RunUp = new(RunUp1, RunUp2);
- static readonly OnekoAnimation RunUpLeft = new(RunUpLeft1, RunUpLeft2);
- static readonly OnekoAnimation RunLeft = new(RunLeft1, RunLeft2);
- static readonly OnekoAnimation RunDownLeft = new(RunDownLeft1, RunDownLeft2);
- static readonly OnekoAnimation RunDown = new(RunDown1, RunDown2);
- static readonly OnekoAnimation RunDownRight = new(RunDownRight1, RunDownRight2);
- static readonly OnekoAnimation RunRight = new(RunRight1, RunRight2);
- static readonly OnekoAnimation RunUpRight = new(RunUpRight1, RunUpRight2);
- static readonly OnekoAnimation ScratchUp = new(ScratchUp1, ScratchUp2);
- static readonly OnekoAnimation ScratchLeft = new(ScratchLeft1, ScratchLeft2);
- static readonly OnekoAnimation ScratchDown = new(ScratchDown1, ScratchDown2);
- static readonly OnekoAnimation ScratchRight = new(ScratchRight1, ScratchRight2);
+ static readonly OnekoAnimation Idle = new(Idle1, Idle1, 1);
+ static readonly OnekoAnimation Alert = new(Alert1, Alert1, 1);
+ 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 RunUp = new(RunUp1, RunUp2, 1);
+ static readonly OnekoAnimation RunUpLeft = new(RunUpLeft1, RunUpLeft2, 1);
+ static readonly OnekoAnimation RunLeft = new(RunLeft1, RunLeft2, 1);
+ static readonly OnekoAnimation RunDownLeft = new(RunDownLeft1, RunDownLeft2, 1);
+ static readonly OnekoAnimation RunDown = new(RunDown1, RunDown2, 1);
+ static readonly OnekoAnimation RunDownRight = new(RunDownRight1, RunDownRight2, 1);
+ static readonly OnekoAnimation RunRight = new(RunRight1, RunRight2, 1);
+ static readonly OnekoAnimation RunUpRight = new(RunUpRight1, RunUpRight2, 1);
+ static readonly OnekoAnimation ScratchUp = new(ScratchUp1, ScratchUp2, 1);
+ static readonly OnekoAnimation ScratchLeft = new(ScratchLeft1, ScratchLeft2, 1);
+ static readonly OnekoAnimation ScratchDown = new(ScratchDown1, ScratchDown2, 1);
+ static readonly OnekoAnimation ScratchRight = new(ScratchRight1, ScratchRight2, 1);
static readonly Dictionary<Vector2, OnekoAnimation> RunDirections = new() {
{Directions.Up, RunUp},