/*** When game form is first loaded: Initialize variables, Add url link,
              Disable buttons, and Display "welcome" in wordLabel slots ***/
        private void HangmanGameForm_Load(object sender, EventArgs e)
        {
            // Initialize variables
             wordFile = new WordFile();
             link = new LinkLabel.Link();
             nextInstructionButton.Visible = false;
             numberOfGamesWon = 0;
             numberOfGamesLost = 0;

             // Initialize label array for SecretWord display
             wordLabels = new Label[MAXIMUM_WORD_SIZE];
             wordLabels[0] = wordChar0;
             wordLabels[1] = wordChar1;
             wordLabels[2] = wordChar2;
             wordLabels[3] = wordChar3;
             wordLabels[4] = wordChar4;
             wordLabels[5] = wordChar5;
             wordLabels[6] = wordChar6;
             wordLabels[7] = wordChar7;
             wordLabels[8] = wordChar8;

             // Initialize button array for letter choice box
             charButtons = new Button[NUMBER_OF_BUTTONS];
             charButtons[0] = aCharButton;
             charButtons[1] = bCharButton;
             charButtons[2] = cCharButton;
             charButtons[3] = dCharButton;
             charButtons[4] = eCharButton;
             charButtons[5] = fCharButton;
             charButtons[6] = gCharButton;
             charButtons[7] = hCharButton;
             charButtons[8] = iCharButton;
             charButtons[9] = jCharButton;
             charButtons[10] = kCharButton;
             charButtons[11] = lCharButton;
             charButtons[12] = mCharButton;
             charButtons[13] = nCharButton;
             charButtons[14] = oCharButton;
             charButtons[15] = pCharButton;
             charButtons[16] = qCharButton;
             charButtons[17] = rCharButton;
             charButtons[18] = sCharButton;
             charButtons[19] = tCharButton;
             charButtons[20] = uCharButton;
             charButtons[21] = vCharButton;
             charButtons[22] = wCharButton;
             charButtons[23] = xCharButton;
             charButtons[24] = yCharButton;
             charButtons[25] = zCharButton;

             // Initialize image array for hangman drawing sections
             hangingManImages = new Image[NUMBER_OF_HANGMAN_IMAGES];
             hangingManImages[0] = Properties.Resources.Man0;
             hangingManImages[1] = Properties.Resources.Man1;
             hangingManImages[2] = Properties.Resources.Man2;
             hangingManImages[3] = Properties.Resources.Man3;
             hangingManImages[4] = Properties.Resources.Man4;
             hangingManImages[5] = Properties.Resources.Man5;
             hangingManImages[6] = Properties.Resources.Man6;
             hangingManImages[7] = Properties.Resources.DeadMan;

             // Initialize image array for instruction images
             instructionImages = new Image[NUMBER_OF_INSTRUCTION_IMAGES];
             instructionImages[0] = Properties.Resources.Instructions0;
             instructionImages[1] = Properties.Resources.Instructions1;
             instructionImages[2] = Properties.Resources.Instructions2;
             instructionImages[3] = Properties.Resources.Instructions3;

             // Add link data
             link.LinkData = "http://introcs.cs.princeton.edu/java/data/1000words.txt";
             textSourceLink.Links.Add(link);

             // Disable letter buttons and 2 menu buttons
             cleanUpButtons();

             // Display "welcome" in wordLabel array
             clearSecretWordDisplay();
             wordFile.SecretWord = "welcome";
             makeBlankDisplayVisible();
             displaySecretWord();
        }
Esempio n. 2
0
        /*** When game form is first loaded: Initialize variables, Add url link,
         *      Disable buttons, and Display "welcome" in wordLabel slots ***/
        private void HangmanGameForm_Load(object sender, EventArgs e)
        {
            // Initialize variables
            wordFile = new WordFile();
            link     = new LinkLabel.Link();
            nextInstructionButton.Visible = false;
            numberOfGamesWon  = 0;
            numberOfGamesLost = 0;

            // Initialize label array for SecretWord display
            wordLabels    = new Label[MAXIMUM_WORD_SIZE];
            wordLabels[0] = wordChar0;
            wordLabels[1] = wordChar1;
            wordLabels[2] = wordChar2;
            wordLabels[3] = wordChar3;
            wordLabels[4] = wordChar4;
            wordLabels[5] = wordChar5;
            wordLabels[6] = wordChar6;
            wordLabels[7] = wordChar7;
            wordLabels[8] = wordChar8;

            // Initialize button array for letter choice box
            charButtons     = new Button[NUMBER_OF_BUTTONS];
            charButtons[0]  = aCharButton;
            charButtons[1]  = bCharButton;
            charButtons[2]  = cCharButton;
            charButtons[3]  = dCharButton;
            charButtons[4]  = eCharButton;
            charButtons[5]  = fCharButton;
            charButtons[6]  = gCharButton;
            charButtons[7]  = hCharButton;
            charButtons[8]  = iCharButton;
            charButtons[9]  = jCharButton;
            charButtons[10] = kCharButton;
            charButtons[11] = lCharButton;
            charButtons[12] = mCharButton;
            charButtons[13] = nCharButton;
            charButtons[14] = oCharButton;
            charButtons[15] = pCharButton;
            charButtons[16] = qCharButton;
            charButtons[17] = rCharButton;
            charButtons[18] = sCharButton;
            charButtons[19] = tCharButton;
            charButtons[20] = uCharButton;
            charButtons[21] = vCharButton;
            charButtons[22] = wCharButton;
            charButtons[23] = xCharButton;
            charButtons[24] = yCharButton;
            charButtons[25] = zCharButton;

            // Initialize image array for hangman drawing sections
            hangingManImages    = new Image[NUMBER_OF_HANGMAN_IMAGES];
            hangingManImages[0] = Properties.Resources.Man0;
            hangingManImages[1] = Properties.Resources.Man1;
            hangingManImages[2] = Properties.Resources.Man2;
            hangingManImages[3] = Properties.Resources.Man3;
            hangingManImages[4] = Properties.Resources.Man4;
            hangingManImages[5] = Properties.Resources.Man5;
            hangingManImages[6] = Properties.Resources.Man6;
            hangingManImages[7] = Properties.Resources.DeadMan;

            // Initialize image array for instruction images
            instructionImages    = new Image[NUMBER_OF_INSTRUCTION_IMAGES];
            instructionImages[0] = Properties.Resources.Instructions0;
            instructionImages[1] = Properties.Resources.Instructions1;
            instructionImages[2] = Properties.Resources.Instructions2;
            instructionImages[3] = Properties.Resources.Instructions3;

            // Add link data
            link.LinkData = "http://introcs.cs.princeton.edu/java/data/1000words.txt";
            textSourceLink.Links.Add(link);

            // Disable letter buttons and 2 menu buttons
            cleanUpButtons();

            // Display "welcome" in wordLabel array
            clearSecretWordDisplay();
            wordFile.SecretWord = "welcome";
            makeBlankDisplayVisible();
            displaySecretWord();
        }