开发者

How can levels be dynamicaly/randomly generated in corona SDK (Lua)

Like in this app.

http://www.youtube.com/watch?v=FdaTyLrNYOo

I see the sprite is kept on the same x axis and the level moves to the left.

platform = display.newRect(0,500,400,10)
physics.addBody(platform, "static")
platform.rotation = 0

^that is for creating one plat开发者_开发知识库form.

how is the platform generated on-the-fly?


This problem is best not addressed on the code level but on a higher design level. You have think through what kind of algorithm you want to use to create the platforms.

There are several options, each with specific pros and cons:

  • Completely random: You can use completely random platform heights and lengths. This is easy to implement but the results are also random and might be impossible to solve.

  • Sine waves: You could use the sin() function to generate altering heights for your level. This is also easy to implement and might produce better gameplay results compared to the random. The danger is that it might be too easy to play and become boring.

Of course you can use a combined technique or any other sort of number generator.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