Monday 17 September 2012

Rock, Paper and Scissors - PsudoCode

Finally, with the PsudoCode out of the way, the actual development of Rock, Paper and Scissors visual basic may begin. 

Paper Button
Private Sub btnPaper_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPaper.Click
When the “Paper” button is clicked…

        If lblHScore.Text = "10" Then
            MsgBox("Congradulations!" & vbCrLf & "You have defeated the Artificial Beings and brought peace to our lands." & vbCrLf & "THANK YOU")
        End If
IF the players score is “10”, display a congratulations Massage box with the inputted comment.

        If lblCScore.Text = "10" Then
            MsgBox("Ooooops!" & vbCrLf & "It looks like you have been beaten by Artificial Beings!" & vbCrLf & "You have caused the downfall of HUMANITY")
        End If
If the computers score is “10”, display a failure Massage box with the inputted message.

        pxtHuman.ImageLocation = "D:\Users\wij0006\Documents\ZZZ\School\IT\Programming and Pathways\Papper, Scissors and Rock\Human Paper.png"
Display the picture of paper

        pxtComp.ImageLocation = Int(Rnd() * 3 + 1)
        Select Case pxtComp
Select a random number from 1 - 3
            Case "1"
                pxtComp.ImageLocation = "D:\Users\wij0006\Documents\ZZZ\School\IT\Programming and Pathways\Papper, Scissors and Rock\AI Paper.png"
If random number “1”, display picture of paper as Computers choice.
            Case "2"
                pxtComp.ImageLocation = "D:\Users\wij0006\Documents\ZZZ\School\IT\Programming and Pathways\Papper, Scissors and Rock\AI Rock.png"
If random number “2”, display picture of rock as Computers choice.
            Case "3"
                pxtComp.ImageLocation = "D:\Users\wij0006\Documents\ZZZ\School\IT\Programming and Pathways\Papper, Scissors and Rock\AI Scissors.png"
If random picture “3”, display picture of Scissors as Computers choice.

        End Select

        If pxtComp.ImageLocation = "D:\Users\wij0006\Documents\ZZZ\School\IT\Programming and Pathways\Papper, Scissors and Rock\AI Rock.png" Then
            lblHScore.Text = lblHScore.Text + 1
            lblComment.Text = "YOu WIN!" & vbCrLf & "Have a Point"
        End If
If the Computers image is Rock, add +1 to humans score and display comment in comment label
        If pxtComp.ImageLocation = "D:\Users\wij0006\Documents\ZZZ\School\IT\Programming and Pathways\Papper, Scissors and Rock\AI Scissors.png" Then
            lblCScore.Text = lblCScore.Text + 1
            lblComment.Text = "YOU LOSE!" & vbCrLf & "Very Predictable"
        End If
If the Computers image is Scissors add +1 to the Computers score and display comment in Comment label
        If pxtComp.ImageLocation = "D:\Users\wij0006\Documents\ZZZ\School\IT\Programming and Pathways\Papper, Scissors and Rock\AI Paper.png" Then
            lblComment.Text = "A DRAW?!" & vbCrLf & "Well, that was unexpected"
        End If
If the Computers image is Paper, display comment in comment label

    End Sub

This code is also repeated for the “Rock” and “Scissors” buttons but is altered according to the rules.

Reset Button
    Private Sub btnReset_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnReset.Click
When the “Reset” button is clicked perform the following tasks…
        lblHScore.Text = "0"
       Change players score to equal “0”
        lblCScore.Text = "0"
       Change computers score to equal “0”
        lblComment.Text = "Make you move"
       Change comment in comment label to read “Make your move”

        pxtHuman.ImageLocation = "D:\Users\wij0006\Documents\ZZZ\School\IT\Programming and Pathways\Papper, Scissors and Rock\Starter Human.png"
Change the human picture to the starter picture
        pxtComp.ImageLocation = "D:\Users\wij0006\Documents\ZZZ\School\IT\Programming and Pathways\Papper, Scissors and Rock\Starter Comp.png"
Change the computer picture to the starter picture
    End Sub

Help Button
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        MsgBox("How to Play" & vbCrLf & "Click 1 of the 3 buttons (rock, paper or scissors) to use your weapon of choice for that round, if you win you get a point and if you lose the computer gets a point. A draw will cause no points to be awarded." & vbCrLf & "The game ends when either you or the computer reaches 10 points." & vbCrLf & "" & vbCrLf & "Rules" & vbCrLf & "Paper beats Rock. Rock beats Scissors and Scissors beat Paper")
    End Sub
Display the following message in a message box when the “Help” button is clicked.

Once again  I have left out coding for the Exit button due to just the single word: End. Make note that I have not included the PsudoCode for the "Rock" and "Scissors" buttons as it is nearly an exact match to the "Paper" button with slight alteration such as which point is given to who and which comment is displayed when.
                                                             ~PsudoCode Complete~

No comments:

Post a Comment