0

私が作成しているゲームでは、2D のつるやつるのような構造をプロシージャルに作成したいと考えています。誰かが私に指摘できる紙やコードスニペットはありますか? グーグル検索の結果、まっすぐとがった枝を持つプロシージャル ツリーが作成されますが、曲線のつるを作成する必要があります。ジャックと豆の木のような成長を考えてみてください。 http://youtu.be/2wq541W6LyE?t=2m11s

4

1 に答える 1

2

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

于 2012-02-17T19:57:17.343 に答える