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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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,

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top