# a place where one brach comes off another class junction: def __init__(self, branch): self.generation = branch.generation self.theta = branch.theta self.phi = branch.phi step = 1.0/junctions_per_branch
def mainloop(): global branches global leaves branches = [] junctions = []
branches.append(branch())
current_generation = 1
while current_generation <= max_generation: #for every junction add a branch for i in junctions: branches.append(branch(i)) junctions = []
#for each branch keep adding junctions until they all have the right number repeat = True while repeat: found_one = False for i in branches: if i. generation == current_generation and i.number_of_children <= junctions_per_branch - 1: junctions.append(junction(i)) found_one = True if not found_one: repeat = False
current_generation += 1
leaves = []
for i in junctions: leaves.append(leaf(i))
mainloop()
running = True while running: for event in pygame.event.get(): if event.type == pygame.QUIT: running = False elif event.type == KEYDOWN: if event.key == K_ESCAPE: running = False if event.key == K_SPACE: mainloop()
for i in branches: i.display(rotation) for i in leaves: i.display(rotation)
pygame.display.flip()
pygame.quit()
MitochondriaBox Learner
Posts : 188 Reputation : 7 Join date : 2013-01-29 Age : 24 Location : Houston, Texas
Subject: Re: Proceedural Tree Generator Sat Feb 21, 2015 2:20 pm
Neat! It might not work for Thrive if plants will be alive (heh rhymes), since the player's supposed to have the chance to actually play as them if they take that direction in the Multicellular Stage. Then again, this COULD be applied to them growing, since not all the player's plants'll turn out the same, with evolution limited to certain parameters (general shape, etc.). Stats could be attached to them and have the organism procedurally change accordingly. I dunnno.
What was your buddy working on?
tjwhale Theorist
Posts : 87 Reputation : 26 Join date : 2014-09-07
Subject: Re: Proceedural Tree Generator Sat Feb 21, 2015 2:56 pm
I think the game will look very different if you are playing as a tree. This prototype is more like a tiny step towards being able to procedurally generate a landscape for your animal to wander around in. We're going to need whole forests of different trees.
He's working on a game, I can't really say too much about it but suffice to say your dragons can get shot down by Tesla coils, so it's going to be awesome and crazy.
tjwhale Theorist
Posts : 87 Reputation : 26 Join date : 2014-09-07
Subject: Re: Proceedural Tree Generator Sat Feb 21, 2015 3:54 pm
Managed to get a couple of different types of tree. It's a bit of a struggle to get it to do certain things but hopefully it should be possible to get some good variety going.
Spoiler:
crovea Programming Team lead
Posts : 310 Reputation : 59 Join date : 2013-10-07 Age : 34 Location : Denmark
Subject: Re: Proceedural Tree Generator Sat Feb 21, 2015 8:41 pm
I can think of ways this can become useful in the future!