Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / New to AGK and Need Help Making a Dynamic/Procedural Tree Generator

Author
Message
Jahhweh
4
Years of Service
User Offline
Joined: 24th Jul 2019
Location: New York
Posted: 16th Aug 2019 10:43
Quick Intro: i am basically new to programming and want to make a game as a hobby. that "game" will be growing and shaping a 2D tree, kinda like a bonsai tree but you dont have to wait decades. i foresee the player cutting branches and pulling on limbs, all while the tree is slowly getting taller and fatter. i have stumbled upon a couple programs that are close to what im trying to do ("Desktop Tree" is the most recent thing and pretty close, the rest are older videos and forum threads) and i think i have an understanding of at least most of the basic moving parts, but im having trouble wrapping my head around this. im looking for a couple pointers as to how i should be setting up my code or most likely some obvious things im missing. really any help would be greatly appreciated.

what even is this: so i was thinking i could "grow" the tree by drawing a line with a little randomness. i got this worm, as i call it, wriggling up the screen and am tracking its x and y values in an array. i was hoping to use the values in the array to make a new sprite for each new position, but i just cant sort it out.




JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 16th Aug 2019 15:45
Moved your thread so more AppGameKit peps would see it.
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 16th Aug 2019 21:29
Im not sure how much help this will be but I have created trees using fractal math
quite complex to get your head around as they use function recursion etc (means the functions
call themselves multiple times)
https://forum.thegamecreators.com/thread/222027
but it may help, also google fractal tree generation. you may find it much easier tho to create
several sprites for your tree that would make it allot easier to control ie a tree sprite animation
beginning without fruit and ending with lots of fruit at the end of the animation

fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Jahhweh
4
Years of Service
User Offline
Joined: 24th Jul 2019
Location: New York
Posted: 18th Aug 2019 02:34
thank you both! fubarpk yes that thread is a goldmine . i did mess around with your fractal math tree and that did help quite a bit. its actually really interesting playing around with the different shapes you can make. so that wind effect with drawline is actually one of the problems im having. instead of progressively changing how the fractal tree grows, it draws a new tree and shakes it about. this brought me to trying to use arrays to try to capture the tree as it grew, and then use the values to draw a line that i could turn into a sprite. thats essentially the problem im having: how to take the values in the array and use them to drawline, and then use that drawline to create a new sprite. is it possible to do this this way or should i be taking a different approach
fubarpk
Retired Moderator
19
Years of Service
User Offline
Joined: 11th Jan 2005
Playing: AGK is my friend
Posted: 18th Aug 2019 06:16 Edited at: 18th Aug 2019 07:21
if you just want different sprites ide just capture several different images with the tree
so you would call the tree algorithm several times to make your different images
with different parameters. Each of these could be saved out as an image and imported
into a sprite maker to make an animated sprite or you could just set the sprites visibility to off
set sprite visibility 1 to on then turn off 1 and turn on 2 etc while it cycles through the sprites
a timer event could be used.

goodluck


Edited this kinda gives the growing effect your after by controlling the amount of recursions
Il leave it to you to make it up the right way up like the first example
fubarpk
fubarpk on Itch...………...https://fubarpk.itch.io/
fubarpk on googleplay..https://play.google.com/store/apps/developer?id=fubarpk
Jahhweh
4
Years of Service
User Offline
Joined: 24th Jul 2019
Location: New York
Posted: 19th Aug 2019 12:48
oooo thats a good way of going about it, i didnt think of that. thank you for the advice!

Login to post a reply

Server time is: 2024-03-28 21:05:48
Your offset time is: 2024-03-28 21:05:48