Ejemplo n.º 1
0
 /// <summary>
 /// Instantiate an RPS game, set players choice and determine winner.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btn_lizard_Click(object sender, EventArgs e)
 {
     userChoice = "l";
     RockPaperScissors LS = new RockPaperScissors();
     int computerThrow = LS.computerThrow(COMPUTER_CHOICE);
     int playerThrow = LS.playerChoiceToInt(userChoice);
     txt_computerChoice.Text = LS.computerChoiceToString(computerThrow);
     txt_winner.Text = LS.determineWinner(computerThrow, playerThrow);
     btn_lizard.BackColor = Color.GreenYellow;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Instantiate an RPS game, set players choice and determine winner.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btn_paper_Click(object sender, EventArgs e)
        {
            userChoice = "p";
            RockPaperScissors RPS = new RockPaperScissors();
            int computerThrow = RPS.computerThrow(COMPUTER_CHOICE);
            int playerThrow = RPS.playerChoiceToInt(userChoice);
            txt_computerChoice.Text = RPS.computerChoiceToString(computerThrow);
            txt_winner.Text = RPS.determineWinner(computerThrow, playerThrow);
            btn_paper.BackColor = Color.DarkRed;
            btn_paper.ForeColor = Color.AntiqueWhite;

            try
            {
                imageStream = assembly.GetManifestResourceStream("RPS_WindowsForm.Images.paper.bmp");
                //Bitmap image = new Bitmap(type.Assembly.GetManifestResourceStream(imageStream));
                pbx_paper.Show();
                pbx_paper.Image = new Bitmap(imageStream);
            }
            catch
            {
                MessageBox.Show("Error creating image.");
            }
        }