# Earthworm!

**URL:** <https://forum.kirupa.com/t/earthworm/184292>\
**Category:** Uncategorized\
**Created:** [April 4, 2006, 3:20am UTC](https://forum.kirupa.com/t/earthworm/184292 "2006-04-04T03:20:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mofongo9](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@mofongo9](https://forum.kirupa.com/u/mofongo9)\
**Post date:** [April 4, 2006, 3:20am UTC](https://forum.kirupa.com/t/earthworm/184292/1 "2006-04-04T03:20:50Z")

</div>

i made an earthworm effect out of purecode  
make sure you set the framerate to 50 fps  
edit things like fbseparation which says the distance between the front and back of the worm and maxcurve which says the maximum amount of curve the earthworm can have and maxinterval which says the amount of time between the full movements of the worm.

```auto

fbseparation = 40;
separation = 15;
bspot = 0;
fspot = bspot+fbseparation;
maxinterval = 30;
interval = maxinterval;
maxcurve = 50;
_root.createEmptyMovieClip("back", 1);
_root.createEmptyMovieClip("front", 2);
_root.createEmptyMovieClip("middle", 3);
_root.createEmptyMovieClip("curve", 4);
setbspot = function () {
    bspot += fbseparation;
    cspot -= maxcurve;
};
setfspot = function () {
    fspot += fbseparation;
    cspot += maxcurve;
};
with (back) {
    beginFill(0xFF99CC, 80);
    lineStyle(5, 0x000000, 100);
    lineTo(15, 0);
    lineStyle(5, 0x000000, 0);
    lineTo(15, 15);
    lineStyle(5, 0x000000, 100);
    lineTo(0, 15);
    lineTo(0, 0);
    _y += 100;
}
with (front) {
    beginFill(0xFF99CC, 80);
    lineStyle(5, 0x000000, 100);
    lineTo(15, 0);
    lineTo(15, 15);
    lineTo(0, 15);
    lineStyle(5, 0x000000, 0);
    lineTo(0, 0);
    _y += 100;
}
cspot = front._y-maxcurve;
onEnterFrame = function () {
    fbseparation += .25;
    if (front._x>550 && back._x>550) {
        front._x = -15;
        fspot = -15;
        back._x = -fbseparation-15;
        bspot = -fbseparation-15;
    }
    interval -= 1;
    if (interval == maxinterval/2) {
        setfspot();
    }
    if (interval == 0) {
        setbspot();
        interval = maxinterval;
    }
    if (front._x != fspot) {
        front._x += (fspot-front._x)/5;
    }
    if (back._x != bspot) {
        back._x += (bspot-back._x)/5;
    }
    if (curve._y != cspot) {
        curve._y += (cspot-curve._y)/5;
    }
    curve._x = (front._x+back._x+15)/2;
    with (middle) {
        clear();
        beginFill(0xFF99CC, 80);
        lineStyle(5, 0x000000, 100);
        moveTo(back._x+15, back._y);
        curveTo(_root.curve._x, _root.curve._y, front._x, front._y);
        lineStyle(5, 0x000000, 0);
        lineTo(front._x, front._y+_root.separation);
        lineStyle(5, 0x000000, 100);
        curveTo(_root.curve._x, _root.curve._y+_root.separation, back._x+15, back._y+_root.separation);
        lineStyle(5, 0x000000, 0);
        lineTo(back._x+15, back._y);
    }
};

```

the worm gets longer over time. to edit that feature out, take out line 43  
swf:  
[http://img471.imageshack.us/my.php?image=earthworm7ep.swf](http://img471.imageshack.us/my.php?image=earthworm7ep.swf)

---

<div class="post-metadata">

**Author:** ![mofongo9](https://avatars.discourse-cdn.com/v4/letter/m/a9adbd/32.png) [@mofongo9](https://forum.kirupa.com/u/mofongo9)\
**Post date:** [April 4, 2006, 12:55pm UTC](https://forum.kirupa.com/t/earthworm/184292/2 "2006-04-04T12:55:50Z")

</div>

aww i thought it was pretty cool but i guess no one else does

---

<div class="post-metadata">

**Author:** ![Templarian](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/templarian/32/7152_2.png) [@Templarian](https://forum.kirupa.com/u/Templarian)\
**Post date:** [April 4, 2006, 1:00pm UTC](https://forum.kirupa.com/t/earthworm/184292/3 "2006-04-04T13:00:18Z")

</div>

… its cool its just when would it fit into a site?

… just make like 100 of them going accross the screen and it will be better.

---

<div class="post-metadata">

**Author:** ![rmo518](https://avatars.discourse-cdn.com/v4/letter/r/f19dbf/32.png) [@rmo518](https://forum.kirupa.com/u/rmo518)\
**Post date:** [April 4, 2006, 2:08pm UTC](https://forum.kirupa.com/t/earthworm/184292/4 "2006-04-04T14:08:33Z")

</div>

Yeah, it’s a cool novelty. It sounds strange, but the other day I was scooting strip of paper around like an inch wormand thinking, hmmm . . . how would you animate something like that in Flash. Well, now I know.

---

<div class="post-metadata">

**Author:** ![mprzybylski](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/mprzybylski/32/613_2.png) [@mprzybylski](https://forum.kirupa.com/u/mprzybylski)\
**Post date:** [April 4, 2006, 6:20pm UTC](https://forum.kirupa.com/t/earthworm/184292/5 "2006-04-04T18:20:22Z")

</div>

it’s a cool effect no doubt. maybe you can extend it by making it (like a top view) go around from random to random place on the stage?

good work nonetheless.

---

<div class="post-metadata">

**Author:** ![vini](https://avatars.discourse-cdn.com/v4/letter/v/c77e96/32.png) [@vini](https://forum.kirupa.com/u/vini)\
**Post date:** [April 6, 2006, 10:52pm UTC](https://forum.kirupa.com/t/earthworm/184292/6 "2006-04-06T22:52:52Z")

</div>

Nice piece of code…:A+:
