Page 2 of 3
Re: Random movement of some little objects?
Posted: Wed Dec 30, 2020 1:01 pm
by richmond62
Parts of the graphical line which are straight lines are described bei two points only regardless the distance.
unfortunately
Code: Select all
move to the points of graphic "XXX"
will do
EXACTLY WHAT IT SAYS ON THE PACKET . . .
So: my experience is that
IFF you want to animate something along a curse you need to generate a curve with a large
number of points very close to each other to avoid any visible jerkiness.
-
-
This is a little stack I just knocked up that generates a half circle curve and then sends a 'bee' along it: from this you should
be able to see what I am getting at.
Of course you can make the graphic curve invisible and so on.

Re: Random movement of some little objects?
Posted: Wed Dec 30, 2020 3:12 pm
by dunbarx
Hi.
It is true that a random string of points, generated by script, will appear jerky for the reasons you mentioned. The random changes in direction, followed by randomly long distances to the next point in the list, are what we perceive as jerkiness.
So you need to generate a random list of points where each new point is only a little bit different from the previous. But this will not "move" the object too far, being essentially a "random walk" exercise. The object will move smoothly and randomly, but very near its starting point.
That list has to have a "sense" of direction, in that its elements are still random, but retain a directional trend even as they continue their randomness. This can easily be done.
The points of a curve, however convoluted, already do that, since its points are strung out in a directionally sequential fashion as the curve is physically drawn. One cannot draw a curve in any other way.
So my question is this. Apart from the simple joy of writing a curve-like list of random points, why bother, since a graphic already does that, can be hidden, and works a treat?
Craig
Re: Random movement of some little objects?
Posted: Wed Dec 30, 2020 3:44 pm
by richmond62
But this will not "move" the object too far
?
You can have a curve with thousands of points that carries an object as far as you like.
Mind you, generating anything beyond rather obvious sections and cycles generated using sine and cosine combinations
will prove a grind that is probably not worth the effort.
Re: Random movement of some little objects?
Posted: Wed Dec 30, 2020 5:20 pm
by dunbarx
?
A random walk is one where an object is moved randomly, point by point. When this is run, the object stays very near its starting position, since each change in position ought never to produce a reasonable travel in any particular direction. This is a law of averages thing; it could happen, it is just not likely.
I mentioned this when I spoke about small random changes in a list of points, in the context of reducing jerkiness. Pure random will not do. You have to have a "goal", groupings of points that have a "direction", randomly sprinkled throughout the list, in order to get the object to trace a reasonable visual path. And all these groups have to follow each other, or you get a "jerk" between the groups.
So the generation of a random list, for this purpose, has to have a certain amount of order to it.
I am a fan of following a graphic. The way they are drawn produces the type of point list the OP is after.
Craig
Re: Random movement of some little objects?
Posted: Wed Dec 30, 2020 6:04 pm
by jacque
You might get better results if you let LC do it for the entire graphic rather than trying to script every segment of the move.
Code: Select all
move img x to the points of grc y in 0.5 seconds without waiting
The engine should smooth out the hops this way. You're right that only the minimum number of points are used to define a graphic.
You can use your variable's list instead of "the points of grc y" but it isn't necessary.
Re: Random movement of some little objects?
Posted: Wed Dec 30, 2020 11:14 pm
by dunbarx
Jacque.
Draw a graphic and let the object move to its points.
This is the "correct" solution to the original OP issue. Look back in this thread a bit and you will see. The discussion at this point is off in the weeds, talking about generating a list of points under script control, instead of letting a graphic do the walking. Making such a list is easy. Making it work like a list generated by the drawing of a curve requires more effort. It is not, in my opinion, apart from the pleasure in doing so, er, worth doing so.
Craig
Re: Random movement of some little objects?
Posted: Thu Dec 31, 2020 3:23 am
by jacque
@Craig, I've been sort of half following this thread. My intention was just to agree with you. Scripting the hops won't ever be as smooth as letting the engine do it.
Re: Random movement of some little objects?
Posted: Thu Dec 31, 2020 3:54 am
by dunbarx
Jacque.
Hi.
I will stop work just to fool around with LC, to create, say, a random yet "smooth" list of points solely from a handler. It helps, of course, that I do not have to report to anyone.
Anyway, I laid out the method to create such a list, but I don't think I will pursue it.
Craig
Re: Random movement of some little objects?
Posted: Thu Dec 31, 2020 9:10 am
by Francesco77
Thank you all for your help and suggestions.
One reason I tried using a list of points instead of letting LC do the work was that it is possible to change the direction of the movement this way.
I worked through the list of points in reverse order and flipped the image of the moved objects each time the direction changed.
Maybe this is also possible when LC moves the objects along the curves but I did not find out how to do it

Re: Random movement of some little objects?
Posted: Thu Dec 31, 2020 3:39 pm
by dunbarx
Hi.
Do you need to control the movement while it is running? Otherwise, if you have been following this thread, you see that, although possible to create a "smooth" list of points, such a task requires effort well beyond the simple random point generator I suggested early on. That post was short-sighted in the context of your needs.
I was ready to set this aside. But if you have good reason to pursue it, let me know, and we might just keep it going.
Craig
Re: Random movement of some little objects?
Posted: Thu Dec 31, 2020 5:54 pm
by Newbie4
Francesco77 wrote: Thu Dec 31, 2020 9:10 am
Thank you all for your help and suggestions.
One reason I tried using a list of points instead of letting LC do the work was that it is possible to change the direction of the movement this way.
I worked through the list of points in reverse order and flipped the image of the moved objects each time the direction changed.
Maybe this is also possible when LC moves the objects along the curves but I did not find out how to do it
Instead of using a list of points, draw the path using the freehand tool
from
https://sites.google.com/a/pgcps.org/li ... -and-paths
4. Moving it along a Set Path - You can "program" objects to move along a set path.
You draw a path with the "Freehand" tool from the tools Palette (let's call it "path" - name it in the property inspector), then you add the line (or a similar one):
Code: Select all
move the button "box" to the points of the graphic "path" in 5 secs
(See the file MovingAlongAPath for a crude screenshot of how to do it
https://docs.google.com/a/pgcps.org/vie ... jM1OTRiOTE)
You can set the graphic "path" not visible which makes the game more interesting
Re: Random movement of some little objects?
Posted: Thu Dec 31, 2020 6:40 pm
by richmond62
You draw a path with the "Freehand" tool from the tools Palette
Indeed you can: however, unless you have an extremely jittery hand, there will be very few points along your path.
Re: Random movement of some little objects?
Posted: Thu Dec 31, 2020 6:51 pm
by dunbarx
Newbie, have you read this thread?
Craig
Re: Random movement of some little objects?
Posted: Thu Dec 31, 2020 7:57 pm
by Newbie4
Yes. The original post described it as a little game for kids. The poster was looking for an easier way to create random moving figures. He/she was even willing to just find or buy such scripts. I was just reiterating the easiest way without the having to create complex equations. I was reinforcing what you just said.
Too bad there isn't a way to control the number of points generated in a graphic (larger sampling) or a "smooth" function. At best, you can control the speed to hide the jaggedness of the graphic.
Thanks
Re: Random movement of some little objects?
Posted: Thu Dec 31, 2020 10:28 pm
by dunbarx
I suppose you could go through the list and insert intermediate points that "fit" between them. But a line graph does such a good job in its own right that I do not see the need.
Craig