Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
Firefighter template
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
WILSON Danny adjete
Firefighter template
Commits
709b8309
Commit
709b8309
authored
1 year ago
by
Danny
Browse files
Options
Downloads
Patches
Plain Diff
change1 restart on new project
code App.java code Grid.java
parent
1f1bfca0
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/Grid.java
+80
-0
80 additions, 0 deletions
src/main/java/Grid.java
with
80 additions
and
0 deletions
src/main/java/Grid.java
0 → 100644
+
80
−
0
View file @
709b8309
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
;
Model
model
;
public
Grid
(
int
width
,
int
height
,
int
colCount
,
int
rowCount
)
{
super
(
width
,
height
);
this
.
width
=
width
;
this
.
height
=
height
;
this
.
colCount
=
colCount
;
this
.
rowCount
=
rowCount
;
setFocusTraversable
(
true
);
setOnMousePressed
(
this
::
mousePressed
);
model
=
new
Model
(
this
);
model
.
initialisation
(
3
,
8
,
2
,
3
);
}
public
void
restart
(
MouseEvent
mouseEvent
){
model
=
new
Model
(
this
);
model
.
initialisation
(
3
,
6
,
2
,
3
);
getGraphicsContext2D
().
clearRect
(
0
,
0
,
width
,
height
);
repaint
();
}
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
(){
for
(
int
col
=
0
;
col
<
colCount
;
col
++)
getGraphicsContext2D
().
strokeLine
(
0
,
col
*
width
/
colCount
,
height
,
col
*
width
/
colCount
);
for
(
int
row
=
0
;
row
<
rowCount
;
row
++)
getGraphicsContext2D
().
strokeLine
(
row
*
height
/
rowCount
,
0
,
row
*
height
/
rowCount
,
width
);
}
void
paint
(
int
row
,
int
col
){
getGraphicsContext2D
().
setFill
(
Color
.
WHITE
);
getGraphicsContext2D
().
fillRect
(
row
*
height
/
rowCount
,
col
*
width
/
colCount
,
height
/
rowCount
,
width
/
colCount
);
}
public
void
paintFF
(
int
row
,
int
col
)
{
getGraphicsContext2D
().
setFill
(
Color
.
BLUE
);
getGraphicsContext2D
().
fillOval
(
row
*
height
/
rowCount
,
col
*
width
/
colCount
,
height
/
rowCount
,
width
/
colCount
);
}
public
void
paintFire
(
int
row
,
int
col
)
{
getGraphicsContext2D
().
setFill
(
Color
.
RED
);
getGraphicsContext2D
().
fillRect
(
row
*
height
/
rowCount
,
col
*
width
/
colCount
,
height
/
rowCount
,
width
/
colCount
);
}
public
void
paintCloud
(
int
row
,
int
col
){
getGraphicsContext2D
().
setFill
(
Color
.
GRAY
);
getGraphicsContext2D
().
fillRect
(
row
*
height
/
rowCount
,
col
*
width
/
colCount
,
height
/
rowCount
,
width
/
colCount
);
}
public
void
paintFFM
(
int
row
,
int
col
){
getGraphicsContext2D
().
setFill
(
Color
.
BLACK
);
getGraphicsContext2D
().
fillRect
(
row
*
height
/
rowCount
,
col
*
width
/
colCount
,
height
/
rowCount
,
width
/
colCount
);
}
/*public void paintMountain(int row, int col){
getGraphicsContext2D().setFill(Color.YELLOW);
getGraphicsContext2D().fillRect(row*height/rowCount, col*width/colCount, height/rowCount, width/colCount);
}*/
public
void
paintRoad
(
int
row
,
int
column
){
}
public
void
paintRocks
(
int
row
,
int
column
){
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment