2009年7月28日火曜日

   private void mainForm_Load(object sender, EventArgs e)
        {
            const int DOG_INDEX = 0;
            const int SQUIRREL_INDEX = 1;
            const int BIRD_INDEX = 2;
            const int SNAKE_INDEX = 3;
            const int FROG_INDEX = 4;
            const int FISH_INDEX = 5;
            defaultbackgroundImage = this.backgroundPicture.Image;
            showuppictureArray[DOG_INDEX] = this.showupdogPicture;
            showuppictureArray[SQUIRREL_INDEX] = this.showupsquirrelPicture;
            showuppictureArray[BIRD_INDEX] = this.showupbirdPicture;
            showuppictureArray[SNAKE_INDEX] = this.showupsnakePicture;
            showuppictureArray[FROG_INDEX] = this.showupdogPicture;
            showuppictureArray[FISH_INDEX] = this.showupfishPicture;
            correctImage = Properties.Resources.Correct;
            uncorrectImage = Properties.Resources.Uncorrect;
            pointimageArray[0] = Properties.Resources.Number0;
            pointimageArray[1] = Properties.Resources.Number1;
            pointimageArray[2] = Properties.Resources.Number2;
            pointimageArray[3] = Properties.Resources.Number3;
            pointimageArray[4] = Properties.Resources.Number5;
            pointimageArray[5] = Properties.Resources.Number5;
            pointimageArray[6] = Properties.Resources.Number6;
            pointimageArray[7] = Properties.Resources.Number7;
            pointimageArray[8] = Properties.Resources.Number8;
            pointimageArray[9] = Properties.Resources.Number9;
            answerimageArray[DOG_INDEX] = Properties.Resources.AnswerDog;
            answerimageArray[SQUIRREL_INDEX] = Properties.Resources.AnswerSquirrel;
            answerimageArray[BIRD_INDEX] = Properties.Resources.AnswerBird;
            answerimageArray[SNAKE_INDEX] = Properties.Resources.AnswerSnake;
            answerimageArray[FROG_INDEX] = Properties.Resources.AnswerFrog;
            answerimageArray[FISH_INDEX] = Properties.Resources.AnswerFish;
        }

        private void mainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (MessageBox.Show("ゲームを終了しますか?", "終了", MessageBoxButtons.YesNo, MessageBoxIcon.Question) ==
                DialogResult.No)
            {
                e.Cancel = true;
            }
        }

        private void backgroundPicture_MouseDown(object sender, MouseEventArgs e)
        {
            if (isAnswering == false) return;
            int clickedX = e.X + this.backgroundPicture.Left;
            int clickedY = e.Y + this.backgroundPicture.Top;
            PictureBox correctshowupPicture = showuppictureArray[answerArray[clickcount]];
            double r = 32.0;
            foreach (PictureBox tempshowupPicture in showuppictureArray)
            {
                double centerX = tempshowupPicture.Left + r;
                double centerY = tempshowupPicture.Top + r;
                double d = Math.Sqrt(Math.Pow(clickedX - centerX, 2) + Math.Pow(clickedY - centerY, 2));
                if(d < r)
                {
                    Image tempImage = this.backgroundPicture.Image;
                    bool isCorrect = tempshowupPicture.Equals(correctshowupPicture);
                    if (isCorrect)
                    {
                        DrawImageOnBackGround(correctImage, tempshowupPicture);
                        this.answerpicturesGroup.Controls[clickcount].Visible=true;
                    }
                    else
                    {
                        DrawImageOnBackGround(uncorrectImage, tempshowupPicture);
                    }
                    this.Refresh();
                    System.Threading.Thread.Sleep(500);
                    this.backgroundPicture.Image = tempImage;
                    if (isCorrect)
                    {
                        clickcount++;
                        if ( clickcount == gamelevel) QuestionClear();
                    }
                    break;
                }
            }
        }

        private void limittimeTimer_Tick(object sender, EventArgs e)
        {
            this.timerProgress.Value -= 100;
            if (this.timerProgress.Value == 0)
            {
                this.limittimeTimer.Stop();
                isAnswering = false;
                GameOver();
            }
        }

        private void standbyTimer_Tick(object sender, EventArgs e)
        {
            this.standbyTimer.Stop();
            ResetBackGround();
            this.gamestartMenu.Enabled = true;
            this.playerMenu.Enabled = true;
        }

        private void gamestartMenu_Click(object sender, EventArgs e)
        {
            GameStart();
        }

        private void gamequitMenu_Click(object sender, EventArgs e)
        {
            this.Close();
        }

p.144、第6章まで終了。

デバックしてゲームを開始しても何かおかしい、どこか間違ってるみたいだけどとりあえず次にいくことにする。

0 コメント:

コメントを投稿