import { Point } from "./Point.js";
import { PongGame } from "./PongGame.js";
import { Segment } from "./Segment.js";
import { renderCube} from "../../../3D/cube.js"

export class Wall extends Segment
{

    /**
     * @param {PongGame} game
     * @param {Point} start 
     * @param {Point} stop 
     */
    constructor(game, start, stop)
    {
        super(game, start, stop)

        /**
         * @type {PongGame}
         */
        this.game = game
    }

	draw(ctx)
	{
		if(ctx instanceof CanvasRenderingContext2D)
		{
			ctx.moveTo(this.start.x, this.start.y);
			ctx.lineTo(this.stop.x, this.stop.y);
		}
		else if(ctx instanceof WebGLRenderingContext)
		{
			const size = this.game.config.BALL_SIZE * 2;
			const sizeX = this.len() / 2;
			const posX = (this.start.x - this.game.config.MAP_CENTER_X);
			const posY = (this.start.y - this.game.config.MAP_CENTER_Y);
			renderCube(ctx, posX, 0, posY, -this.angle(), sizeX, size, size);
		}
		else
		{
			alert('Unknown rendering context type');
		}
	}
}