0 Favourites

Endless Procedurally Generated World

  • Hey all,

    In a continuation from my previous topic, I have been curious about taking it to the next level.

    At the moment, my capx can generate a pretty decent random terrain.

    <img src="http://i.imgur.com/PjeG0.png" border="0">

    This only works for a set sized rectangle layout. Ideally, I want the player to be able to explore an infinite, randomly generated world. I don't care if going somewhere then coming back doesn't generate the same terrain - but exploration in one direction should be seamless.

    Is this even possible? I'm guessing it will involve shifting the array or something. Is it enough to simply destroy the blocks offscreen, while making the array huge, or will the array have to be resized to fit?

    Thanks!

  • Sure its possible, but to what end?

    I realize most games tend to skip over a great deal of the plot, but still you have to have some mechanics that make sense.

    So the question is how do you work that into game play?

  • newt, it's supposed to be a minigame - not a huge endeavor. Mainly an experiment in mechanics. I can think of lots of fun gameplay additions with the infinite world mechanic.

  • Using a large array is an option, it will provide persistence. Shifting the array is another option but you won't be able to use for each xy element. You'll need to set the array in a certain order depending on which direction you shift. For example shifting right:

    for x from 32 to 0

    for y from 0 to 32

    -- set array(x,y) to array(x-1,y)

    A third option that would provide for persistence and and infinite size would be to use or implement a random function that allows you to set the seed.

    One example of this would be Perlin Noise

  • R0J0hound, I understand what you are saying however I am very worried about using a huge array - won't that eat up the memory significantly?

    Keep in mind I don't care at all about persistence.

  • I would suggest a series of smaller array objects

    ###

    #P#

    ###

    or 3x3 minimum. Where each one represents a set size of 1000px by 1000px(or whatever you want really, just a hypothetical suggestion)

    when creating your map pin all the objects(blocks?) of one array to a single object.

    When a player moves to to a new araay, destroy the farthest, move the array over and create a new piece of the map.

    I would also suggest moving 9 map pieces rather than the player. That way your layout is of a set size. Alternativly you can just move the player and the map once the player reaches a certain section of the map thus reducing map movement to a minimum.

    Or don't use an array at all and just create and pin the objects straight to a HUB object as above.

  • Have you looked up using a seeded random? You can use a seeded random to get the same result every time, without having to save any data. So, if persistence isn't an issue, you can either have spawned tiles or pre-generated ones always give the same outcome. I'm sure that I've used a plugin for this in the past. It was either RGen or Random Plus.

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • Another thing involves avoiding seams in the algorithm - and that's what's really stumping me. That's why separate arrays like jayderyu suggested might not work.

  • A quick and dirty way for a much bigger map would be to have your big array store the map (as you have). When the player reaches the edge limits of the map, flip the map array. Now no more seams to worry about, and if the map is big enough, the player won't notice the terrain repeating backwards. Especially if you have random details like trees or whatever. You could even show different tiles for the new area.

    I can think of a more dynamic way but a certain hangover is preventing me from thinking clearly enough to know if it'd even work... ;)

  • procrastinator, interesting idea, but I think it would just ruin the magic once the player realizes.

  • I have it in mind , but I completely ignore how you could do it ... that's only theory !

    you could generate random layout each time and only save the layout to an array when the player interacts with it ...

  • Yeah that's the downside. With a map big enough I don't think it would be as noticable as you think.

    You're not fussed about it being persistent which would be worse for the player straight away. Imagine going a few screens left, then doubling back because there was some item there.. sure the item may (or may not?) be there but the scenery is different. Very confusing no?

  • Well again you have to figure out some mechanics before you event start.

    Like is it top down, or side scrolling? Is it one layout, or multiple layouts?

    Some forms of noise lend themselves to different game types better than others, while multiple layouts would make up for the lack of persistence.

    Another thing to think about is you have to have an algorithm that's fast enough to keep up with your generation.

  • Hi sqiddster

    I was reading through the comments and suddenly a simple endless world generation engine popped into my thoughts.

    You asked for something that was non repeatable, and as far as i understood you did not meant to save the world layout.

    So here is a little demo i just fixed.

    This one is top down, but u could simply apply this same technique if u want to create a platform game.

    Demo

    And here is the capx.

    Capx

    Let me know i this would help.

    Kind Regards.

    Savvy001

  • Savvy001, that capx is empty.

    @Newt I was thinking a fast-paced side-scrolling game - perhaps you are being pushed in one direction or something.

    @procrastinator, I'm not too concerned about this as the game will be about fast navigation, not item collection.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
187 45,133
Yann's avatar
Yann
Unread hot topic
89 11,361
thehen's avatar
thehen
Unread hot topic
67 6,248
swathin's avatar
swathin