Endless Procedurally Generated World

Get help using Construct 2

Post » Tue Jan 01, 2013 6:55 pm

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.



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!sqiddster2013-01-01 18:56:37
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Tue Jan 01, 2013 7:11 pm

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?
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Tue Jan 01, 2013 7:15 pm

@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.sqiddster2013-01-01 19:15:42
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Tue Jan 01, 2013 7:55 pm

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
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Tue Jan 01, 2013 8:03 pm

@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.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Tue Jan 01, 2013 8:43 pm

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.
B
87
S
18
G
9
Posts: 2,455
Reputation: 14,834

Post » Tue Jan 01, 2013 8:49 pm

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.
B
6
S
1
Posts: 37
Reputation: 774

Post » Tue Jan 01, 2013 9:11 pm

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.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Post » Tue Jan 01, 2013 10:04 pm

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... ;)
B
15
S
5
G
7
Posts: 877
Reputation: 5,650

Post » Tue Jan 01, 2013 10:34 pm

@procrastinator, interesting idea, but I think it would just ruin the magic once the player realizes.
B
90
S
30
G
24
Posts: 3,189
Reputation: 32,400

Next

Return to How do I....?

Who is online

Users browsing this forum: armaldio, Colludium, plinkie and 18 guests