[Tutor] Ball in Box
Alan Gauld
alan.gauld at btinternet.com
Sun Apr 13 16:48:49 CEST 2008
"brebreman3" <sbigtymers3 at yahoo.com> wrote
> I have a program i am trying to create where the user clicks inside
> of a red
> parameter inside of the window. The user has an unlimited amount of
> clicks
> in order to create their own pool table. I would like for the ball
> to
> bounce inside of the pool table they just created and for it to fall
> inside
> of a hole that is shown on the pool table.
This will require a fairly good understanding of basic geometry.
Is your math level good enough to understand how this would
be modelled mathematically? If not you might find this quite
tough to get working. You can probably find sample code on
the net but if it doesn't work it will be hard to debug.
OTOH if your math skill is good then this shouldn't be too hard.
Can you tell us more about what you are using and what you
find difficult?
> I already have the users unlimited clicks and the red parameter
What are you drawing this on? Is it a GUI? If so, which one and
which widget?
> inside but I don't have a clue how to get the ball to bounce
> inside of the pool table and for the pocket to be created
> inside the pool table.
Do you know how to make a ball move? Forget the bouncing
just get them to move in a staight line for a fixed distance.
Then get them to stop when the meet the perimeter.
Then calculate the angles and set them in motion again.
Finally detect when they reach the hole.
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list