package xaero.rotatenjump.game.object;

import xaero.rotatenjump.game.Game;
import xaero.rotatenjump.game.graphics.Graphics;

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

public class NinjaStarCut extends EntityWithVelocity {

    private int halfId;
    private float rotationZ;
    private float rotationZRender;
    private float lastRotationZRender;

    public NinjaStarCut(float posX, float posY, float velocityX, float velocityY, float velocityZ, float rotationZ, int halfId) {
        super(posX, posY, Player.PLAYER_RADIUS, Player.PLAYER_RADIUS, Player.PLAYER_RADIUS / 2);//fatness is just random here
        this.halfId = halfId;
        this.rotationZRender = this.rotationZ = rotationZ;
        this.velocityX = velocityX;
        this.velocityY = velocityY;
        this.velocityZ = velocityZ;
    }

    @Override
    public void preUpdate() {
        super.preUpdate();
    }

    @Override
    public void update(Game game){
        velocityX += game.getDirectedGravityX();//gravity
        velocityY += game.getDirectedGravityY();//gravity
        fixVelocity();
        applyVelocity();
        rotationZ += 10;
    }

    @Override
    public void refresh() {
        super.refresh();
        lastRotationZRender = rotationZRender;
        rotationZRender = rotationZ;
    }

    @Override
    public void render(Game game, float partialTicks) {
        Graphics.color = Graphics.DKGRAY;
        Graphics.modelsLoadedFromFiles[halfId].draw((lastPosXRender + (posXRender - lastPosXRender) * partialTicks), lastPosYRender + (posYRender - lastPosYRender) * partialTicks, lastPosZRender + (posZRender - lastPosZRender) * partialTicks, lastRotationZRender + (rotationZRender - lastRotationZRender) * partialTicks, 0, 0, Player.PLAYER_RADIUS, Player.PLAYER_RADIUS, Player.PLAYER_RADIUS);
        //Graphics.color = Graphics.WHITE;

        /* super.render(canvas, paint, partialTicks);
        SimpleGraphics.push(canvas);
        paint.setColor(Color.RED);
        SimpleGraphics.scaledTranslate(canvas, (lastPosX + (posX - lastPosX) * partialTicks), lastPosY + (posY - lastPosY) * partialTicks);
        SimpleGraphics.scaledCircle(canvas, paint, COIN_SIZE);
        paint.setColor(Color.BLACK);
        SimpleGraphics.pop(canvas);*/
    }

}
