
-----------------------------------
zylum
Sun Jan 16, 2005 5:34 pm

Worm Class!!!
-----------------------------------
this is a turing version of the worm thing in my sig... 

class WORMCLASS
    export INITIALIZE, MOVEWORM, DRAWWORM

    type WORMDATA :
        record
            _X : real
            _Y : real
        end record

    var WORM : flexible array 1 .. 0 of WORMDATA
    var ANG : real
    var SPD : real
    var CLR : int
    var RAD : int
    var ANGSPD : real

    proc INITIALIZE (x, y, c, r, l : int, a, s, as : real)
        var tx : real := x
        var ty : real := y
        new WORM, l
        ANG := a
        SPD := s
        CLR := c
        RAD := r
        ANGSPD := as
        if tx < 0 or tx > maxx or ty < 0 or ty > maxy then
            tx := Rand.Int (0, maxx) / 2 + maxx / 4
            ty := Rand.Int (0, maxy) / 2 + maxy / 4
        end if
        for i : 1 .. l
            WORM (i)._X := tx
            WORM (i)._Y := ty
        end for
    end INITIALIZE

    proc MOVEWORM
        ANG := (ANG + Rand.Real * ANGSPD * 2 - ANGSPD) mod 360
        WORM (1)._X += cos (ANG) * SPD
        WORM (1)._Y += sin (ANG) * SPD

        if WORM (1)._X < 0 then
            WORM (1)._X := 0
        elsif WORM (1)._X > maxx then
            WORM (1)._X := maxx
        end if
        if WORM (1)._Y < 0 then
            WORM (1)._Y := 0
        elsif WORM (1)._Y > maxy then
            WORM (1)._Y := maxy
        end if

        for i : 2 .. upper (WORM)
            WORM (i)._X -= (WORM (i)._X - WORM (i - 1)._X) / 2
            WORM (i)._Y -= (WORM (i)._Y - WORM (i - 1)._Y) / 2
        end for
    end MOVEWORM

    proc DRAWWORM
        for i : 1 .. upper (WORM)
            drawfilloval (round (WORM (i)._X), round (WORM (i)._Y), RAD + 3, RAD + 3, 7)
        end for
        for i : 1 .. upper (WORM)
            drawfilloval (round (WORM (i)._X), round (WORM (i)._Y), RAD, RAD, CLR)
        end for
    end DRAWWORM
end WORMCLASS

setscreen ("offscreenonly, graphics:300;300, nobuttonbar")

var worm : array 1 .. 4 of ^WORMCLASS

for i : 1 .. upper (worm)
    new WORMCLASS, worm (i)
    worm (i) -> INITIALIZE (-1, -1, Rand.Int (80, 103), Rand.Int (2, 7), Rand.Int (20, 150), Rand.Int (1, 360), 1, Rand.Real / 2 + 0.5)
end for

loop
    for i : 1 .. upper (worm)
        worm (i) -> MOVEWORM
        worm (i) -> DRAWWORM
    end for
    View.Update
    delay (10)
    cls
end loop

-----------------------------------
Delos
Sun Jan 16, 2005 6:35 pm


-----------------------------------
Zylum strikes again.

Dude...what can I say, other than You are most definitely You.

-----------------------------------
Cervantes
Sun Jan 16, 2005 6:58 pm


-----------------------------------
*/me is shocked*
Thanks for the code Zylum!  Another great program to add to my "Zylum" folder. :)
+40 BITS

-----------------------------------
zylum
Sun Jan 16, 2005 10:52 pm


-----------------------------------
thanks for the comments :wink: 

people keep asking me how i did my sig so i thought id post the source in turing.

-----------------------------------
[Gandalf]
Sun Jan 16, 2005 11:54 pm


-----------------------------------
Cool! *too bad I can't see your sig :? *
The worms look really... Lifelike  :)

-----------------------------------
TheZsterBunny
Mon Jan 17, 2005 4:16 am


-----------------------------------
hey, thanks

^_^


-Z

--edit--
...still don't get it tho'

--edit--
lol. noticed you still followed the actionscript naming conventions.

i'mma try to redo it in actionscript.

--edit-- 
don't know enought actionscript.

i'mma do it in java

--edit--
*sigh*
almost there, but can't quite fix it.

--edit-- 
couldn't sleep this eve. here's a modification on your worms.

