package sig.objects;

import sig.RabiClone;
import sig.engine.Rectangle;
import sig.engine.Sprite;
import sig.engine.Transform;
import sig.objects.actor.PhysicsObject;
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);
        setY(y);
        setAccelerationLimits(100, 100);
        setVelocityLimits(246, 500);
        setGroundDrag(2000);
        setGroundFriction(PhysicsObject.NORMAL_FRICTION);
        setAirDrag(800);
        setAirFriction(180);
        setSlidingVelocity(164);
        setSlidingAcceleration(120);
        setJumpVelocity(PhysicsObject.NORMAL_JUMP_VELOCITY);
    }

    @Override
    public Rectangle setCollisionBounds() {
        return new Rectangle(12,4,24,38);
    }

    @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
    public void draw(byte[] p) {
    }

    @Override
    public Transform getSpriteTransform() {
        return Transform.NONE;
    }

    @Override
    public boolean rightKeyHeld() {
        return moveTimer>0&&moveDir;
    }

    @Override
    public boolean leftKeyHeld() {
        return moveTimer>0&&!moveDir;
    }
}
