package scene;

import java.io.FileNotFoundException;
import javafx.geometry.Point2D;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import spaceObject.spaceShip.Allied;

public class GameScene extends Scene {

	public GameScene(Group group) throws FileNotFoundException {
		super(group);

		// Main Ship
		Allied spaceShip = new Allied(group) {
		};
		spaceShip.setX(300);
		spaceShip.setY(500);

		Label label = new Label();
		group.getChildren().add(label);

		addEventHandler(KeyEvent.KEY_PRESSED, e -> {
			if (e.getCode() == KeyCode.A) {
				spaceShip.setMovePoint2d(new Point2D(-1, 0));
			}
			if (e.getCode() == KeyCode.D) {
				spaceShip.setMovePoint2d(new Point2D(1, 0));
			}
			if (e.getCode() == KeyCode.W) {
				spaceShip.setMovePoint2d(new Point2D(0, -1));
			}
			if (e.getCode() == KeyCode.S) {
				spaceShip.setMovePoint2d(new Point2D(0, 1));
			}
			if (e.getCode() == KeyCode.SPACE) {
				spaceShip.shoot(new Point2D(0, -1));
			}
		});
		addEventHandler(KeyEvent.KEY_RELEASED, e -> {
			if (e.getCode() == KeyCode.A || e.getCode() == KeyCode.D || e.getCode() == KeyCode.W
					|| e.getCode() == KeyCode.S) {
				spaceShip.setMovePoint2d(new Point2D(0, 0));
			}
		});

		new GameUpdater(group, spaceShip);
	}

}
