By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,294 Members | 2,650 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,294 IT Pros & Developers. It's quick & easy.

generate / control a number or "balls" moving inside a square

P: n/a
OJ
It's easy to control one ball (a graphic) to move and bounce inside a square.
But I don't know how to create and control a large number of balls (10 or
100) and count how many times they hit a wall of the square.

Anyone can help?? I have little experience in VB.net.

Thanks in advance.

OJ
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Design it so that each ball is a single class and create an instance of this
class on a separate thread for each ball that moves around.

Each ball will have properties (size, material that control elasticity for
bouncing, current location, momentum, direction of movement) and will know
how to draw itself in a container (another class).

Kind of basic but should get you started.

"OJ" <OJ@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
It's easy to control one ball (a graphic) to move and bounce inside a
square.
But I don't know how to create and control a large number of balls (10 or
100) and count how many times they hit a wall of the square.

Anyone can help?? I have little experience in VB.net.

Thanks in advance.

OJ

Nov 21 '05 #2

P: n/a
OJ,

I never like this graphical stuff, however in my opinion computers are that
fast that people cannot notice it if you do 100 changes in a row or do them
randomly by using more threads.

If it was my problem, than I would do it by probably by using an array and
do my complete routine in one great loop.

Instead that I instance one ball, (which is probably now already a class) I
would use an array of balls.

For each ball in my Balls
do the stuff you have now everytime with that ball
Next

Just my idea,

Cor
Nov 21 '05 #3

P: n/a
Check out the article on animation in Windows Forms Tips and Tricks.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"OJ" <OJ@discussions.microsoft.com> wrote in message
news:FD**********************************@microsof t.com...
It's easy to control one ball (a graphic) to move and bounce inside a
square.
But I don't know how to create and control a large number of balls (10 or
100) and count how many times they hit a wall of the square.

Anyone can help?? I have little experience in VB.net.

Thanks in advance.

OJ

Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.