geezer12
12-28-2005, 06:39 AM
Hey,
I am making a snakes and ladders board game, so far:
I have a created a board using GDI+ consisting of 100 squares.
Two dice creating random numbers when a button is clicked.
I have a couple of questions:
I have created my board inside one panel is this correct? Or shall I created 100 panels instead, this way would seem easier to me.
Another problem is that I cannot find a way of getting my board to include data, like which ones hold snakes/ladders and how to move the counters to the corresponding squares when a dice is rolled. My counters do not need to be animated, just moved to each square.
I think I need to create an array to hold the data for the squares, but I have done this to draw the board. This is my code I have put inside the panel to create the board.
Dim Square As New SizeF(0.075F * Me.ClientRectangle.Width, 0.075F * Me.ClientRectangle.Height)
Dim solidb As New SolidBrush(Color.White)
Dim toggle As Boolean = False
Dim y As Integer
For y = 0 To 9
Dim x As Integer
For x = 0 To 9
If toggle Then
solidb.Color = Color.Red
Else
solidb.Color = Color.Black
End If
Dim rect As New RectangleF(x * Square.Width, y * Square.Height, Square.Width, Square.Height)
e.Graphics.FillRectangle(solidb, rect)
toggle = Not toggle
Next x
toggle = Not toggle
Next y
solidb.Dispose()
Thanks in advance,
G
I am making a snakes and ladders board game, so far:
I have a created a board using GDI+ consisting of 100 squares.
Two dice creating random numbers when a button is clicked.
I have a couple of questions:
I have created my board inside one panel is this correct? Or shall I created 100 panels instead, this way would seem easier to me.
Another problem is that I cannot find a way of getting my board to include data, like which ones hold snakes/ladders and how to move the counters to the corresponding squares when a dice is rolled. My counters do not need to be animated, just moved to each square.
I think I need to create an array to hold the data for the squares, but I have done this to draw the board. This is my code I have put inside the panel to create the board.
Dim Square As New SizeF(0.075F * Me.ClientRectangle.Width, 0.075F * Me.ClientRectangle.Height)
Dim solidb As New SolidBrush(Color.White)
Dim toggle As Boolean = False
Dim y As Integer
For y = 0 To 9
Dim x As Integer
For x = 0 To 9
If toggle Then
solidb.Color = Color.Red
Else
solidb.Color = Color.Black
End If
Dim rect As New RectangleF(x * Square.Width, y * Square.Height, Square.Width, Square.Height)
e.Graphics.FillRectangle(solidb, rect)
toggle = Not toggle
Next x
toggle = Not toggle
Next y
solidb.Dispose()
Thanks in advance,
G