Exemplo n.º 1
0
        public bool pogodok(Ball topka)
        {
            if (topka.Y + topka.Radius >= forma.Top && topka.Y + topka.Radius <= forma.Bottom - topka.Radius && topka.X >= forma.Left - topka.Radius && topka.X <= forma.Right + topka.Radius)
            {
                topka.velocityY = -topka.velocityY;
                return true;
            }

            else if (topka.Y - topka.Radius <= forma.Bottom && topka.Y - topka.Radius >= forma.Top + topka.Radius && topka.X >= forma.Left - topka.Radius && topka.X <= forma.Right + topka.Radius)
            {
                topka.velocityY = -topka.velocityY;
                return true;
            }

            else if (topka.X + topka.Radius >= forma.Left && topka.X + topka.Radius <= forma.Left + topka.Radius && topka.Y >= forma.Top - topka.Radius && topka.Y <= forma.Bottom + topka.Radius)
            {
                topka.velocityY = -topka.velocityY;
                topka.velocityX = -topka.velocityX;
                return true;
            }

            else if (topka.X - topka.Radius <= forma.Right && topka.X - topka.Radius >= forma.Right - topka.Radius && topka.Y >= forma.Top - topka.Radius && topka.Y <= forma.Bottom + topka.Radius)
            {
                topka.velocityY = -topka.velocityY;
                topka.velocityX = -topka.velocityX;
                return true;
            }

            return false;
        }
Exemplo n.º 2
0
        public void novaIgra()
        {
            cigli = new CiglaDoc();
            pomosna = new CiglaDoc();
            doublebuffer = new Bitmap(Width, Height);
            graphics = CreateGraphics();
            boja = new SolidBrush(Color.Green);
            ball = new Ball(200, 200, 5,20, (float)(Math.PI / 4));
            bounds = new Rectangle(0, 0, this.Width, this.Height);
            ball.Bounds = bounds;
            kvadrat = new Rectangle(this.Width / 2 - 100, this.Height - 100, 200, 30);

            prevX = kvadrat.X + kvadrat.Width / 2;

            Show();

            iscrtaj(graphics);

            timer = new Timer();
            timer.Tick += new EventHandler(timer_Tick);
            timer.Interval = 1000 / BRZINA;
            timer.Start();
        }
Exemplo n.º 3
0
        void proverka(Ball b)
        {
            foreach (Cigla item in cigli.lstCigli)
            {
                if (item.pogodok(b))
                {
                    pomosna.brisi(item);

                }
            }
            cigli.lstCigli.Clear();

            foreach (Cigla item in pomosna.lstCigli)
            {
                cigli.lstCigli.Add(item);
            }
        }