I don't have much time on the forum lately but I did this tonight. It makes random trees and stars. Hope you like it.

I will work more if time permits. Good luck to everyone.

EDIT

This newest version is the final version, please try this one.

Code if you dare read my unoptimized and heavily rushed handy work.

`' Lindenmayer system explorer`

' Ryan Burnside (Pixel_Outlaw) 2008

' sloppy and unoptimiezed Huzzah?

Strict

Framework BRL.GLMax2D

Import BRL.Random

Import BRL.Math

Import BRL.LinkedList

SeedRnd(MilliSecs())

' first we set aside an old list used just for drawing

Global old_list:TList = New TList

' now we set aside a new list which will be used to make new branches

Global new_list:TList = New TList

' set how many branches each branch generates

Global splits:Float = 3

' the angle of spread

Global spread:Float = 45

' reduction of each generation

Global reduction:Float =.70

Global sub_angle:Float = spread / (splits - 1)

Function create_branch:branch(x:Float, y:Float, angle:Float, length:Float)

Local b:branch = New branch

b.x = x

b.y = y

b.length = length

b.angle = angle

b.x2 = b.x + Cos(b.angle) * b.length

b.y2 = b.y + Sin(b.angle) * b.length

Return b

End Function

Function spawn_new_generation()

Local temp_list:TList = New TList

' first branch each branch in the new list

For Local b:branch = EachIn(new_list)

' remove from new list and add to old list

ListRemove(new_list, b)

ListAddLast(old_list, b)

' create new branches from the length and angle of old

Local e:Int = Rand(0, 2)

Local sub_angle_a = spread / (splits - e)

Local start_angle:Float = b.angle - (spread / 2.0)

For Local i = 0 To splits - e

If Rand(0, 9)

Local g:branch = create_branch(b.x2, b.y2, start_angle + (i * sub_angle_a) + Rand(- 10, 10), b.length * reduction * Rand(70, 100) / 100)

ListAddLast(temp_list, g)

EndIf

Next

Next

new_list = temp_list

End Function

Function draw_lists()

For Local a:branch = EachIn(old_list)

DrawLine(a.x, a.y, a.x2, a.y2)

Next

For Local b:branch = EachIn(new_list)

DrawLine(b.x, b.y, b.x2, b.y2)

Next

End Function

Function find_angle:Float(x:Float, y:Float, x2:Float, y2:Float)

Local direction:Float = ATan2(y - y2, x - x2) + 180

Return direction

End Function

Function find_distance:Float(x:Float, y:Float, x2:Float, y2:Float)

' returns distance between two points

' using c= sqr(a^2 + b^2)

Local x_dist = x - x2

Local y_dist = y - y2

Return Sqr((x_dist * x_dist) + (y_dist * y_dist))

EndFunction

' make a branch type

Type branch

Field x:Float, y:Float, x2:Float, y2:Float, angle:Float, length:Float

End Type

AppTitle="Lindenmayer Nocturne"

Graphics 640, 480

SetBlend(LIGHTBLEND)

SetAlpha(1)

Global timer:Int = 0

While 1

If Not timer

Cls

' goodnight moon

SetColor(255, 255, 255)

DrawOval(Rand(640), Rand(64, 128), 32, 32)

' draw ground

'draw ground

For Local i = 0 To 7

DrawLine(0, 240 + i * i, 640, 240 + i * i)

Next

'draw stars

For Local i = 0 To 16

Plot(Rand(0, 640), Rand(0, 240))

Next

' draw 10 trees of varying size

SetColor(100, 255, 200)

SetAlpha(.5)

For Local c:Int = 0 To 35

' the angle of spread

Local z:Float = Rand(0, 30)

ListAddLast(new_list, create_branch(Rand(640), 240 + (240 / z), 270, 212 / z))

For Local i = 0 To 6

spawn_new_generation

Next

draw_lists

ClearList(old_list)

ClearList(new_list)

Next

Flip

timer = 1000

If KeyHit(KEY_ESCAPE)

End

End If

Else

timer:-1

End If

Wend