Esempio n. 1
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();
        }
        void timer_Tick(object sender, EventArgs e)
        {
            Graphics g = Graphics.FromImage(doublebuffer);

            g.Clear(Color.White);
            g.DrawRectangle(new Pen(new SolidBrush(Color.Red)), ball.Bounds);
            g.FillRectangle(new SolidBrush(Color.RoyalBlue), kvadrat);

            cigli.drawAll(g);
            if (gotovo())
            {
                timer.Stop();
                DialogResult result = MessageBox.Show("Играта заврши. Нова игра ?", "Нова игра ?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                if (result == DialogResult.No)
                {
                    Application.Exit();
                }
                if (result == DialogResult.Yes)
                {
                    novaIgra();
                }
            }
            else if (cigli.lstCigli.Count == 0)
            {
                cigli   = new CiglaDoc();
                pomosna = new CiglaDoc();
                iscrtaj(g);
            }

            proverka(ball);

            ball.Draw(boja, g);
            ball.Move(kvadrat);

            graphics.DrawImageUnscaled(doublebuffer, 0, 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();
        }
Esempio n. 4
0
        void timer_Tick(object sender, EventArgs e)
        {
            Graphics g = Graphics.FromImage(doublebuffer);
            g.Clear(Color.White);
            g.DrawRectangle(new Pen(new SolidBrush(Color.Red)), ball.Bounds);
            g.FillRectangle(new SolidBrush(Color.RoyalBlue), kvadrat);

            cigli.drawAll(g);
            if (gotovo())
            {
                timer.Stop();
              DialogResult result = MessageBox.Show("Играта заврши. Нова игра ?", "Нова игра ?", MessageBoxButtons.YesNo , MessageBoxIcon.Question);

                if (result == DialogResult.No)
                { Application.Exit();}
                if (result == DialogResult.Yes) {
                    novaIgra();
                }

            }
            else if (cigli.lstCigli.Count == 0)
            {
                cigli = new CiglaDoc();
                pomosna = new CiglaDoc();
                iscrtaj(g);

            }

            proverka(ball);

            ball.Draw(boja, g);
            ball.Move(kvadrat);

            graphics.DrawImageUnscaled(doublebuffer, 0, 0);
        }