package xaero.rotatenjump.game.object;

import xaero.rotatenjump.game.Game;

/**
 * Created by xaero on 06/07/2017.
 */

public class RotatingOnTouchWall extends Wall {

    private static final float[] COLOUR = {1f, 0.4f, 0.27f, 1f};
    private boolean rotating;

    public RotatingOnTouchWall(float posX, float posY, float rotation, float width, float height, float speed){
        super(posX, posY, rotation, width, height, speed);
        rotating = false;
    }

    @Override
    protected float[] getColour(){
        return COLOUR;
    }

    @Override
    public void update(Game game) {
        super.update(game);
        if(!rotating)
            rotation -= speed;//cancel out
    }

    @Override
    public void onAttach(Game game, Player p) {
        super.onAttach(game, p);
        if(attachSide % 2 == 0)
            rotating = true;
    }

    @Override
    public void onDettach(Player p) {
        rotating = false;
        super.onDettach(p);
    }
}
