How do I randomly generate obstacles/platforms?

Get help using Construct 2

Post » Sun Apr 06, 2014 12:46 pm

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.
B
7
S
1
Posts: 17
Reputation: 466

Post » Sun Apr 06, 2014 1:00 pm

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.
What I know would fill a Book , what I don't know would fill a Library
B
37
S
12
G
29
Posts: 331
Reputation: 16,499

Post » Sun Apr 06, 2014 11:16 pm

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.
B
7
S
1
Posts: 17
Reputation: 466

Post » Mon Apr 07, 2014 2:34 am

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.
B
16
S
2
G
3
Posts: 61
Reputation: 2,346

Post » Mon Apr 07, 2014 3:28 am

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.
B
13
S
3
G
3
Posts: 35
Reputation: 2,731

Post » Mon Apr 07, 2014 9:24 am

Thanks for all the replies. I will try these suggestions!
B
7
S
1
Posts: 17
Reputation: 466

Post » Mon Apr 07, 2014 11:04 am

Message: VIKINGS can only post plain text URLS until they have 500 rep. 1 URLS modified. Why?
You could olso take a look at this tutorial.

www.scirra.com / tutorials / 857 / flappy-birds-clone-in-10-minutes (delete the spaces between /'s)
B
21
S
11
G
6
Posts: 414
Reputation: 5,335

Post » Mon Apr 07, 2014 3:41 pm

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?
B
7
S
1
Posts: 17
Reputation: 466

Post » Mon Apr 07, 2014 4:01 pm

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.

Regards,
B
31
S
13
G
6
Posts: 355
Reputation: 5,058

Post » Mon Apr 07, 2014 4:18 pm

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.
B
7
S
1
Posts: 17
Reputation: 466

Next

Return to How do I....?

Who is online

Users browsing this forum: danalog, dop2000 and 25 guests