package xaero.rotatenjump.game.object;

import xaero.rotatenjump.game.Game;
import xaero.rotatenjump.game.graphics.Graphics;
import xaero.rotatenjump.game.graphics.model.Kunai2D;
import xaero.rotatenjump.game.graphics.model.Model;
import xaero.rotatenjump.misc.Transformations;

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

public class Accelerator extends Entity {
    public static final float ACCELERATOR_SIZE = 30;
    private static final float[] COLOUR = {0.59f, 0.56f, 0, 0.59f};
    private static final Model KUNAI = new Kunai2D();

    private float angle;
    private float strength;

    public Accelerator(float posX, float posY, float angle, float strength) {
        super(posX, posY, ACCELERATOR_SIZE, ACCELERATOR_SIZE, ACCELERATOR_SIZE / 2);
        this.angle = angle;
        this.strength = strength;
    }

    @Override
    public void render(Game game, float partialTicks){
        Graphics.color = COLOUR;
        Graphics.SPHERE5_10.draw(posXRender, posYRender, 0, 0, 0, 3, 3, 3);
        Graphics.modelsLoadedFromFiles[3].draw(posXRender, posYRender, angle, 0, 0, ACCELERATOR_SIZE, ACCELERATOR_SIZE, ACCELERATOR_SIZE);
    }

    @Override
    public boolean isCollidingWith(Player player, float distance, float[][] points, float collisionPartial) {
        return distance < Accelerator.ACCELERATOR_SIZE / 2 || super.isCollidingWith(player, distance, points, collisionPartial);
    }

    @Override
    public void collide(Player player, float[][] points) {
        super.collide(player, points);
        Transformations.rotate(strength, 0, angle, updateVector2);
        player.velocityX += updateVector2[0];
        player.velocityY += updateVector2[1];
        goThrough = 3;
    }
}
