08-03-2011, 04:02 PM
Hello, here is another little tutorial. This one is how to make a game of Rock, Paper, Scissors
Lets get started.
What you Need:
Code:
It's pretty fun to play when you're bored
If you want, you could also make a program with multiple games and have this in there, that's probably what I will be doing soon
Lets get started.
What you Need:
- 1 Combo Box
- 1 Button (Label it "Choose")
- 1 Label (Label it "...")
Code:
Code:
Public Class Form1
Dim userselected As Integer
Dim gameresult As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ComboBox1.SelectedIndex = 0
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Random As New Random
Dim computerchoice = Random.Next(3)
If computerchoice = userselected Then gameresult = 0
Select Case computerchoice
Case 0
If userselected = 1 Then gameresult = 2
If userselected = 2 Then gameresult = 1
Case 1
If userselected = 0 Then gameresult = 1
If userselected = 2 Then gameresult = 2
Case 2
If userselected = 0 Then gameresult = 2
If userselected = 1 Then gameresult = 1
End Select
Select Case gameresult
Case 0
Label1.Text = "It Was A Draw"
Case 1
Label1.Text = "Bad Luck! Computer Wins"
Case 2
Label1.Text = "You Win!"
End Select
End Sub
End Class
It's pretty fun to play when you're bored
If you want, you could also make a program with multiple games and have this in there, that's probably what I will be doing soon