[VB6] Point-to-point movement
[VB6] Point-to-point movement
[VB6] Point-to-point movement
[VB6] Point-to-point movement
[VB6] Point-to-point movement
[VB6] Point-to-point movement [VB6] Point-to-point movement [VB6] Point-to-point movement [VB6] Point-to-point movement [VB6] Point-to-point movement [VB6] Point-to-point movement [VB6] Point-to-point movement [VB6] Point-to-point movement
[VB6] Point-to-point movement [VB6] Point-to-point movement
[VB6] Point-to-point movement
Go Back  Xtreme Visual Basic Talk > > > [VB6] Point-to-point movement


Reply
 
Thread Tools Display Modes
  #1  
Old 11-06-2011, 05:05 AM
jaberwalk jaberwalk is offline
Newcomer
 
Join Date: Nov 2011
Posts: 1
Default [VB6] Point-to-point movement


Hello. (Sorry for my grammar, cause i'm russian)
The idea is:

There are two shapes (А and B), shape (А) has to move (or reach exact coordinates, whatever) to shape (B). (left part of image)

Movement has to be smoothly (not just jump into x,y)
The problem is:
How to make it moving?

PHP Code:
A.A.10
A
.A.10 or A.move
Isn
't good 
Because in this case shape (A) moves diagonally.
That is OK, when target is located like in the picture (1.).
But what should i do, if shape (B) is located like in (2.) ??
Shape (A) will move to nowhere.

Thanks
Attached Images
File Type: jpg gogo.JPG (10.5 KB, 8 views)
Reply With Quote
  #2  
Old 11-06-2011, 03:39 PM
surfR2911 surfR2911 is offline
Contributor
 
Join Date: Oct 2009
Posts: 719
Default Move sprite towards (or follow) point, sprite, or mouse click

Hello jaberwalk and welcome to the forum!

Maybe I'm being dense (stupid) or something is getting lost in translation, but I don't really understand why you are having trouble writing the code to move from A to B.

It really doesn't make any difference whether you are dealing with case #1 or case #2 -- the coding technique is essentially the same.

You calculate (or store and continually update) the x & y position value of "B" (the point where you want "A" to move toward).

To have it move non-directly (slowly) from A to B you have to divide the X and Y distances
( x distance = b.x - a.x,
y distance = b.y -a.y)

..by some at interval --for example .25 for quarter-way-there interval movement during each timer loop (or other triggering event).

Of course if B is moving at the same time A is moving that can make things more involved if you want "smoothing" of the movement calculation during each timer loop iteration.

A least squares polynomial calculation can sometimes provide smoothing of a path along a curve for a particular set of path moving points:
polynomial least squares fit for a set of points in VB6

I always suggest to new members that they try to do a search of the forum before asking questions.

If you had you might have found these code samples:
This forum code library thread dealing with moving from A to B
..some working examples/demos of the classic "move to click" routine
are attached to these posts:
zanth_quareni demo
Flamingeye demo

Last edited by surfR2911; 11-06-2011 at 03:55 PM.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
[VB6] Point-to-point movement
[VB6] Point-to-point movement
[VB6] Point-to-point movement [VB6] Point-to-point movement
[VB6] Point-to-point movement
[VB6] Point-to-point movement
[VB6] Point-to-point movement [VB6] Point-to-point movement [VB6] Point-to-point movement [VB6] Point-to-point movement [VB6] Point-to-point movement [VB6] Point-to-point movement [VB6] Point-to-point movement
[VB6] Point-to-point movement
[VB6] Point-to-point movement
 
[VB6] Point-to-point movement
[VB6] Point-to-point movement
 
-->