From 445a6c16eac95183d9802136788f963df4756aa4 Mon Sep 17 00:00:00 2001 From: sigonasr2 Date: Tue, 14 Jun 2022 20:36:33 -0500 Subject: [PATCH] Randomly moving buns Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 --- src/sig/objects/Erinoah.java | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/sig/objects/Erinoah.java b/src/sig/objects/Erinoah.java index 38fbdc1..3c4601b 100644 --- a/src/sig/objects/Erinoah.java +++ b/src/sig/objects/Erinoah.java @@ -9,6 +9,10 @@ import sig.objects.actor.RenderedObject; public class Erinoah extends PhysicsObject implements RenderedObject{ + double lastMoved = 0; + boolean moveDir = false; + double moveTimer = 0; + public Erinoah(double x, double y) { super(Sprite.ERINOAH,6.5,RabiClone.p); setX(x); @@ -32,6 +36,23 @@ public class Erinoah extends PhysicsObject implements RenderedObject{ @Override public void update(double updateMult) { super.update(updateMult); + lastMoved+=updateMult; + if (lastMoved>5) { + switch ((int)(Math.random()*3)) { + case 0:{ + moveDir=true; + moveTimer=Math.random()*3; + }break; + case 1:{ + moveDir=false; + moveTimer=Math.random()*3; + }break; + case 2:{ + lastMoved=0; + }break; + } + } + moveTimer-=updateMult; } @Override @@ -45,11 +66,11 @@ public class Erinoah extends PhysicsObject implements RenderedObject{ @Override public boolean rightKeyHeld() { - return false; + return moveTimer>0&&moveDir; } @Override public boolean leftKeyHeld() { - return false; + return moveTimer>0&&!moveDir; } }