
import * as c from "./constants.js";
import { MovingRectangle } from "../shared_js/class/Rectangle.js";
import { GameComponents } from "./class/GameComponents.js";

function wallsMovements(delta: number, gc: GameComponents)
{
	const wallTop = <MovingRectangle>gc.wallTop;
	const wallBottom = <MovingRectangle>gc.wallBottom;
	if (wallTop.pos.y <= 0 || wallTop.pos.y >= c.movingWallPosMax) {
		wallTop.dir.y *= -1;
	}
	if (wallBottom.pos.y >= c.h-c.wallSize || wallBottom.pos.y <= c.h-c.movingWallPosMax) {
		wallBottom.dir.y *= -1;
	}
	wallTop.moveAndCollide(delta, [gc.playerLeft, gc.playerRight]);
	wallBottom.moveAndCollide(delta, [gc.playerLeft, gc.playerRight]);
}

export {wallsMovements}
