How do I make a endless level?

0 favourites
  • 11 posts
From the Asset Store
Unlock Levels, Worlds & skin plus add coins by watching ads
  • 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

  • Upload a file .capx for help you.

  • 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.

  • 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

  • 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.

  • 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.

  • 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.

    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)

  • >

    >

    > 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.

  • 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.

  • 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 ):

    [attachment=1:3pkwld49][/attachment:3pkwld49]

    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:

    [attachment=0:3pkwld49][/attachment:3pkwld49]

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ahh i figured it out. Thanks again for your help

    Also I have the tiles getting a new frame when they are moved.

    The only thing I want to do now is to create the level a little less random and more like an actual level. I guess thats what the events at "bilinear interpolate" do. I find that quite complicated, is there an easier way to archive a similar effect?

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