aquaticdeity 0 Newbie Poster

Hi all,
I don't know whether my question belong here but any ways
why every browser has a built-in regex engine?

Why they have to find patterns in a http page?

aquaticdeity 0 Newbie Poster

I tried to create 10 random circles with random colors using windows forms.

The problem am not able to restrict my program to draw only 10 circles.It goes on and on.

Timer t = new Timer();
t.Interval = 1;
t.Start();
t.Tick += new EventHandler(DrawCircle);

is there any way to stop the timer after 10 counts?
So that i will call
t.stop(); after drawing 10 circles.

aquaticdeity 0 Newbie Poster

Arrays don't have a remove method, a List<T> has. Where T could be a Brick object of a to be defined Brick class. This Brick class could have a property Empty(true or false). With that property your List could figure out which Bricks to draw and which not.

Thank You it worked!!

aquaticdeity 0 Newbie Poster

I have modified the code and it works now.The brick gets disappeared.I changed from array to list and it worked.Here is the modified code.

The code is fine but the ball traces the same path,there is some logic problem in ball movement,can some one help me with that

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Breakout
{
    public partial class Form1 : Form
    {
#region variables
        private const int WIDTH = 500;
        private const int NBRICKS_PER_ROW = 10;
        private const int NBRICK_ROWS = 10;
        private const int BRICK_SEP = 2;
        private const int BRICK_WIDTH = (WIDTH - (NBRICKS_PER_ROW - 1) * BRICK_SEP) / NBRICKS_PER_ROW;
        private const int BRICK_HEIGHT = 8;
       
        Rectangle gameBall = new Rectangle(165,212,15,15);
        Rectangle gamePaddle = new Rectangle(180, 434, 72, 10);
        Rectangle nothing = new Rectangle(0, 0, 0, 0);

        List<Rectangle> brick = new List<Rectangle>();

        static Timer mytimer = new Timer();
        int yVel = 5;
        int xVel = 2;
        PaintEventArgs pt;
        Message mBox = new Message();

#endregion

        public Form1()
        {
            this.Width = WIDTH;
            this.MaximizeBox = false;            
            InitializeComponent();
    }

        private void Form1_Load(object sender, EventArgs e)
        {
            DoubleBuffered = true;
            mytimer.Tick += new EventHandler(timer_tick);          
            mytimer.Interval = 10;
            mytimer.Start();
        }

        void Brick(Brush b, Pen p, PaintEventArgs e)
        {    
            int x = 0, y = 0,count=0;
            for (int i = 0; i < 10; i++)
            {               
                for (int j = 0; j < 10; j++)
                {
                    if (i < 2) b = new SolidBrush(Color.Red);
                    else if (i >= 2 & i …
aquaticdeity 0 Newbie Poster

Constants are a very good habbit to have. They come in handy in many cases. But don't use width and height constants if you want to manipulate width and height!

Ok, but is there any built in property like brick[i,j].remove(),So as to remove the bricks.
If not how to do it then?

aquaticdeity 0 Newbie Poster

Hi god of the water, welcome at Daniweb.:)
Line 31 does absolutely nothing, so why is it there?
You are setting the Width and the Height of the Brick that is hit to zero. But in your Brick method (should call it DrawBricks!) You are using predefined constants for the Width and Height, so the Brick will never vanish. Hope this helps.

Forget to remove the declaration in line 31.
Yes am using predefined constants!! thanks
So how to remove the brick then.
Help me out!!!

aquaticdeity 0 Newbie Poster

Hi am learning c# myself.I have created a Breakout using c#.But am struck with one problem.When I run the program the paddle and the ball moves properly,but when the ball hits the brick it, the brick does not disappear.

The problem I believe is with the Invalidate() method.I think when I call invalidate() the entire bricks are redrawn including those that are deleted.Kindly look into the code and suggest me some modifications.

Most of the code is just initialization,the logic would be some 30 lines(max).Form1_paint and the timer_tick are the function that I believe the errors are there
Look into line 114;(How to make rectangle dissappear)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace Breakout
{
    public partial class Form1 : Form
    {
        private const int WIDTH = 500;
        private const int NBRICKS_PER_ROW = 10;
        private const int NBRICK_ROWS = 10;
        private const int BRICK_SEP = 2;
        private const int BRICK_WIDTH = (WIDTH - (NBRICKS_PER_ROW - 1) * BRICK_SEP) / NBRICKS_PER_ROW;
        private const int BRICK_HEIGHT = 8;
       
        Rectangle gameBall = new Rectangle(165,212,15,15);
        Rectangle gamePaddle = new Rectangle(180, 434, 72, 10);
        Rectangle[,] brick=new Rectangle[10,10];

        static Timer mytimer = new Timer();
        int yVel = 5;
        int xVel = 2;

        Message mBox = new Message();

        Graphics g;

        public Form1()
        {
            this.Width = WIDTH;
            this.MaximizeBox = false;            
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            DoubleBuffered = true;
            mytimer.Tick += new EventHandler(timer_tick);          
            mytimer.Interval = 10;
            mytimer.Start();
        }
        
        void Brick(PaintEventArgs e) …