-
December 2nd, 2013, 12:53 AM
#1
[VB 2012] Need help with a Rock Paper Scissors Lizard Spock game
Okay, for my last project in my class I'm to construct a game that follows these guidelines:
http://imageshack.com/a/img811/6125/r6zh.jpg
So now that I've got that out of the way, I'm having some issues with my code. Mainly one issue, here's my code with the bold indicators where my problem is, since it won't go bold faced:
Code:
Public Class frmCapstone
Dim numWinUser As Integer
Dim numWinComp As Integer
Dim numDraws As Integer
Dim userName, roundNum As String
Dim computer As String
Dim c1, c2, c3, c4, c5 As Integer
Private Sub chkGame_CheckedChanged(sender As Object, e As EventArgs) Handles chkGame.CheckedChanged
grpGame.Enabled = False
userName = CStr(txtName.Text)
roundNum = CStr(txtRounds.Text)
If chkGame.Checked Then
grpGame.Enabled = True
Else
grpGame.Enabled = False
End If
End Sub
Private Sub btnPlay_Click(sender As Object, e As EventArgs) Handles btnPlay.Click
Dim randomNum As New Random
Dim winner As String
computer = randomNum.Next(1, 6)
c1 = chkRock.Checked
c2 = chkPaper.Checked
c3 = chkScissors.Checked
c4 = chkLizard.Checked
c5 = chkSpock.Checked
DisplayResults(numWinUser, numWinComp, numDraws)
winner = DetermineWinner(userName, computer)
Select Case grpGame
Case Is = chkRock.Checked
lstResults.Items.Clear()
lstResults.Items.Add("The winner of this round is " & winner)
lstResults.Items.Add("Your chose " & c1)
lstResults.Items.Add("Computer's choice was " & randomNum)
Case Is = chkPaper.Checked
lstResults.Items.Clear()
lstResults.Items.Add("The winner of this round is " & winner)
lstResults.Items.Add("Your chose " & c2)
lstResults.Items.Add("Computer's choice was " & randomNum)
Case Is = chkScissors.Checked
lstResults.Items.Clear()
lstResults.Items.Add("The winner of this round is " & winner)
lstResults.Items.Add("Your chose " & c3)
lstResults.Items.Add("Computer's choice was " & randomNum)
Case Is = chkLizard.Checked
lstResults.Items.Clear()
lstResults.Items.Add("The winner of this round is " & winner)
lstResults.Items.Add("Your chose " & c4)
[b]lstResults.Items.Add("Computer's choice was " & randomNum)[b]
Case Is = chkSpock.Checked
lstResults.Items.Clear()
lstResults.Items.Add("The winner of this round is " & winner)
lstResults.Items.Add("Your chose " & c5)
lstResults.Items.Add("Computer's choice was " & randomNum)
End Select
Select Case winner
Case "user"
numWinUser += 1
Case "comp"
numWinComp += 1
Case "draw"
numDraws += 1
End Select
DisplayResults(numWinUser, numWinComp, numDraws)
End Sub
Function DetermineWinner(ByVal userName As String, ByVal computer As Integer) As String
If userName > computer Then
Return "" & userName
lstResults.Items.Add("Impressive. Most impressive. But you're not a Jedi yet!")
ElseIf userName < computer Then
Return "computer"
lstResults.Items.Add("You really suck at this game. U Mad Bro?")
Else
Return "draw"
lstResults.Items.Add("Epic Fail with a side of Picard Facepalm")
End If
End Function
Sub DisplayResults(ByVal numWinUser As Integer, ByVal numWinComp As Integer, ByVal numDraws As Integer)
txtWin.Text = CStr(numWinUser)
txtLoss.Text = CStr(numWinComp)
txtDraw.Text = CStr(numDraws)
If numWinComp = 2 Then
lstResults.Items.Add("Ha Ha Ha Ha, you lose. Loser! You're a loser! Game Over")
ElseIf numWinUser = 2 Then
lstResults.Items.Add("You win?!? NO FAIR!!! You cheated!!! I always win!!!")
End If
End Sub
Sub DisplayCards(ByVal userName As String, ByVal computer As String)
Select Case userName
Case Is = chkRock.Checked = 1
picUser.Image = Image.FromFile("rock.jpg")
Case Is = chkPaper.Checked = 2
picUser.Image = Image.FromFile("paper.png")
Case Is = chkScissors.Checked = 3
picUser.Image = Image.FromFile("scissors.jpeg")
Case Is = chkLizard.Checked = 4
picUser.Image = Image.FromFile("lizard.jpg")
Case Is = chkSpock.Checked = 5
picUser.Image = Image.FromFile("spock.jpg")
End Select
Select Case computer
Case Is = 1
picUser.Image = Image.FromFile("rock.jpg")
Case Is = 2
picUser.Image = Image.FromFile("paper.png")
Case Is = 3
picUser.Image = Image.FromFile("scissors.jpeg")
Case Is = 4
picUser.Image = Image.FromFile("lizard.jpg")
Case Is = 5
picUser.Image = Image.FromFile("spock.jpg")
End Select
End Sub
End Class
I was wondering how to fix this error. Also I had a couple of questions on how to add a couple of things in and where I should add them.
First, I'm not sure what to use or how to utilize where I need it, but what would I use to determine a number of rounds that are played between the computer and the user. Secondly, how would I put in and where would I put in what each result would me (e.g. rock smashes scissors, Spock disproves paper, ect.) I know I've got some work ahead of me but any help would be appreciated.
I'm going to upload my program to zippyshare for those who want to work with it hands on to help me. Thanks for all help in advance.
http://www67.zippyshare.com/v/44506790/file.html
-
December 2nd, 2013, 01:09 PM
#2
Re: [VB 2012] Need help with a Rock Paper Scissors Lizard Spock game
Nobody wants to write your code for you. Sorry.
-
December 2nd, 2013, 01:32 PM
#3
Re: [VB 2012] Need help with a Rock Paper Scissors Lizard Spock game
You don't have to be a **** about it, all I was asking was for some help with my errors
Last edited by HanneSThEGreaT; December 7th, 2013 at 04:25 AM.
Reason: LANGUAGE!
-
December 3rd, 2013, 01:25 AM
#4
Re: [VB 2012] Need help with a Rock Paper Scissors Lizard Spock game
Originally Posted by jaym1125
all I was asking was for some help with my errors
David has a weird way of saying things but he is right..
It's not good telling us you got errors.. Tell us what the error is.. What is it doing that it's not supposed to.. What is it supposed to be doing..
In the code you posted, you say the error is on lstResults.Items.Add("Computer's choice was " & randomNum)... tell us What & Why??
And looking at the code i can see a few issues, but then again not on the lines you highlighted..
This is your School Project -- HOMEWORK -- and as a simple rule here, we do not do homework, we will guide you, give you hints, tips, code examples and plenty of advice.. but not the full answer.... How do you expect to learn if you do not do the work..
P.S. look through your class book, everything you need to do this is already in there....
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
December 7th, 2013, 04:26 AM
#5
Re: [VB 2012] Need help with a Rock Paper Scissors Lizard Spock game
jaym1125 - this is a public site. please do not swear on it again!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|