Question

For a game I am making I want to create 2D vines and vine like structures procedurally. Is there some paper or code snippet that someone can point me to? Googling results in procedural trees which have straight spiky branches, but I need to create vines which are curvy. Think Jack and the beanstalk type of growth. http://youtu.be/2wq541W6LyE?t=2m11s

Was it helpful?

Solution

Your particular approach is going to depend on how you game handles drawing and collisions.

An approach popular with flash-based games is to draw the vine to a bitmap: Since you don't list your programming environemnt, I'll just explain the steps, not the code.

Start with a circle, 1 draw it, 2 move it, 3 scale it down. 4 At a random interval, spawn a "branch" and or a leaf. Set the scale and position of the branch to match the parent. Start a 1-5 loop on the branch. 5 repeat 1 until fully grown (scale is too small to proceed).

In the move phase it can be handy to use Sin curve to make your vine weave in and out. Youcan tweak the settings for how much it curves to get different types of vines.

Here is a link to a discussion fo teh topic. Some good source to be found in the links. http://groups.google.com/group/flashcodersny/browse_thread/thread/9906041e557e620c

Including source code inf flash: http://xfiles.funnygarbage.com/~colinholgate/swf/varicoseg.zip

And a javascript version that looks more like lightning, but couild be adapted to vines without much change: http://www.brainjam.ca/hyperbolic/01_spite_mrdoob.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top