Tree Maker - SierraKen - 09-02-2022
I know B+ has made a better one awhile back, but I've wanted to make one of these myself for years and FINALLY did it!!
It doesn't add leaves but it makes the trunk and random branches. And the land line.
It finally came to me this morning to just use PSET color plot points and to loop it and at every loop it also scans to find those PSET color plot points.
It's very simple if you take a look at the code and play around with it.
In the comments I added the PSET color not to use anywhere else on the screen for your own programs since that's where it needs those points. In the code I put where you can play around with other numbers on 2 lines.
Press the Space Bar to make another random tree.
The funny thing is, I was trying to do this yesterday but ended up making the Tesla Coil instead.
Code: (Select All) 'Tree Maker by SierraKen - September 2, 2022.
'Feel free to use this in any code.
'The screen cannot have _RGB32(255, 125, 127) because it uses that PSET point as a plot value.
Screen _NewImage(800, 600, 32)
_Title "Tree Maker - Press Space Bar for another tree - Esc to end"
start:
_Limit 20
Cls
Line (0, 500)-(800, 500), _RGB32(127, 255, 127)
Line (397, 500)-(403, 480), _RGB32(255, 127, 127), BF
PSet (400, 480), _RGB32(255, 125, 127)
limbsy = 490
size = 60
For stories = 1 To 5 '<<<<<<< Experiment with this number.
size = size - 3 '<<<<<<< Experiment with this number.
For yy = 0 To 600
For xx = 0 To 800
If Point(xx, yy) = _RGB32(255, 125, 127) Then
limbsx = xx
limbsy = yy
seconds = (Rnd * 8) + 5
s = (60 - seconds) * 6 + 180
x = Int(Sin(s / 180 * 3.141592) * size) + limbsx
y = Int(Cos(s / 180 * 3.141592) * size) + limbsy
For b = 2 To -2 Step -.1
Line (limbsx + b, limbsy)-(x + b, y), _RGB32(255, 127, 127)
Line (limbsx + b, limbsy)-(x + b, y), _RGB32(255, 127, 127)
Next b
PSet (x, y), _RGB32(255, 125, 127)
seconds = (Rnd * 9) + 47
s = (60 - seconds) * 6 + 180
x = Int(Sin(s / 180 * 3.141592) * size) + limbsx
y = Int(Cos(s / 180 * 3.141592) * size) + limbsy
For b = 2 To -2 Step -.1
Line (limbsx + b, limbsy)-(x + b, y), _RGB32(255, 127, 127)
Line (limbsx + b, limbsy)-(x + b, y), _RGB32(255, 127, 127)
Next b
PSet (x, y), _RGB32(255, 125, 127)
End If
Next xx
Next yy
Next stories
Do:
_Limit 20
a$ = InKey$
If a$ = " " Then GoTo start:
If a$ = Chr$(27) Then End
Loop
RE: Tree Maker - bplus - 09-02-2022
I'd be hard pressed to do it without a recursive sub, except I did for Binary Tree, I suppose just start with that and throw in some randomness.
About tesla coil, to my dismay I have no music to test, not even sure how to get it. I tried off CD but all that does is let me burn another CD, blah!
I am not so interested in music as to what the graphic looks like, you got a screen shot or 2?
RE: Tree Maker - SierraKen - 09-02-2022
Sure B+, I'll put up a graphic on that topic thread. There's 2 ways that I get mp3's, either I buy them off Amazon to download or I rip them off the CD's I buy using Windows Media Player.
I just made this tree maker into an orchard maker with 20 random smaller trees.
Press the space bar to make another random orchard.
Code: (Select All) 'Tree Orchard Maker by SierraKen - September 2, 2022.
'Feel free to use this in any code.
'The screen cannot have _RGB32(255, 125, 127) because it uses that PSET point as a plot value.
Screen _NewImage(800, 600, 32)
_Title "Orchard Maker - Press Space Bar for another orchard - Esc to end"
start:
_Limit 20
Cls
For y = 200 To 600
c1 = c1 + .5
Line (0, y)-(800, y), _RGB32(0, c1, 0)
Next y
c1 = 0
For trees = 1 To 40 Step 2
x2 = Rnd * 800
y2 = (Rnd * 400) + 200
Line (x2 - 3, y2)-(x2 + 3, y2 - 25), _RGB32(255, 127, 127), BF
PSet (x2, y2 - 20), _RGB32(255, 125, 127 + trees)
limbsy = 490
size = 25
For stories = 1 To 5 '<<<<<<< Experiment with this number.
size = size - .5 '<<<<<<< Experiment with this number.
For yy = 0 To 600
For xx = 0 To 800
If Point(xx, yy) = _RGB32(255, 125, 127 + trees) Then
limbsx = xx
limbsy = yy
seconds = (Rnd * 8) + 5
s = (60 - seconds) * 6 + 180
x = Int(Sin(s / 180 * 3.141592) * size) + limbsx
y = Int(Cos(s / 180 * 3.141592) * size) + limbsy
For b = 2 To -2 Step -.1
Line (limbsx + b, limbsy)-(x + b, y), _RGB32(255, 127, 127)
Line (limbsx + b, limbsy)-(x + b, y), _RGB32(255, 127, 127)
Next b
PSet (x, y), _RGB32(255, 125, 127 + trees)
seconds = (Rnd * 9) + 47
s = (60 - seconds) * 6 + 180
x = Int(Sin(s / 180 * 3.141592) * size) + limbsx
y = Int(Cos(s / 180 * 3.141592) * size) + limbsy
For b = 2 To -2 Step -.1
Line (limbsx + b, limbsy)-(x + b, y), _RGB32(255, 127, 127)
Line (limbsx + b, limbsy)-(x + b, y), _RGB32(255, 127, 127)
Next b
PSet (x, y), _RGB32(255, 125, 127 + trees)
End If
Next xx
Next yy
Next stories
size = 25
Next trees
Do:
_Limit 20
a$ = InKey$
If a$ = " " Then GoTo start:
If a$ = Chr$(27) Then End
Loop
RE: Tree Maker - SierraKen - 09-03-2022
I updated the original Tree Maker today to make grass, sky, leaves, and thinner branches but a larger tree. Press the Space Bar to make another random tree.
Tell me what you think, thanks.
Code: (Select All) 'Tree Maker by SierraKen - September 3, 2022.
'Feel free to use this in any code.
'The screen cannot have _RGB32(255, 125, 127) or _RGB32(255, 127, 127) because they use that for points as a plot value.
Screen _NewImage(1000, 600, 32)
_Title "Tree Maker - Press Space Bar for another tree - Esc to end"
start:
_Limit 20
Cls
'sky
For y = 0 To 500
blue = blue + .5
Line (0, y)-(1000, y), _RGB32(0, 0, blue)
Next y
blue = 0
'Ground
For y = 501 To 600
green = green + 2
Line (0, y)-(1000, y), _RGB32(0, green, 0)
Next y
green = 0
Line (499, 500)-(501, 480), _RGB32(255, 127, 127), BF
PSet (500, 480), _RGB32(255, 125, 127)
limbsy = 490
size = 100
For stories = 1 To 6 '<<<<<<< Experiment with this number.
size = size - 2 '<<<<<<< Experiment with this number.
For yy = 0 To 600
For xx = 0 To 800
If Point(xx, yy) = _RGB32(255, 125, 127) Then
limbsx = xx
limbsy = yy
seconds = (Rnd * 8) + 5
s = (60 - seconds) * 6 + 180
x = Int(Sin(s / 180 * 3.141592) * size) + limbsx
y = Int(Cos(s / 180 * 3.141592) * size) + limbsy
Line (limbsx + b, limbsy)-(x + b, y), _RGB32(255, 127, 127)
PSet (x, y), _RGB32(255, 125, 127)
seconds = (Rnd * 9) + 47
s = (60 - seconds) * 6 + 180
x = Int(Sin(s / 180 * 3.141592) * size) + limbsx
y = Int(Cos(s / 180 * 3.141592) * size) + limbsy
Line (limbsx, limbsy)-(x, y), _RGB32(255, 127, 127)
PSet (x, y), _RGB32(255, 125, 127)
End If
Next xx
Next yy
Next stories
For leaves = 1 To 30000
leafx = Rnd * 800
leafy = Rnd * 480
If Point(leafx, leafy) = _RGB32(255, 127, 127) Then
For sz = .25 To 4 Step .25
Circle (leafx, leafy + 4), sz, _RGB32(0, 255, 0), , , 2.5
Next sz
End If
Next leaves
Do:
_Limit 20
a$ = InKey$
If a$ = " " Then GoTo start:
If a$ = Chr$(27) Then End
Loop
RE: Tree Maker - James D Jarvis - 09-03-2022
You inspired me to fiddle with a tree generating program as well. The codes pretty different so I placed it in another thread.
|