Log In  

Cart #38134 | 2017-03-10 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
9

Here's a demo cart using the algorithm we used in Spaceman 8.

Some words about it: http://kometbomb.net/2017/03/10/how-levels-are-generated-in-spaceman-8/

P#38135 2017-03-10 12:05 ( Edited 2017-04-16 12:30)

I have a little question about the "while loop" you have in step1():

so the engine is running it until conditions are met for it to be broken ; the engine is only running one time right? i'm asking because the step1() function is called by update() (about 30 times per second), just to be sure ^^

P#39713 2017-04-16 07:29 ( Edited 2017-04-16 11:29)

Every time you see the cave grow (even just a single tile), the while loop in step1() has been run until it finds a suitable tile (and then that tile is set empty). The demo uses several frames to create the whole cave just so that you can see how it builds it (and of course the demo generates maps as long as you let it run so the engine is run several times also).

I guess the function is named a bit stupidly because it's actually step 3 in the article!

You can create the whole level instantly like this:

function generate(maxsize)
  step0()
  for i=1,maxsize do step1() end
end
P#39714 2017-04-16 08:30 ( Edited 2017-04-16 12:31)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-19 06:10:44 | 0.010s | Q:13