added improvements to tile attribution and javaFX application

master
Cemal Odabasioglu 2022-04-13 17:14:34 +02:00
parent ab53bdc999
commit 3e6530a90a
2 changed files with 53 additions and 11 deletions

View File

@ -14,25 +14,38 @@ public class LaticeApplicationConsole {
Tile blueBird = new Tile(Color.BLUE, Shape.BIRD);
Tile greenLeaf = new Tile(Color.GREEN, Shape.LEAF);
Tile redFlower = new Tile(Color.RED, Shape.FLOWER);
ArrayList<Tile> rackPlayer1 = new ArrayList<Tile>();
ArrayList<Tile> rackPlayer2 = new ArrayList<Tile>();
int tilesNumber = 3;
ArrayList<Tile> tiles =new ArrayList<Tile>(Arrays.asList(redFlower, greenLeaf, redFlower));
ArrayList<Tile> tiles =new ArrayList<Tile>(Arrays.asList(blueBird, greenLeaf, redFlower));
System.out.println("Hello Latice ! " + blueBird.getShape() + blueBird.getColor());
System.out.println("Hello Latice ! " + greenLeaf.getShape() + greenLeaf.getColor());
System.out.println("Hello Latice ! " + redFlower.getShape() + redFlower.getColor());
System.out.println("Hello Latice ! " + tiles.get(0).getShape() + tiles.get(0).getColor());
//------------------------------Attribution des tuiles-----------------------------------
//------------------------------Tiles attribution-----------------------------------
Random random = new Random();
for(int i=0; i<2; i++) {
int randomNumber = random.nextInt(3);
Tile[] rackPlayer1 = {tiles.get(randomNumber), tiles.get(randomNumber)};;
for(int i=0; i<=tilesNumber; i++) {
if(! tiles.isEmpty()) {
int randomNumber = random.nextInt(tiles.size());
if(i%2 == 0) {
rackPlayer1.add(tiles.get(randomNumber));
System.out.println(rackPlayer1.get(0).getColor().toString() + rackPlayer1.get(0).getShape().toString());
} else {
rackPlayer2.add(tiles.get(randomNumber));
System.out.println(rackPlayer2.get(0).getColor().toString() + rackPlayer2.get(0).getShape().toString());
}
for(int i=0; i<2; i++) {
int randomNumber = random.nextInt(3);
Tile[] rackPlayer2 = {tiles.get(randomNumber), tiles.get(randomNumber)};
tiles.remove(randomNumber);
System.out.println(randomNumber);
System.out.println(rackPlayer1);
System.out.println(rackPlayer2);
}
}
}
}

View File

@ -3,20 +3,30 @@ package latice.application;
import java.io.File;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import latice.model.Color;
import latice.model.Shape;
import latice.model.Tile;
public class LaticeApplicationWindow extends Application{
Image image = new Image("C:/Users/cemal/saebut1/latice/src/main/resources/laticePlateau.png");
ImageView imageView = new ImageView(image);
Tile blueBird = new Tile(Color.BLUE, Shape.BIRD);
Tile greenLeaf = new Tile(Color.GREEN, Shape.LEAF);
Tile redFlower = new Tile(Color.RED, Shape.FLOWER);
public static void main(String[] args) {
Application.launch(args);
@ -27,13 +37,32 @@ public class LaticeApplicationWindow extends Application{
BorderPane root = new BorderPane();
Text title = new Text("Latice");
title.setFont(new Font(20));
title.setFont(new Font(30));
root.setTop(title);
root.setAlignment(title, Pos.CENTER);
//Image
root.setCenter(imageView);
Scene scene = new Scene(root, 1280, 720);
//Rack
HBox rack = new HBox();
rack.setSpacing(10);
rack.setPadding(new Insets(15,20, 10,10));
Text rackTile1 = new Text();
rackTile1.setText(blueBird.getShape().toString() + blueBird.getColor());
Text rackTile2 = new Text();
rackTile2.setText(greenLeaf.getShape().toString() + greenLeaf.getColor());
Text rackTile3 = new Text();
rackTile3.setText(redFlower.getShape().toString() + redFlower.getColor());
rack.getChildren().addAll(rackTile1, rackTile2, rackTile3);
rack.setAlignment(Pos.CENTER);
root.setBottom(rack);
Scene scene = new Scene(root, 1280, 720);
primaryStage.setTitle("Latice");
primaryStage.setScene(scene);