Skip to content
Snippets Groups Projects
Commit 9951d2c0 authored by LABOUREL Arnaud's avatar LABOUREL Arnaud
Browse files

added gitignore

parent 184c51a2
No related branches found
No related tags found
No related merge requests found
/.gradle/
/build/
/.idea/
......@@ -9,8 +9,6 @@ import javafx.stage.Stage;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import static java.lang.Thread.sleep;
public class App extends Application {
......@@ -21,7 +19,7 @@ public class App extends Application {
}
@Override
public void start(Stage primaryStage) throws InterruptedException {
public void start(Stage primaryStage) {
Group root = new Group();
Button restart = new Button("Restart");
Button switchPause = new Button("Pause");
......@@ -41,14 +39,11 @@ public class App extends Application {
grid.repaint();
ScheduledThreadPoolExecutor threadPoolExecutor = new ScheduledThreadPoolExecutor(1);
threadPoolExecutor.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
threadPoolExecutor.scheduleAtFixedRate(() -> {
if(!isInPause) {
grid.model.activation();
grid.repaint();
}
}
}, 0, 50 , TimeUnit.MILLISECONDS);
}
}
......
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.Color;
public class Grid extends Canvas{
int width, height, colCount, rowCount;
double width;
double height;
double colCount;
double rowCount;
Model model;
......@@ -29,9 +31,6 @@ public class Grid extends Canvas{
private void mousePressed(MouseEvent mouseEvent) {
model.activation();
repaint();
/*double x = mouseEvent.getX();
double y = mouseEvent.getY();
model.click((int)x*rowCount/height,(int)y*colCount/width);*/
}
void repaint(){
......@@ -49,7 +48,7 @@ public class Grid extends Canvas{
public void paintFF(int row, int col) {
getGraphicsContext2D().setFill(Color.BLUE);
getGraphicsContext2D().fillRect(row*height/rowCount,col*width/colCount,height/rowCount,width/colCount);
getGraphicsContext2D().fillOval(row*height/rowCount,col*width/colCount,height/rowCount,width/colCount);
}
public void paintFire(int row, int col) {
......
......@@ -3,7 +3,8 @@ import java.util.*;
public class Model {
Grid grid;
int colCount, rowCount;
double colCount;
double rowCount;
List<Position> firefighters = new ArrayList<>();
Set<Position> fires = new HashSet<>();
List<Position> ffNewPositions;
......@@ -44,8 +45,8 @@ public class Model {
}
for (Position newFire : newFires)
grid.paintFire(newFire.row, newFire.col);
fires.addAll(newFires);}
fires.addAll(newFires);
}
step++;
}
......@@ -55,10 +56,8 @@ public class Model {
}
private Position activateFirefighter(Position position) {
Position randomPosition = aStepTowardFire(position);
//next(position).get((int) (Math.random()*next(position).size()));
List<Position> nextFires = next(randomPosition).stream().filter(fires::contains).toList();
extinguish(randomPosition);
for (Position fire : nextFires)
......@@ -101,5 +100,6 @@ public class Model {
return position;
}
public record Position(int row, int col){}
public record Position(int row, int col) {
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment