Create a JavaFX GUI that represents the streets of Pamplona. You do not need to
ID: 3606954 • Letter: C
Question
Create a JavaFX GUI that represents the streets of Pamplona. You do not need to consult an actual map of Pamplona, although you may if you want to.
Do the styling (coding of the details of the appearance of the GUI, such as colors and font sizes) using CSS, not the JavaFX setters, wherever possible. Make the start and finish squares appear different from other squares.
Grading for this lab will heavily weight the appearance of the GUI as well as its functionality. To get a good grade on this assignment, your GUI must both work correctly and look good.
Here are some of the classes you will need. This is not a complete list, and each class will need more than the basics I specify below:
A Coordinate class with an int row, an int column, and a char representing the value of the coordinate (this week, you will use four values for the Coordinates: blank (' ') for an empty space, W for a wall, S for the starting point, and E for the exit.) Provide getters and setters.
A StreetMap class with a two-dimensional array of Coordinates but no GUI code.
A JavaFX GUI class called MazeGUIPane. Since the constructor for Scene takes a Pane as a parameter, this class should extend one of the Pane classes, most likely BorderPane. It should also contain a GridPane with a two-dimensional grid of Labels. One label in the GridPane corresponds to one Coordinate in the StreetMap. Note this important distinction: the MazeGUIPane is for the the user interface while the StreetMap is for data.
The outer edges of the grid should consist of walls, except for one starting square and one exit square. When the game starts, squares that are not on the edges should be randomly set to wall and space squares (use about 20% walls.) Note that this does not guarantee that it is possible to escape the bulls at all.
You will also need a game reset button In my solution, this button is in an HBox contained in the MazeGUIPane.
Map Of Pamplona RunExplanation / Answer
Option Base 1
Dim c(10) As Variant
Dim r(10) As Variant
Dim x As Integer
Dim m As Integer
Dim n As Integer
Dim num As Integer
Dim tnum As Single
Dim tnum1 As Single
Dim player As Integer
Dim t As Integer
Private Sub Command2_Click()
'To move the pieces to the original position
Image1(0).Move 10200, 5520
Image1(1).Move 10200, 6480
tnum = 0
tnum1 = 0
Label2.Caption = ""
MMControl1.Command = "close"
End Sub
Private Sub Command3_Click()
End
End Sub
Private Sub Form_Load()
' To assign the column and row coordinates to all the boxes
c(1) = 600
r(1) = 8200
For i = 1 To 9
c(i + 1) = c(i) + 800
Next
For j = 1 To 9
r(j + 1) = r(j) - 800
Next
End Sub
'To initiate the rolling of dice
Private Sub roll()
x = x + 10
Randomize Timer
n = Int(1 + Rnd * 6)
For i = 0 To 6
Shape1(i).Visible = False
Next
If n = 1 Then
Shape1(3).Visible = True
Shape2.FillColor = &HC0C0C0
End If
If n = 2 Then
Shape1(2).Visible = True
Shape1(4).Visible = True
Shape2.FillColor = &H8080FF
End If
If n = 3 Then
Shape1(2).Visible = True
Shape1(3).Visible = True
Shape1(4).Visible = True
Shape2.FillColor = &H80FF&
End If
If n = 4 Then
Shape1(0).Visible = True
Shape1(2).Visible = True
Shape1(4).Visible = True
Shape1(6).Visible = True
Shape2.FillColor = &HFFFF00
End If
If n = 5 Then
Shape1(0).Visible = True
Shape1(2).Visible = True
Shape1(3).Visible = True
Shape1(4).Visible = True
Shape1(6).Visible = True
Shape2.FillColor = &HFFFF&
End If
If n = 6 Then
Shape1(0).Visible = True
Shape1(1).Visible = True
Shape1(2).Visible = True
Shape1(4).Visible = True
Shape1(5).Visible = True
Shape1(6).Visible = True
Shape2.FillColor = &HFF00FF
End If
End Sub
Private Sub Command1_Click(Index As Integer)
'To indentify which player click the roll dice command
If Index = 0 Then
player = 1
End If
If Index = 1 Then
player = 2
End If
Timer1.Enabled = True
x = 0
End Sub
Private Sub Timer1_Timer()
If x < 100 Then
Call roll
Else
Timer1.Enabled = False
'To check the number on the dice
If Shape1(3).Visible = True Then
num = 1
End If
If (Shape1(2).Visible = True) And (Shape1(4).Visible = True) Then
num = 2
End If
If (Shape1(2).Visible = True) And (Shape1(3).Visible = True) And (Shape1(4).Visible = True) Then
num = 3
End If
If (Shape1(0).Visible = True) And (Shape1(2).Visible = True) And (Shape1(4).Visible = True) And (Shape1(6).Visible = True) Then
num = 4
End If
If (Shape1(0).Visible = True) And (Shape1(2).Visible = True) And (Shape1(3).Visible = True) And (Shape1(4).Visible = True) And (Shape1(6).Visible = True) Then
num = 5
End If
If (Shape1(0).Visible = True) And (Shape1(1).Visible = True) And (Shape1(2).Visible = True) And (Shape1(4).Visible = True) And (Shape1(5).Visible = True) Then
num = 6
End If
'To move player 1 according to the total score of the dice
If player = 1 Then
tnum = tnum + num
If tnum < 11 Then
Image1(0).Move c(tnum), r(1)
If tnum = 10 Then
Image1(0).Move c(8), r(3)
tnum = 28
End If
End If
If tnum > 10 And tnum < 21 Then
Image1(0).Move c(21 - tnum), r(2)
If tnum = 17 Then
Image1(0).Move c(4), r(4)
tnum = 37
End If
End If
If tnum > 20 And tnum < 31 Then
Image1(0).Move c(tnum - 20), r(3)
End If
If tnum > 30 And tnum < 41 Then
Image1(0).Move c(41 - tnum), r(4)
If tnum = 34 Then
Image1(0).Move c(5), r(2)
tnum = 16
End If
If tnum = 31 Then
Image1(0).Move c(10), r(7)
tnum = 70
End If
End If
If tnum > 40 And tnum < 51 Then
Image1(0).Move c(tnum - 40), r(5)
If tnum = 45 Then
Image1(0).Move c(4), r(9)
tnum = 84
End If
If tnum = 44 Then
Image1(0).Move c(1), r(3)
tnum = 21
End If
End If
If tnum > 50 And tnum < 61 Then
Image1(0).Move c(61 - tnum), r(6)
End If
If tnum > 60 And tnum < 71 Then
Image1(0).Move c(tnum - 60), r(7)
If tnum = 68 Then
Image1(0).Move c(8), r(5)
tnum = 48
End If
End If
If tnum > 70 And tnum < 81 Then
Image1(0).Move c(81 - tnum), r(8)
If tnum = 79 Then
Image1(0).Move c(2), r(6)
tnum = 59
End If
If tnum = 78 Then
Image1(0).Move c(4), r(10)
tnum = 97
End If
End If
If tnum > 80 And tnum < 91 Then
Image1(0).Move c(tnum - 80), r(9)
End If
If tnum > 90 And tnum < 101 Then
Image1(0).Move c(101 - tnum), r(10)
If tnum = 95 Then
Image1(0).Move c(8), r(8)
tnum = 73
End If
End If
If tnum > 100 Or tnum = 100 Then
Image1(0).Move c(1), r(10)
End If
End If
'To move player 2 according to the total score of the dice
If player = 2 Then
tnum1 = tnum1 + num
If tnum1 < 11 Then
Image1(1).Move c(tnum1), r(1)
If tnum1 = 10 Then
Image1(1).Move c(8), r(3)
tnum1 = 28
End If
End If
If tnum1 > 10 And tnum1 < 21 Then
Image1(1).Move c(21 - tnum1), r(2)
If tnum1 = 17 Then
Image1(1).Move c(4), r(4)
tnum1 = 37
End If
End If
If tnum1 > 20 And tnum1 < 31 Then
Image1(1).Move c(tnum1 - 20), r(3)
End If
If tnum1 > 30 And tnum1 < 41 Then
Image1(1).Move c(41 - tnum1), r(4)
If tnum1 = 34 Then
Image1(1).Move c(5), r(2)
tnum1 = 16
End If
If tnum1 = 31 Then
Image1(1).Move c(10), r(7)
tnum1 = 70
End If
End If
If tnum1 > 40 And tnum1 < 51 Then
Image1(1).Move c(tnum1 - 40), r(5)
If tnum1 = 45 Then
Image1(1).Move c(4), r(9)
tnum1 = 84
End If
If tnum1 = 44 Then
Image1(1).Move c(1), r(3)
tnum1 = 21
End If
End If
If tnum1 > 50 And tnum1 < 61 Then
Image1(1).Move c(61 - tnum1), r(6)
End If
If tnum1 > 60 And tnum1 < 71 Then
Image1(1).Move c(tnum1 - 60), r(7)
If tnum1 = 68 Then
Image1(1).Move c(8), r(5)
tnum1 = 48
End If
End If
If tnum1 > 70 And tnum1 < 81 Then
Image1(1).Move c(81 - tnum1), r(8)
If tnum1 = 79 Then
Image1(1).Move c(2), r(6)
tnum1 = 59
End If
If tnum1 = 78 Then
Image1(1).Move c(4), r(10)
tnum1 = 97
End If
End If
If tnum1 > 80 And tnum1 < 91 Then
Image1(1).Move c(tnum1 - 80), r(9)
End If
If tnum1 > 90 And tnum1 < 101 Then
Image1(1).Move c(101 - tnum1), r(10)
If tnum1 = 95 Then
Image1(1).Move c(8), r(8)
tnum1 = 73
End If
End If
If tnum1 > 100 Or tnum1 = 100 Then
Image1(1).Move c(1), r(10)
End If
End If
'To play the sound when any one player reach 100
If (tnum > 100 Or tnum = 100) And tnum1 < 100 Then
Label2.Caption = "Player 1 Wins"
MMControl1.Notify = False
MMControl1.Wait = True
MMControl1.Shareable = False
MMControl1.DeviceType = "WaveAudio"
MMControl1.FileName = "C:mohiniVB programudiopause.wav"
MMControl1.Command = "Open"
MMControl1.Command = "Play"
End If
If (tnum1 > 100 Or tnum1 = 100) And tnum < 100 Then
Label2.Caption = "Player 2 Wins"
MMControl1.Notify = False
MMControl1.Wait = True
MMControl1.Shareable = False
MMControl1.DeviceType = "WaveAudio"
MMControl1.FileName = "C:mohiniVB programudiopause.wav"
MMControl1.Command = "Open"
MMControl1.Command = "Play"
End If
End If
End Sub
Private Sub Timer2_Timer()
delay
If t < 1000 Then
Else
Timer2.Enabled = False
End If
End Sub
Sub delay()
t = t + 1
End Sub