예제 #1
0
        public Form1()
        {
            InitializeComponent();
            this.DoubleBuffered = true;
            game              = new Game();
            bonusGame         = new BonusGame();
            isBall2           = false;
            isNewBall         = false;
            isClickedMore     = false;
            isClickedSurprise = true;

            timer          = new Timer();
            timer.Interval = 30;
            timer.Tick    += new EventHandler(timer_Tick);
            timer.Start();

            timer2          = new Timer();
            timer2.Interval = 100;
            timer2.Tick    += new EventHandler(timer2_Tick);


            leftX  = 20;
            topY   = 40;
            width  = this.Width - (3 * leftX);
            height = this.Height - (int)(2.5 * topY);

            BallX      = this.Width / 2;
            BallY      = this.Height - 120;
            RectangleX = this.Width / 2 - 40;
            RectangleY = this.Height - 110;
            ball       = new Ball(new Point(BallX, BallY));
            rectangle  = new Rectangle(RectangleX, RectangleY);
            Misses     = 3;
        }
예제 #2
0
        public BonusLevel()
        {
            InitializeComponent();
            BonusGame = new BonusGame();


            this.DoubleBuffered = true;
            leftX  = 20;
            topY   = 40;
            width  = this.Width - (3 * leftX);
            height = this.Height - (int)(2.5 * topY);


            ball           = new Ball(new Point(this.Width / 2, this.Height - 120));
            rectangle      = new Rectangle(this.Width / 2 - 40, this.Height - 110);
            game           = new Game();
            isMoved        = 0;
            timer          = new Timer();
            timer.Interval = 20;
            timer.Tick    += new EventHandler(timer_Tick);
            try
            {
                timer.Start();
            }
            catch { }
        }
예제 #3
0
 public Game()
 {
     CurrentColor = Color.Red;
     Bricks       = new List <Brick>();
     Balls        = new List <Ball>();
     BallsMore    = new List <Ball>();
     bonusGame    = new BonusGame();
     flag         = 0;
     EndGame      = false;
     ShowBonus    = false;
     random       = new Random();
     r            = random.Next(0, 50);
     Points       = 0;
     ShowImage    = true;
 }
예제 #4
0
        public void NewGame()
        {
            if (ball.isNewGame)
            {
                game.ClearBall();
                if (Misses > 1)
                {
                    ball      = new Ball(new Point(BallX, BallY));
                    rectangle = new Rectangle(RectangleX, RectangleY);
                    isMoved   = 0;
                    Misses--;
                    timer.Enabled = false;
                    timer.Dispose();
                    timer2.Enabled = false;
                    timer2.Dispose();
                    progrssBar.Value = 0;
                    timer            = new Timer();
                    timer.Interval   = 30;
                    timer.Tick      += new EventHandler(timer_Tick);
                    timer.Start();
                    if (supriseCount <= 4)
                    {
                        lblSuprise.ForeColor = Color.Red;
                        isClickedSurprise    = true;
                    }
                }
                else if (Misses == 1)
                {
                    timer.Enabled = false;

                    DialogResult dialogResault = MessageBox.Show("Do you want to play again?", "GAME OVER", MessageBoxButtons.RetryCancel);

                    if (dialogResault == DialogResult.Retry)
                    {
                        timer          = new Timer();
                        timer.Interval = 30;
                        timer.Tick    += new EventHandler(timer_Tick);
                        timer.Start();

                        game.ClearBall();
                        ball          = new Ball(new Point(BallX, BallY));
                        rectangle     = new Rectangle(RectangleX, RectangleY);
                        game          = new Game();
                        bonusGame     = new BonusGame();
                        isBall2       = false;
                        isNewBall     = false;
                        isClickedMore = false;

                        Misses   = 3;
                        isMoved  = 0;
                        CountTwo = 1;
                        timer2.Dispose();
                        timer2.Enabled   = false;
                        progrssBar.Value = 0;

                        SetValueForFinalePoints = 0;
                        suprise              = 0;
                        supriseCount         = 0;
                        lblSuprise.ForeColor = Color.Red;
                        isClickedSurprise    = true;

                        lblMore.ForeColor = Color.Coral;
                        lblTwo.ForeColor  = Color.Coral;
                    }
                    else
                    {
                        try
                        {
                            timer.Dispose();
                            timer.Enabled = false;
                            timer2.Dispose();
                            timer2.Enabled = false;
                            Menu       menu  = new Menu();
                            FinalScore final = new FinalScore();

                            if (game.Points >= max)
                            {
                                SetValueForFinalePoints = game.Points;
                                max = SetValueForFinalePoints;
                            }
                            this.Hide();
                            menu.ShowDialog();
                            this.Dispose();
                            this.Close();
                        }
                        catch { }
                    }
                }

                if (isBall2)
                {
                    game.Balls.Remove(ball_2);
                    isBall2 = false;
                }
            }
            lblLives.Text  = Misses.ToString();
            lblPoints.Text = game.Points.ToString();
        }