Random movement of some little objects?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Francesco77
Posts: 40
Joined: Mon Nov 16, 2020 8:16 pm

Re: Random movement of some little objects?

Post by Francesco77 » Thu Jan 07, 2021 3:12 pm

Thanks again for your help.

I will experiment a little bit with your suggested solutions.

At the moment I try to detect in which direction the little bees move currently so that I can flip or turn them in the right direction to avoid having backwards flying bees.
I can do that when I read out the positions every x milliseconds but this seems to be a little bit of "overkill".
Especially when a lot of them are flying around.

I still wonder if the direction of the movement along a path of a handdrawn line can be turned around (move to last point vs. move to first point).
That would make a lot of things easier.
In this case I could flip the bee images everytime the path direction changes.

In the meantime I will use the path movement as you suggested.
And as you wrote possibly "nobody will notice" the difference.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Random movement of some little objects?

Post by dunbarx » Thu Jan 07, 2021 4:39 pm

Hi.

If you are moving along a list of points, hopefully generated by drawing a line graphic, and want to change direction under script control, then you need to manage the list explicitly. This is doable, but requires some forethought.

Perhaps you can create a dozen or so line graphs, each beginning in a specified direction, and reset the motion of the bee so it begins to track that new list.

The issue is the smoothness of the transition. If you are already heading east, and want to restart the tracking to go north, you will see a "jump" at the moment of change.

So that group of new graphics must begin at one direction and then move quickly and smoothly to the desired direction. One such graphic might be named "eastToNorth" and is drawn so that it starts east and changes smoothly to north before going random as all the other do. Then you must, at the moment of change, know which direction the bee is currently moving. You can track the current points and determine that direction. Then call the appropriate new "main" graphic.

Doable, as I say. A nice project, and please let us know how you are getting on with it.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10099
Joined: Fri Feb 19, 2010 10:17 am

Re: Random movement of some little objects?

Post by richmond62 » Thu Jan 07, 2021 7:11 pm

BUZZZZZ.jpg
-
NOT perfect by a long, long way, but, even if anything else this may warn you of getting bogged down a bit.
Attachments
BUZZ.livecode.zip
Here's the stack.
(110.92 KiB) Downloaded 201 times

Post Reply