Image:
 Author: therestofguys Group: Default Filesize: 46.25 kB Date added: 2024-05-18 Rating: 5 Downloads: 582 Views: 187 Comments: 2 Ratings: 1 Times favored: 0 Made with: Algodoo v2.1.0 Tags:
|
An example I made for myself.
Reference: http://www.algodoo.com/algobox/details.php?id=244311
----------
In the spring's "postStep":
- Simplified access of the spring's lineEndPoints
endPoint0 = (entityByID((readable(entity)).lineEndPoint0));
endPoint1 = (entityByID((readable(entity)).lineEndPoint1));
- Read the lineEndPoints' pos
_pos0 = endPoint0.pos;
_pos1 = endPoint1.pos;
- Calculates the distance between _pos0 and _pos1
_dist = ((_pos0(0) - _pos1(0)) ^ 2 + (_pos0(1) - _pos1(1)) ^ 2) ^ 0.5;
- Spring size change
size = 1 * _dist;
- Convert _dist's result with 0.5 meter offset to 0.0 ~ 1.0, and limiting it with an if argument with another if argument in its 'else' state
(_dist - 0.5) / 2 < 0 ? {_percent = 0} : {(_dist - 0.5) / 2 < 1 ? {_percent = (_dist - 0.5) / 2} : {_percent = 1}};
- Simplified access to the yellow box lineEndPoint0 is attached to
Box0 = (entityByGeomID((readable(endPoint0)).geom));
- Apply _percent to Box0
Box0.text = {"" + math.ToInt(_percent * 100)} |
Last edited at 2024/05/18 13:36:55 by therestofguys
Please log in to rate this scene
|