How do I create an "infinity" map using tilemap

0 favourites
From the Asset Store
A template which allows you to customise the controls of your game.
  • Using a tilemap for this could be tricky and may not give any gains since it looks like you'd have to update the whole tilemap every time you scroll. I'll have to think about it some more though.

    Scrolling in other directions will only take one event a piece, and will look much like the one to scroll right. I'm away from my PC atm.

    Only the randomize seed action sets the state. The perlin2 expression will always give the same value for an xy if the seed is the same.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Using a tilemap for this could be tricky and may not give any gains since it looks like you'd have to update the whole tilemap every time you scroll. I'll have to think about it some more though.

    Scrolling in other directions will only take one event a piece, and will look much like the one to scroll right. I'm away from my PC atm.

    Only the randomize seed action sets the state. The perlin2 expression will always give the same value for an xy if the seed is the same.

    I see, so the result would be the same generation but "mirrored".

    I wanted to use tilemap because using several objects will harm a lot the game's performance and, for an 8x8 or16x16 tile, which is what i'm focusing, would be unplayable.

    I might think another alternative where I don't need to save an infinity world generation and all it's changes made by the player, since that's the whole point of using this plugin. Although wouldn't fit well in a game like Terraria that I'm trying to create.

  • What could be done is a chunk based approach so the tilemap could be used. The idea would be to do the same as my example but use multiple tilemap objects that you move around and update the tiles in them when they're moved around.

    I'll try to give that a go tomorrow, it sounds promising.

    The next problem to consider is a way to keep track of terrain changes if you want to be able to add/remove tiles as the game runs.

  • Ok, here's the result:

    https://dl.dropboxusercontent.com/u/542 ... lemap.capx

    Probably should have called it spelunking turtle.

    I set it up with 64x64 tilemaps with 4x4 tile size and it works decently. I get about 30fps on my machine, so I assume most others will get a higher fps. I briefly tried 128x128 tiles but it seemed to stall a bit more. Also I had some more fun with perlin noise in this one. I found you can combine it in various ways to create some interesting terrain.

    It can be made faster I think if I use some javascript to do what the update function does, and create a json that can be loaded into the tilemap. But for now it's decent.

  • R0J0hound

    Pretty nice, I'd never think this way. I was thinking about using just 4 tilemaps, 2 for the X and 2 for the Y.

    Here is the beginning. https://www.dropbox.com/s/z5upfgvu6euxc ... .capx?dl=0

    I still need to make the tilemaps arrangement for the Y axis, place underground materials, caves and the most difficult, generate enemies and the blocks that were broken and record both. But now I have a good starting point.

    You helped a lot, man. Thank you.

  • Glad it was useful. I'll take a look at what your capx tomorrow.

    I thought of a simple way to save changes to the array.

    Basically just change the tiles on the tilemap like normal, but when you do, set a Boolean variable to save that tilemap.

    When that Boolean is set and before moving a tilemap that moved off screen, store that tilemap in a dictionary object.

    With this key

    X&" "y

    And this value:

    Tilemap.asjson

    Then after moving check if the current tilemap position is in the dictionary. If it is, load that json. If it isn't call update.

    That way only tilemaps that are changed are saved.

    Enemies could be tricky if they're off screen since they would no longer have a tilemap to interact with. Two ways around that come to mind. One would be to put the object to sleep if offscreen. Another would be to maintain some tilemaps around the enemies, however this could prove complex.

  • You can improve the rendering speed of the tilemaps by setting "seamless mode" to off in the tilemap properties.

    In addition to that set "pixel rounding" to on and "fullscreen scaling" to low quality.

    Here's the latest of my capx that saves chunks that were modified.

    https://dl.dropboxusercontent.com/u/542 ... lemap.capx

  • R0J0hound

    Awesome! Your example gave me some ideas on how to do other things as well. Thanks!

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