Skip to content
Snippets Groups Projects
Commit 7adbe31a authored by Alexis BUSSENEAU's avatar Alexis BUSSENEAU
Browse files

Add graphic class

parent f950c07d
No related branches found
No related tags found
No related merge requests found
Pipeline #
package controller;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Pane;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.net.URL;
import java.util.ResourceBundle;
import model.Board;
public class GameController implements Initializable {
/* ----- FXML ATTRIBUTES ----- */
@FXML
private GridPane board;
@FXML
private Label levelNumber;
/* ----- ATTRIBUTES ----- */
/**
*
*/
private static final String LEVELS_FILE = "data/levels.txt";
/**
*
*/
private BufferedReader br;
/**
* The model of the controller.
*/
private Board model;
public GameController() {
try {
br = new BufferedReader( new FileReader(LEVELS_FILE) );
String[] line = br.readLine().split(" ");
model = new Board(Integer.valueOf(line[0]), Integer.valueOf(line[1]));
} catch (IOException e) {
e.printStackTrace();
}
}
@Override
public void initialize(URL location, ResourceBundle resources) {
board.setGridLinesVisible(true);
double size = 300.0 / model.getSize();
Pane cell;
boolean tmp = true;
for (int i = 0; i < model.getSize(); i++)
for (int j = 0; j < model.getSize(); j++) {
cell = new Pane();
cell.setPrefSize(size, size);
board.add(cell, i, j);
}
}
}
package main;
public class Main {
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public static void main(String[] args) {
System.out.println("Hi! I'm a super intelligent AI");
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load( getClass().getResource("../view/Game.fxml") );
primaryStage.setTitle("Rush Pascal");
primaryStage.setResizable(false);
primaryStage.setScene( new Scene(root, 320, 350) );
primaryStage.show();
primaryStage.centerOnScreen();
}
public static void main(String[] args) {
launch(args);
}
}
......@@ -26,6 +26,12 @@ public class Board {
//getAllPossibleMoves();
public int getSize() {
return board.length;
}
public int getCarsNumber() {
return cars.length;
}
}
package view;
public class Controller {
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment