How do I make a endless level?

Get help using Construct 2

Post » Thu Mar 05, 2015 11:09 am

Hello,

Im asking for a tutorial to make an endless level like in "go faster". In need help with the scrolling.

What I have:

    An Array "Level"
    A Sprite "Tile" with solid behavior(initial disabled)
    A Sprite "Player" with Platform behavior.

My Code for the initial level generation:

    System(On start of layout) -> Create object Tile on Layer 0 at Level.CurX*32, Level.CurY*32
    Level(For each XY element)

    System(On start of layout) -> Set Animation Frame to random(3)
    System(For each Tile)

    System(On start of layout) -> Set Solid Enabled
    System(For each Tile)
    Tile(Animation Frame =2)

So how do i make the level scroll? Any advice where to start?

thanks in advance
B
5
Posts: 23
Reputation: 261

Post » Thu Mar 05, 2015 4:36 pm

Upload a file .capx for help you.
B
46
S
9
G
10
Posts: 198
Reputation: 8,200

Post » Thu Mar 05, 2015 5:20 pm

I would suggest moving every object except for the player in order to get a scrolling effect. You can control the rate of movement with a global variable that you slowly increment.
B
14
S
5
G
1
Posts: 189
Reputation: 1,536

Post » Thu Mar 05, 2015 6:40 pm

@luisgmolina
Thanks, I attached it :)

@bladedpenguin
Yes, but I need to generate more tiles if the player is moving, simply changing the place of the existing tiles isnt enough
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 23
Reputation: 261

Post » Fri Mar 06, 2015 1:09 am

I notice you are using the array object only for setting up the level. It's better to use a pair of named For loops, one for X, and one for Y.

Every tick, move all the tiles down by ScrollRate * dt, or maybe give them all the bullet behavior, moving down.

Pick the TIle with the lowest Y value. if that Y value is higher than zero, use a loop to create a new row of tiles at Yvalue-32 and randomly assign them the same way you already do.
when a tile has Y > layout height, destroy it.
B
14
S
5
G
1
Posts: 189
Reputation: 1,536

Post » Fri Mar 06, 2015 4:33 am

One approach I've used in the past is create enough tiles to cover the screen and create no more. I then used a large array to store the generated level and hide and disable solid for eny empty tiles onscreen. When you scroll around as normal the tiles that move offscreen are then moved to the other side and updated from the array.

Another idea could be to use the tilemap object if it's acceptable to have edges.
B
85
S
27
G
78
Posts: 5,010
Reputation: 54,254

Post » Fri Mar 06, 2015 9:02 am

bladedpenguin wrote:
Every tick, move all the tiles down by ScrollRate * dt, or maybe give them all the bullet behavior, moving down.

Pick the TIle with the lowest Y value. if that Y value is higher than zero, use a loop to create a new row of tiles at Yvalue-32 and randomly assign them the same way you already do.
when a tile has Y > layout height, destroy it.


Why should i give them a bullet behavior? Doesnt that mean that the tiles would move down all the time?
How dould i pick the lowest value and create a loop? I know what you mean but cant figure out how to create this event.


R0J0hound wrote:One approach I've used in the past is create enough tiles to cover the screen and create no more. I then used a large array to store the generated level and hide and disable solid for eny empty tiles onscreen. When you scroll around as normal the tiles that move offscreen are then moved to the other side and updated from the array.

Another idea could be to use the tilemap object if it's acceptable to have edges.


Thats what i was thinking. I already create the level with an array. But i cant really move them to the other side like you described.

Tile(Y<0) -> Tile(Set Y to OriginalWindowsWidth+32)
B
5
Posts: 23
Reputation: 261

Post » Fri Mar 06, 2015 1:13 pm

svd91 wrote:
bladedpenguin wrote:
Every tick, move all the tiles down by ScrollRate * dt, or maybe give them all the bullet behavior, moving down.

Pick the TIle with the lowest Y value. if that Y value is higher than zero, use a loop to create a new row of tiles at Yvalue-32 and randomly assign them the same way you already do.
when a tile has Y > layout height, destroy it.


Why should i give them a bullet behavior? Doesnt that mean that the tiles would move down all the time?
How dould i pick the lowest value and create a loop? I know what you mean but cant figure out how to create this event.


Ah I thought tiles moving down all the time was what you want?

I thought there was a way to pick instances by the lowest/highest expression, but apparantly that's only for instance varialbes. What you can do is use the sprite Event Compare X or Compare Y to pick the tiles which are off the screen in a particular direction, and use pick nearest/furthest to see if the outermost is close enough for you to spawn a new row of tiles.

If you do intend scrolling to be multidirectional and follow the player instead of constantly scrolling, it would be best if you kept using the array for not only level generation, but storage as well. RexRainbow has a plugin that handles grids rather well; I am using it for my RPG. Even though you won't have the player moving on the board, you might look into his LogicMask, which automatically restricts the set of active tiles to the ones on the screen.
B
14
S
5
G
1
Posts: 189
Reputation: 1,536

Post » Fri Mar 06, 2015 6:04 pm

Here's the topic where go faster's approach was devised.
endless-procedurally-generated-world_p638518?#p638518
In the linked post there's a capx. Events 6-9 move the tiles. The recalc variable is just a flag to tell the tile to re-lookup if it's a wall or not in it's new position. The most complicated bit is how the level is generated. It uses a array of random values and then does some interpolation with those values so that any position can be checked on the layout and always be able to get the same value. There's a perlin noise plugin that would greatly simply this.
B
85
S
27
G
78
Posts: 5,010
Reputation: 54,254

Post » Tue Mar 10, 2015 4:39 pm

R0J0hound wrote:Here's the topic where go faster's approach was devised.

In the linked post there's a capx. Events 6-9 move the tiles. The recalc variable is just a flag to tell the tile to re-lookup if it's a wall or not in it's new position. The most complicated bit is how the level is generated. It uses a array of random values and then does some interpolation with those values so that any position can be checked on the layout and always be able to get the same value. There's a perlin noise plugin that would greatly simply this.


Hi,
sorry for the late answer. I was busy the last few days..
Anyways, after looking through the capx, i came up with this(well, almost just copied :D ):
c2.PNG


Works great, thank you very much:)
The only problem i still have is that some tiles are still solid enabled but shouldn't(and white spaces on the sides, almost like the game isnt updating anymore). Any idea why?
There the capx:
Scroll.capx
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 23
Reputation: 261

Next

Return to How do I....?

Who is online

Users browsing this forum: 20170217, 8bitgamer, alimuqaddas, PrinceHata and 8 guests