I'm building a board game. The game is played on a 4 by 4 grid in pairs, one player at a time. I would really appreciate if you could help me with this. Please help me. I'm new to Visual Basics. It has been only 1 month since I started learnig VB.
I'm using Visual Basics 2010:
A player generates two random numbers and colours in an area on the grid indicated by the numbers. For example if the generated number is a 2 and a 3 the player clicks in the 2x3 square which results in the colour of the square being changed.
A player should only be able to click and change the colour of the square represented by the random numbers only.
At the start of the game, the initial score should have a value of 0. With each square coloured the score increases by the product of two numbers. You can display the score anywhere within the user interface.
The game should maintain the time taken to colour all the squares. Hence, when a player starts the game the timer should also start. You can display the time anywhere within the user interface.
The game should end in two ways. They include: a. A player generating the same random numbers in three consecutive attempts b. A player colouring all the squares
The second player should be able to play the game without closing the whole application. When the game ends for the second player, the winner should be announced. The winner should be the one who scores the highest within the least amount of time. If a player has the highest score but takes the highest time, then the game is considered a tie. Hence, display a message saying it is a tie. Sp far this is what I got:
Public Class Form1
Private randomRow As Integer
Private randomCol As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Shared random As New Random()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim i As Integer
For i = 0 To 5
TextBox1.Text = (Convert.ToString(random.Next(1, 5)))
TextBox2.Text = (Convert.ToString(random.Next(1, 5)))
Next
End Sub
Dim elapTimer As New Threading.Timer(AddressOf tick, Nothing, 1000, 1000)
Dim stpw As Stopwatch = Stopwatch.StartNew
Private Sub tick(ByVal state As Object)
If stpw.IsRunning Then
Me.Invoke(Sub()
Label1.Text = stpw.Elapsed.ToString("d\ \ hh\:mm\:ss\.ff")
End Sub)
End If
End Sub
Dim ClickCount As Integer = 0
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim rand1 As String
Dim rand2 As String
rand1 = TextBox1.Text
rand2 = TextBox2.Text
If Not ClickCount = 4 Then
ClickCount += 1
Else
ClickCount = 1
End If
Select Case ClickCount
Case Is = 1
Button2.BackColor = Color.Green
Case Is = 2
Button2.BackColor = Color.Yellow
Case Is = 3
Button2.BackColor = Color.Red
End Select
End Sub
End Class
I've no idea how to get the random numbers from the Textboxes and use it to locate the buttons. Also I'm having difficulties with the Score keeping. Please help me.. :)