This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2008-07-07 12:08:32

NXTGeek
Scratcher
Registered: 2008-03-27
Posts: 100+

Rope simlation.

In this forum thread I will tell you what exactly a simple rope simulation dose, then general concept of one and then into the nitty gritty(well not that gritty) coding. Near the end I will provide a link to my rope simulation project.

-WHAT IS A ROPE SIMULATION AND WHAT DOSE IT LOOK LIKE?-

Well, to put it simply, a rope simulation is a collcection of veticies and lines that looks and behaves like a rope. A good rope simulator has anywhere from 4 to 10 or mybe more vertcies. A pen sprite is also required to draw the lines between the vertecies. The nasic core code in the simluation basically tells a vertex to move twards the vetex in front of it if that vertex is to far away. I.E. follow the leader.

-WHAT ARE SOME MORE SPACIFICS ON THIS CONCEPT?-

Lets delve a little deeper. Just for referance v1 is the vertex in front and v2 is the vetex that follows v1.

First we must define the maximum distance between the two vertecies before v2 starts o move. lets its 10. So:

if(distance_to_object(v1) > 10)
{
point_direction(self.x,self.y, v1.x,v1.y)
self.speed = (distance_to_object(v1) - 10)
}

This is a little code in GML that basically tells v2 to move twards v1 with a step large enough to compensate for the distance beond 10. (the maximum distance)

If this was a little comfusing plz leave a comment or you could look at the coding in my project http://scratch.mit.edu/projects/NXTGeek/190867

I hope this info helps.

Offline

 

Board footer