package xaero.rotatenjump.game.object;

import xaero.rotatenjump.game.Game;

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

public class RelativityPlatform extends Platform {

    private float gravityAngleOnAttach;
    //private static final float[] COLOUR = {0.573f, 0.153f, 0.176f, 1f};
    private static final float[] COLOUR = {0.867f, 0.106f, 0.106f, 1f};

    public RelativityPlatform(float posX, float posY, int sides, float rotation, float size, float speed) {
        super(posX, posY, sides, rotation, size, speed);
    }

    public RelativityPlatform(float posX, float posY, int sides, float rotation, float size, float fatness, float speed){
        super(posX, posY, sides, rotation, size, fatness, speed);
    }

    public RelativityPlatform(float posX, float posY, int sides, float rotation, float size, float renderBoxWidth, float renderBoxHeight, float fatness, float speed){
        super(posX, posY, sides, rotation, size, renderBoxWidth, renderBoxHeight, fatness, speed);
    }

    @Override
    public void onAttach(Game game, Player p){
        gravityAngleOnAttach = game.getGravityAngle();
    }

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

    @Override
    public void house(Game game, Player p){
        super.house(game, p);
        if(!game.gameStarted)
            return;
        float rotationSinceAttach = rotation - p.getPlatformRotationOnAttach();
        game.setGravityAngle(gravityAngleOnAttach + rotationSinceAttach);
    }

}
