procedural level generation help

The moment I am doing it now is by using the Random operator in a timer to spawn an object that when alive continuously moves in x direction until reaching a point outside of the screen where it is destroyed. This simulates the illusion of scrolling.

The problems come when having more than one object being spawned that way. It is not possible to control the with the random operator and they get spawned at the same time and place. As a result I get overlapping objects and a boring even level where their randomness doesnt vary enough.

How would you go about solving this issue.

I am trying to make something like “jetpack joyride” or flappy bird.

Could you post a screenshots of your events? :slight_smile:

its very basic. X is determined by random time of creation, Y is determined by random Y. They scroll and when on the other side of the screen, get destroyed.

You’re testing timers against a random time, but this random time is random each time events are executed. As events are exectued around 60 times per seconds, there will be one time where the Random return 0 or 1, so the timer will be reset and actions executed: There is nothing random at all.

You should store the time to wait before spawning the next object in a variable : You can set this time to be equal to 2+Random(3) or anything using Random, but you should do it only once :slight_smile:

I’m not sure if my suggestion can fit your game, but what I would do, is to change animation randomly of specified objects.

Just place every object in to the scene, and use an object variable (animation) for every object to store animation number.
Store animations in separated animation sets for all object, and at the beginning of the scene, generate random value for each object
variable (animation) and use this variable to change animation of objects.

For example, you have an object that has an animation set of rockbottom and crystall.
Animation 0 : no animation (empty transparent image if you need)
Animation 1 : rockbottom
Animation 2 : crystall

Create an object variable, and at the beginning generate a random value for each object variable

For each object: name of object At the beginning of the scene: Do =Random(2) to variable animation of object

Finally, change animation of object by using it variable

For each object: name of object At the beginning of the scene: Do =object.Variable(animation) to the number of current animation of object

If you also want to change position, direction of object randomly, do exactly the same. Create object variable to store
X,Y position and direction of object, generate random value for variables at the beginning and finally set object position, direction by using the object variables for each object.

For each object: name of object At the beginning of the scene: Do =object.Variable(x_position);=object.Variable(y_position) to the position of object Do =object.Variable(direction) to the direction of object

To run different actions for objects with different animations, simply also check the actual animation of object.
if player is in collision with object and object variable = 0 then do something if =1 do something else.

Otherwise, if you want to create some objects in random position 1 by 1, probably I would do the same only create objects instead of changing animation and I would also use the repeat event, to set how many times I want to create an object, how many objects I want in the scene, also to make sure 2 objects is not overlapping each other, I would run an event to move created object in X,Y position until not colliding with an other object, or regenerate X,Y coordinates until it not colliding with another object.

Hope it helps.

Hi and thank you for the feedback!! I will give it a shot.

Btw is there a more controlled way to generate a level? I really wish there was an example file. :smiley:

Could you send a screenshot of what kind of level you are trying to make?

with placeholder graphics:

its sort of like flappy bird atm, with stuff coming from the right, scrolling on the screen and getting destroyed when outside of the screen (behind the player). I am going to put a new spin on it though.

I did the flappy controls first with my own custom logic. Then I slapped myself on the head and redid it with less code by just using the platformer automatism+ the double jump feature

I don’t know if you still need help with this, I just made a quick example of my suggestion: … sp=sharing

If I understand you correctly, you want every obstacles to be random.
In my example every obstacle is basically the same object, only with different, random animations for each.
Not perfect, need to polish a lot but a good example and starting point of my suggestion imo.

Hope it helps.