Randomly moving buns

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 2 years ago
parent 71a9bd0871
commit 445a6c16ea
  1. 25
      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;
}
}

Loading…
Cancel
Save