Dusk - putting different maps together during runtime?

I’m trying to create an infinite runner.  Maybe my approach is wrong here but I would like to put different tile maps together in random order so I can create variation as the player runs through the game.

I’m thinking of having two display groups with two different maps loaded at all times.  as the first display group leaves the view it moves to the back and pulls in a different tiled map.  

I’ve been playing with dusk and its very easy to create a map quickly but I’m wondering if it can be extended to something like an infinite runner.

I was considering just ditching tiled altogether and loading random physics objects as platforms for the player to jump on, but I am leaning towards tiled because I wanted to roll my own tile based physics.

any suggestions? :slight_smile:

Hm. You can definitely do this with Tiled and Dusk, the question is whether it’s the best tool for the job. You might find it a little simpler to go with the procedurally-generated platform approach, but if you want to use Tiled and Dusk, that’ll work, too.

You could begin with checking for when a map’s right edge (assuming you’re going to the right like most endless runners) reaches the side of the screen and building another map when that happens. You could also load multiple maps and swapping them out randomly - that would be faster. If you need some help with implementation, let me know and I’ll try to come up with some code.

  • Caleb
function scene:create( event ) local sceneGroup = self.view local world = display.newGroup( ) sceneGroup:insert( world ) map = dusk.buildMap("levels/level1.json") world:insert(map) player = player.new({x=100, y=340}) map.layer["tiles"]:insert(player)

I’d rather not use the procedurally generated approach since I want to have more control on how each section looks.  Some pseudo code would be really great caleb.   :slight_smile:

This is how im creating the map and inserting the player into it.  I guess i would have to load a new map once we get to a certain point, and re-add the player to that map?   I’m just confused on what would happen to the old map.  the player needs to be able to cross two maps that are laid out side by side, but it seems like he can only ever exist in one maps layer at a time…

It would be ideal if I could append one map to another during runtime.

Hm. You can definitely do this with Tiled and Dusk, the question is whether it’s the best tool for the job. You might find it a little simpler to go with the procedurally-generated platform approach, but if you want to use Tiled and Dusk, that’ll work, too.

You could begin with checking for when a map’s right edge (assuming you’re going to the right like most endless runners) reaches the side of the screen and building another map when that happens. You could also load multiple maps and swapping them out randomly - that would be faster. If you need some help with implementation, let me know and I’ll try to come up with some code.

  • Caleb
function scene:create( event ) local sceneGroup = self.view local world = display.newGroup( ) sceneGroup:insert( world ) map = dusk.buildMap("levels/level1.json") world:insert(map) player = player.new({x=100, y=340}) map.layer["tiles"]:insert(player)

I’d rather not use the procedurally generated approach since I want to have more control on how each section looks.  Some pseudo code would be really great caleb.   :slight_smile:

This is how im creating the map and inserting the player into it.  I guess i would have to load a new map once we get to a certain point, and re-add the player to that map?   I’m just confused on what would happen to the old map.  the player needs to be able to cross two maps that are laid out side by side, but it seems like he can only ever exist in one maps layer at a time…

It would be ideal if I could append one map to another during runtime.