Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Moving Fractal Tree
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
fishtastic




PostPosted: Fri Feb 15, 2008 3:58 pm   Post subject: Moving Fractal Tree

Not as good as i expected. but I wanted to do this Mr. Green

Turing:
var tree : collection of
    record
        l : int
        a : real
        c : int
        t : int
        b : int
        son : array 1 .. 6 of pointer to tree
    end record

const d := 5 % mess around with this var
const t := Rand.Int (2, 3) % and this var
var s := -0.2
var acc := 0.01
var col : array 1 .. d of int
var roots : array 1 .. t of pointer to tree
var x : array 1 .. t of int

proc initialize (var t : pointer to tree, c, depth : int)
    new tree, t
    if c <= depth then
        t -> l := floor ((1.6 ** (depth - c) * Rand.Int (15, 30)))
        t -> a := Rand.Int (-60, 60) + 90
        if c = 1 then
            t -> a := 90
        end if
        t -> c := c
        t -> t := (depth - c) * 3
        t -> b := Rand.Int (depth - c, 6)
        for i : 1 .. t -> b
            initialize (t -> son (i), c + 1, depth)
        end for
    end if
end initialize

proc draw (t : pointer to tree, c, depth, x, y : int)
    if c <= depth then
        if c = depth then
            Draw.FillOval (x, y, 4, 4, col (t -> c))
        else
            var dx := round (cosd (t -> a) * t -> l)
            var dy := round (sind (t -> a) * t -> l)
            Draw.ThickLine (x, y, x + dx, y + dy, ceil (1.25 ** t -> t), col (t -> c))
            for i : 1 .. t -> b
                draw (t -> son (i), c + 1, depth, x + dx, y + dy)
            end for
        end if
    end if
end draw

proc move (t : pointer to tree, c, depth, a : real)
    if c <= depth then
        t -> a += a
        for i : 1 .. t -> b
            move (t -> son (i), c + 1, depth, a * 2)
        end for
    end if
end move

View.Set ("offscreenonly")
colorback (102)
for i : 1 .. d div 2
    col (i) := RGB.AddColour (0.2 + 0.1 * i, 0.1 + 0.1 * i, 0)
end for
for i : d div 2 .. d
    col (i) := RGB.AddColour (0.0, 0.1 * i, 0)
end for
for i : 1 .. t
    initialize (roots (i), 1, d)
    x (i) := Rand.Int (50, maxx - 50)
end for

loop
    cls
    for i : 1 .. t
        draw (roots (i), 1, d, x (i), 0)
        move (roots (i), 1, d, s)
    end for
    s += acc
    if s > 0.2 or s < -0.2 then
        acc := -acc
    end if
    View.Update
end loop

Sponsor
Sponsor
Sponsor
sponsor
Mackie




PostPosted: Fri Feb 15, 2008 4:29 pm   Post subject: RE:Moving Fractal Tree

O wow, that's awesome. I'm adding this to my lst of things to research/create.
SIXAXIS




PostPosted: Fri Feb 22, 2008 8:33 am   Post subject: Re: Moving Fractal Tree

Looks great. Reminds me a bit of the trees in Far Cry 2; they move in the wind and they can regenerate after a while.
DanielG




PostPosted: Sun Feb 24, 2008 5:28 pm   Post subject: RE:Moving Fractal Tree

Its not bad, but I think it is a little too slow
McKenzie




PostPosted: Sun Feb 24, 2008 7:51 pm   Post subject: Re: Moving Fractal Tree

The key is you're on the right track, now all that's left is to play with it until it looks the way you want it to. Trust me, I've drawn many, many fractal trees in Turing. Keep playing, you'll get it.
DaveAngus




PostPosted: Tue Mar 18, 2008 9:16 am   Post subject: RE:Moving Fractal Tree

This is pretty cool. I like it.
Loading




PostPosted: Thu Nov 21, 2019 10:45 pm   Post subject: RE:Moving Fractal Tree

How do i make a plain tree? Not moving
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: