Advertisement

BricksBreaker-style level design Question

Started by August 25, 2014 07:55 PM
1 comment, last by Huy Luu 10 years, 4 months ago

Hi guys,

I just want to drop by and ask a really simple question here. For a Bricks Breaker-style game, such as this one:

https://play.google.com/store/apps/details?id=com.wegoi.brickfree&hl=en

,the game automatically generates new levels everytime the player enters a new session. However, I wonder what methods/techniques did the designer use to assemble blocks so that when it is needed, a new level can be generated with both logic (Bricks count) and aesthetic (Block Shape, Symmetry).

If you have any ideas on this problem, please share your knowledge. That will really help me in a lot of ways. Thank you very much in advance !

For this kind of thing, my method of doing it is to use a recursive random generator function. So you'd have a function like generateRandom(x,y,w,h), where the parameters describe a rectangle. generateRandom calls a random one of a few dozen generate functions with the same parameters, that do something to that rectangle, then call generateRandom again on one or more subrectangles of it.

For example, generateBorder(x,y,w,h) would fill in all the perimeter blocks, then call generateRandom(x+1,y+1,w-2,h-2) -- that is, draw a border and start again on the space inside that border. generateVerticalSplit might fill a line down the middle and the call generateRandom twice, once for each of the regions delimited. For vertical symmetry, you could have generateMirroredVerticalSplit, which only calls generateRandom for the left region, then mirrors it in the other region.

If you're comfortable with a functional style of programming, this is fun to do as a library of function combinators.

Advertisement

Hello valrus,

I'm really thankful for your reply. Even though it might have a lot of stuff on the technical side, fortunately your explanation was simple enough for me to understand. I'm trying to implement the ruleset based on what you've guided here, and will tell you later if there's any problems occurred. So far so good, thank you very much friend !

This topic is closed to new replies.

Advertisement