예제 #1
0
        /*
         *  Event Handeler for showing high score board
         *
         */
        private void scoreboard_Click(Object sender, EventArgs e)
        {
            popUpForm rankings = new popUpForm(-1);

            this.Visible = false;
            rankings.menuMode();

            DialogResult result = rankings.ShowDialog();


            if (result == DialogResult.OK)
            {
                this.Visible = true;
            }
            else
            {
                Close();
            }
        }
예제 #2
0
        /*
         * The following method determines what happens on the background timers click
         */
        private void backgroundMoveTime_Tick(object sender, EventArgs e)
        {
            //check if the game has been won yet
            if (!gameWon)
            {
                //if game has not been won, check if there is any time left on the timer
                if (Math.Round(gameTime) == 0)
                {
                    //set the game to be won
                    gameWon = true;
                    //open the scoreboard
                    var newForm = new popUpForm(score);
                    var result  = newForm.ShowDialog();

                    //wait for input from the scorboard
                    if (result == DialogResult.OK)
                    {
                        //if the player wants to play again, call refreshGame()
                        if (newForm.playAgain)
                        {
                            refreshGame();
                        }
                        else
                        {
                            //else quit back to menu
                            this.DialogResult = DialogResult.OK;
                            Close();
                        }
                    }
                }
                else //else if game has not finished
                {
                    //tick down the game timer
                    gameTime -= 0.01;

                    //update labels
                    timerDisplay.Text = Convert.ToString(Math.Round(gameTime));
                    scoreDisplay.Text = "Score " + Convert.ToString(score);
                }

                //following loop scrolls up the background
                for (int y = 0; y < grid.GetLength(1); y++)
                {
                    //move the background up
                    grid[bottomRow, y].Top -= scrollSpeed;

                    //check collision and move GUI to top
                    checkCollision(bottomRow, y);
                    player.BringToFront();
                    gameMenu.BringToFront();

                    //checks if the picturebox is off the screen
                    if (grid[bottomRow, y].Top <= 0)
                    {
                        grid[bottomRow, y].Top       = 500;
                        grid[bottomRow, y].BackColor = backg;
                        grid[bottomRow, y].Image     = null;
                        //change the bottom row to hold the new bottom row
                        bottomRow--;
                    }

                    //if the bottom row has gone negative, reset it
                    if (bottomRow == -1)
                    {
                        bottomRow = 8;
                    }
                }
            }
        }