% Glow WORMS
class WORMCLASS
    export INITIALIZE, MOVEWORM, DRAWWORM, LONGWORM, SHORTWORM, COLORWORM, THINWORM, FATWORM

    type WORMDATA :
        record
            _X : real
            _Y : real
        end record

    var WORM : flexible array 1 .. 0 of WORMDATA
    var ANG : real
    var SPD : real
    var CLR : int
    var RAD : int
    var ANGSPD : real

    proc INITIALIZE (x, y, c, r, l : int, a, s, as : real)
        var tx : real := x
        var ty : real := y
        new WORM, l
        ANG := a
        SPD := s
        CLR := c
        RAD := r
        ANGSPD := as
        if tx < 0 or tx > maxx or ty < 0 or ty > maxy then
            tx := Rand.Int (0, maxx) / 2 + maxx / 4
            ty := Rand.Int (0, maxy) / 2 + maxy / 4
        end if
        for i : 1 .. l
            WORM (i)._X := tx
            WORM (i)._Y := ty
        end for
    end INITIALIZE

    proc MOVEWORM
        ANG := (ANG + Rand.Real * ANGSPD * 2 - ANGSPD) mod 360
        WORM (1)._X += cos (ANG) * SPD
        WORM (1)._Y += sin (ANG) * SPD

        if WORM (1)._X < RAD + 3 then
            WORM (1)._X := RAD + 3
        elsif WORM (1)._X > maxx - (RAD + 3) then
            WORM (1)._X := maxx - (RAD + 3)
        end if
        if WORM (1)._Y < RAD + 3 then
            WORM (1)._Y := RAD + 3
        elsif WORM (1)._Y > maxy - (RAD + 3) then
            WORM (1)._Y := maxy - (RAD + 3)
        end if

        for i : 2 .. upper (WORM)
            WORM (i)._X -= (WORM (i)._X - WORM (i - 1)._X) / 2
            WORM (i)._Y -= (WORM (i)._Y - WORM (i - 1)._Y) / 2
        end for
    end MOVEWORM

    proc DRAWWORM
        var r, g, b : real
        RGB.GetColor (CLR, r, g, b)
        for i : 1 .. upper (WORM)
            drawfilloval (round (WORM (i)._X), round (WORM (i)._Y), RAD + 3, RAD + 3, RGB.AddColor (0.1 * r, 0.1 * g, 0.1 * b))
        end for
        for i : 1 .. upper (WORM)
            drawfilloval (round (WORM (i)._X), round (WORM (i)._Y), RAD + 2, RAD + 2, RGB.AddColor (0.3 * r, 0.3 * g, 0.3 * b))
        end for
        for i : 1 .. upper (WORM)
            drawfilloval (round (WORM (i)._X), round (WORM (i)._Y), RAD + 1, RAD + 1, RGB.AddColor (0.5 * r, 0.5 * g, 0.5 * b))
        end for
        for i : 1 .. upper (WORM)
            drawfilloval (round (WORM (i)._X), round (WORM (i)._Y), RAD, RAD, RGB.AddColor (0.9 * r, 0.9 * g, 0.9 * b))
        end for
        for i : 1 .. upper (WORM)
            drawdot (round (WORM (i)._X), round (WORM (i)._Y), CLR)
        end for
    end DRAWWORM

    proc LONGWORM
        new WORM, upper (WORM) + 1
        WORM (upper (WORM))._X := WORM (upper (WORM) - 1)._X;
        WORM (upper (WORM))._Y := WORM (upper (WORM) - 1)._Y;
    end LONGWORM

    proc SHORTWORM
        new WORM, upper (WORM) - 1
    end SHORTWORM

    proc COLORWORM
        CLR := Rand.Int (80, 103)
    end COLORWORM

    proc THINWORM
        if RAD > 4 then
            RAD -= 1
        end if
    end THINWORM

    proc FATWORM
        if RAD < 13 then
            RAD += 1
        end if
    end FATWORM
end WORMCLASS

setscreen ("offscreenonly, graphics:300;300, nobuttonbar")
colorback (black)
cls
var worm : array 1 .. 5 of ^WORMCLASS

for i : 1 .. upper (worm)
    new WORMCLASS, worm (i)
    worm (i) -> INITIALIZE (-1, -1, Rand.Int (80, 103), Rand.Int (2, 7), Rand.Int (20, 150), Rand.Int (1, 360), 1, Rand.Real / 2 + 0.5)
end for

loop
    for i : 1 .. upper (worm)
        worm (i) -> MOVEWORM
        worm (i) -> DRAWWORM
        if Rand.Int (0, 10) = 9 then
            worm (i) -> LONGWORM
        end if
        if Rand.Int (0, 10) = 2 then
            worm (i) -> SHORTWORM
        end if
        if Rand.Int (0, 50) = 23 then
            worm (i) -> COLORWORM
        end if
        if Rand.Int (0, 30) = 17 then
            worm (i) -> FATWORM
        end if
        if Rand.Int (0, 30) = 12 then
            worm (i) -> THINWORM
        end if
    end for
    drawbox (0, 0, maxx, maxy, 7)
    View.Update
    delay (10)
    cls
end loop



-----------------------------------
apomb
Mon Jan 17, 2005 3:51 pm


-----------------------------------
LOL nice modification Zster! ... maybe you could submit your java programs in the java section so people who do java and  not turing can see it too!  :D  gj tho, i dont know how you keep cranking out these programs tho zylum! its awsome

-----------------------------------
Amreen
Sat Jan 22, 2005 12:50 pm


-----------------------------------
really kool...lolz...nice job! :D u guyz really love turing! :shock:

-----------------------------------
ste_louis26
Fri Jan 28, 2005 4:28 pm


-----------------------------------
awesome program!!! :D  like the worms
