How do I randomly generate obstacles/platforms?

0 favourites
  • 15 posts
From the Asset Store
The complete source file for my Youtube platformer game tutorial series.
  • Say I want to make a game like Flappy Bird or Doodle Jump where the player is essentially endlessly scrolling and there are new structures constantly generated at random - how would I do this? Is there a tutorial somewhere that explains this action? I really want to understand this function and how it works so I can try to implement it and do different things with it. Like in a Doodle Jump-styled game where the platforms would get fewer in number the "higher" you go.

  • To get them to spawn randomly just make an event, every x seconds and add the action create object.

    X: random(3000)

    Y: random(3000)

    Or use what ever coordinates you want.

  • Thanks for the reply! I tried your suggestion, but it doesn't seem to function in the same way as Doodle Jump. In games like Doodle Jump, it gives the appearance that the platforms are generating at random as you move up the screen. It looks like you are uncovering more platforms as the screen moves upwards. Or like in Flappy Bird, how the pipes continuously spawn offscreen and the gap between the pipes is constantly in different positions. This is the type of behavior that I'm trying to replicate.

  • How about:

    X: random(300)+800

    Y: random(400)

    Assuming a resolution of 800x400 (in landscape orientation)

    That way the object would always be made at an X coordinate offscreen to the right.

    Then add an System->OnEveryTick to subtract 1 from X of each of those objects.

    So that they all move to the left slowly.

  • Have you tried using the Flapping Bird, Infinite Jumping, or the Auto-Runner template? Click on File -> New and select one of the templates. You can learn a lot from those. Sounds like it covers what you want to learn.

  • Thanks for all the replies. I will try these suggestions!

  • You could olso take a look at this tutorial.

    / tutorials / 857 / flappy-birds-clone-in-10-minutes (delete the spaces between /'s)

  • Thanks for the tip! Quick question: on an infinite jumping game, is there a way to get my background to stay in the screen. every time I test it out, my character sprite essentially jumps out of the background as the view scrolls as he jumps. Any suggestions for how to fix this?

  • you want your background to move or just static?

    if static you need to delete the bullet action for the background if not you need to adjust the image to the size of the template or adjust the code to your background.


  • I want it to stay in the frame at all times. I have unbounded scrolling enabled for my layout, so the player essentially jumps out of the background if I set it as static and just size it to the template. I tried setting my background as a sprite and adding the Anchor property, which works, but it kind of flickers and looks jittery.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • No worries, I figured it out. It was my parallax settings for the layer that my background was on. It's all secure now. Thanks for the help!

  • what you do is make two layers; Main and Backround. then you give ur sprite scroll to behaviour. then make ur main trans parent and set ur parralax to 25 25 for backround.

  • what you do is make two layers; Main and Backround. then you give ur sprite scroll to behaviour. then make ur main trans parent and set ur parralax to 25 25 for backround.


    Why have you pointlessly resurrected a 4 year old thread?

  • ....

  • Prob just cus of throwin mustard in or cus he wanted to give a concluding answer to this question.

    Or just cus of attention like me :3

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)