Exemple #1
0
        public bool Move(PalkaRect palka)
        {
            float nextY = Y + velocityY;

            Y += velocityY;
            return(RectangleCollision(palka));
        }
Exemple #2
0
        public void NewGame()
        {
            gameover = false;

            bounds       = new Rectangle(0, 25, f.Bounds.Width - 18, f.Bounds.Height - 40);
            doubleBuffer = new Bitmap(f.Width, f.Height);
            graphics     = f.CreateGraphics();
            ball         = new Ball(360, 564, 15, 60, 30, this, f, ff);
            f.Show();
            palka = new PalkaRect(360, 600, 100, 10);
            brush = new SolidBrush(Color.Blue);
            pen   = new Pen(Color.White);

            LVL      = 0;
            level    = new Level(LVL);
            intScore = 0;
            Lives    = 3;
            intScore = 0;

            brojacInvert = 0;
            brojacMala   = 0;
            brojacGolema = 0;



            timer          = new Timer();
            timer.Tick    += new EventHandler(timer_Tick);
            timer.Interval = 50 / FRAMES_PER_SECOND;
            timer.Start();
        }
Exemple #3
0
 bool RectangleCollision(PalkaRect palka)
 {
     if (this.isTouching(palka))
     {
         return(true);
     }
     return(false);
 }
Exemple #4
0
        public List <Brick> Move(PalkaRect palka, List <Brick> b)
        {
            game.Score();
            if (!GameOver)
            {
                //if (g != null) g.Move(palka);
                for (int i = 0; i < g.Count; i++)
                {
                    if (g[i].Move(palka))
                    {
                        g[i].RandomGift();
                        g.RemoveAt(i);
                    }
                }

                this.palka = palka;
                this.b     = b;

                float nextX = X + velocityX;
                float nextY = Y + velocityY;

                if (nextY > palka.Y && game.Lives == 0)
                {
                    GameOver = true;
                    game.CloseGame();


                    if (MessageBox.Show("Вкупно освоени поени: " + game.intScore, "Дали сакате да се обидете повторно",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
                    {
                        game.NewGame();
                    }
                    else
                    {
                        game.CloseGame(); f.Close(); game.gameover = true;
                    }
                }
                else if (nextY > palka.Y)
                {
                    game.START = false;
                    game.palka.ResetPosition();
                    game.ball.ResetPosition();
                    game.Lives--;
                }
                WallCollision();
                RectangleCollision();
                BrickCollision();


                X += velocityX;
                Y += velocityY;
            }
            return(b);
        }
Exemple #5
0
 public bool isTouching(PalkaRect palka)
 {
     return((Math.Abs(palka.Y - Y) <= (palka.height / 2) + 2) && (Math.Abs(palka.X - X) <= (palka.width / 2) + 2));
 }