Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I make an shape move towards another shape?

Status
Not open for further replies.

rickpro

Programmer
Sep 11, 2002
7
CA
Hello,

I am making a small mini-golf game for a computer course, I am having a problem with moving the ball towards where the aimer is set. In the form dragdrop settings I have vars set to accept the x and y positions. Is there a way I can move the ball towards these positions? I have a scroll bar setting how fast the ball moves and right now when you click the shoot button it moves the ball over however many spaces the hscroll is set to using a timer. Is what I am wanting to do possible? Is there another way I can do this perhaps? Thanks!!
Rick
 

Yes it is possible, but you are going to need to use some math. Take for example you want to move the top of your shape 100 and the left of your shape 10. The first thing you will need to know is which distance is greater. Then you will need to figure out a ratio of top versus left so that your image moves in a straight line. Once you have these you will then need to increment or decrement until you have reached desired position. Now if you are doing this in 3D this a whole different set of calcualtions. You will then need to know perspective and based upon movement size of image displayed to simulate moving either away or closer. Take a look at a high school algebra book. You will find many ideas in there on how to figure out how to calcualte your X-Y-(and if 3D Z) properties.

Good Luck

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top