Updating a Tile Based World

This forum is currently in read-only mode.
From the Asset Store
Fantasy Game includes more than 600 sound effects inspired by hit computer games like World of Warcraft and Diablo.
  • (Bold parts are my questions.)

    Okay, so, I have been working on an isometric tile-based map/world editor for a week now. I have come across quite a hand full of questions and problems. Many of them are quite satisfied from my furious search through the Construct tutorials and forums. Unfortunately, some are still leisurely strolling around in my head without consent and they have been quite bothersome.

    I cannot remember all the questions right now, but here is what I am currently wondering:

    How can I constantly update my tile map while moving around?

    What I mean is that I would like to create an infinitely sized map, but a large tile count squashes that dream within pico-seconds. What I would like is to be able to destroy old distant blocks I move away from and create fresh new blocks as I move closer to the edge of the world. I hope that is enough to tell you what I need help with.

    What is the best object used for backdrops? Why is that the case?

    I have tried multiple instances of [Sprites], [Canvases], or [Tiled Backgrounds]. Using sprites completely ate up my FPS. Using canvases and tiled background charged a lot in terms of VRAM.

    Will invisible tiles consume VRAM as well?

    I do not completely understand how all the hardware/software and their makes/specs come into play here so, yeah.

    Also, does anyone have a circle or polygonal loop circuit or function on hand?

    May come in handy.

    I have other questions too, but I may need to try my hand at implementing the accompanying features first... or I just forgot - for now. Also, I would enjoy some tips on how I can optimize a tile-based (map editor, map game, etc.) anything.

    ----------------------------------------------------

    Here is my .cap project:

    IsoMapEditor.7z

    dl.dropbox.com/s/iuvr7emx1e8var8/IsoMapEditor.7z

    Project Info:

    • The tiles are of the [Tiled Background] object. There are a hand full of [Buttons] and [Text Boxes]. The Player (Camera in this case) is a Camera Focused [Sprite].
    • You use the WASD keys to move around the world. 8-direction behaviour just seemed to stop working after you draw/reset the grid, but that has been a "before" problem and may be working now, but I have not checked.
    • I have not managed a free world tiling system yet ? for reasons told above ? so the editable world space is dictated by the measurements you input at the top-left corner.
    • I have not implemented a proper Tile Type selector yet, so the tile type selected furthest to the right is the one that will be placed onto the grid because of chronological ordering of events.
    • Saving and Loading the [Hash Table] works perfectly fine (If not, I would like to know.). You can try loading the two maps I tested it with. (Map 2 has 10,000 (100x100 grid) tiles in it and may take a while to load.)
    • There are a lot of optimization I can still do, but I do not know if it will effect what I have currently. And I have been a bit lazy from head to toe.

    Thanks,

    monkeyboy

  • How can I constantly update my tile map while moving around?

    If you did this with one large map file, you'd have to loop through said map file constantly, and that sure doesn't sound good. I imagine that the best way to do this is to divide your world map up into cells made up of a certain size of tiles. You'd stitch these together; maybe using a 2D array where each position points towards a cell file or something, then when your player moves towards a new cell, the engine knows to load that cell and unload older ones. I thought about doing this back when I was using MMF2 but I'm lazy and never get anything done huehuehue <img src="smileys/smiley9.gif" border="0" align="middle">

    EDIT: Alternatively, you could easily just name the cell after the coordinates of the cell in world space e.g. "0,0.map" "0,1.map" etc, and have the game search for the appropriate cell file based on its name when you enter that cell. Would be easier on the processing, too.

    What is the best object used for backdrops? Why is that the case?

    I see the way you're doing it right now is loading an image for every single tile, meaning VRAM usage is going to inflate very quickly at very large map sizes and cause the map loading process to hang the entire application. This is obviously not a viable solution :(

    I think the best way (performance-wise) to do tile-based maps is using only one image for a tileset which is comprised of every single tile you plan to use in your map side-by-side. The image is then loaded into the Tiled Background object and is shared among every instance of the object, then tiles can be picked using the image offset function. But even this method has its problems:

    • The image offset function only works for textures sizes that are a power of 2. Obviously this isn't too big a deal, if you're using irregular tile sizes there can be some blank space you can program your game to ignore.
    • At runtime, loading a new texture into the Tiled Background object causes it to gain a unique texture. Either we have to set the object's texture in-editor as a game resource or, once again, VRAM usage inflates and the game hangs as a result of trying to load an entire tileset into every single tile.
    • I also tried to solve the above problem using the Texture Setter object. Unfortunately, it doesn't affect Tiled Background objects. So much for that idea.

    I think this is the method konjak uses in The Iconoclasts, but as far as I know it doesn't use external tileset images, the tiles are presumably stored in the game resources.

    You could also try using a sprite object to load every tile image you're going to use into a new frame for the sprite object at the beginning of runtime, then when you're creating a new tile, instead of loading the texture into it, you're just setting the animation frame. I think this method also causes VRAM usage to inflate and locks up the game for a while, but not as much as if you were loading textures into objects individually, since you're only loading the texture for a tile once. Also, since you can't add new animation frames you have to add a whole ton of empty frames in the editor and there'll be a hard limit to how many tiles you can use as a result.

    I can't think of any other way to do it. Sorry if I can't be any more helpful. Maybe we should ask r0j0hound why the texture setter doesn't work on tiled BG objects? If it did, things would be so much easier :(

    Will invisible tiles consume VRAM as well?

    Yeah. It's best to have your loader ignore blank spaces instead of trying to create a blank tile there.

  • Hi guys! i think there is method we can use for that purpose a tile-based map, let me work a couple weeks and i will presents my tile-based map editor idea... It must be cheaper (low VRAM comsuption), versatile & reliable (load as quick as posible and support user tileset), as part of my next project. I will work on that... any progress i'll report...

    ^_^

  • ow can I constantly update my tile map while moving around?

    Here is a example of a 1000x1000 tile map displayed with 429 sprites.

    http://dl.dropbox.com/u/5426011/examples11/tileScroll.cap

    The sprites don't actually move only the tile they represent changes. Scrolling the layout a bit completes the illusion of scrolling over the tiles.

    Also, does anyone have a circle or polygonal loop circuit or function on hand?

    I don't understand this. Do you mean motion in a circle or along a polygon path? Please clarify.

    solar

    I don't have visual studio installed atm, so I can't tinker with the Texture Setter source right now. But it should be possible to get it to work with tiledBackgrounds, in fact I'm pretty sure I had it working at some point when I was making it.

  • solar

    I have used the suggested offset function and now the VRAM stays at 0.05mb compared to the 78+mb it was at when creating a 100*100 size grid. Thanks! Also, thanks for showing me Iconoclasts, it was fun while it lasted. It is unfortunate that it is not a complete project.

    Yaottabyte

    Any example of a tile-based map/world generator would be much appreciated. I look forward to your take on this project.

    R0J0hound

    The example you provided is sweet!

    Unfortunately, I am still slightly at a loss as to which object is best for background purposes. The Tiled-Background vs. Sprite as background sort of debate. Sprites seem to eat up the frame rate when enough has been added, but tiled-backgrounds are limited to the object size, all offset textures must be that size or face a bit of cropping, and it is created based on always created based on its location from (0,0). Maybe you can explain why you used Sprites as opposed a Tiled-background with offsets?

    As for the scrolling, I am still studying how it works. When I threw in an arbitrary sprite object onto the ?hud? layer it stayed in one place as it should I suppose. When I tested it on ?Layer 1?, it shakes in the direction of the mouse, but at the end of the it all, the arbitrary sprite was on the same spot as if it were on the ?hud? layer. My biggest concern is will this form of scrolling will affect a game with player sprites moving around the world? If they had a projectile launcher, would the projectile move in the intended direction while scrolling? Are these problems really much of an issue or can they be fixed easily?

    About the Circle/Polygonal loop circuit or function. I suppose I may have needed to clarify things more as to its intended use. Because I am working on a tile-based world/map ?editor?, I thought being able to place tiles with polygonal patterns would be very helpful, as opposed manually placing tiles to make a circle or a triangle or rectangle or any other polygonal shape. Drawing rectangles should not too difficult to implement, but drawing triangles and anything above 4-sided shapes are really unnecessary and circles may be a bit of a problem for me.

    Also, I always took the ?Start of layout? condition as something that happens only once when the layout starts and no more afterwards, but the events with the loop conditions seem to go on forever.

    ------------------------------------------------------

    Lastly, I have also been working on a smaller project to help me precisely pick the tile you want as opposed to picking the closest tile or the one closest to the front (I assumed that would have been a problem when making a game with height).

    It took a good chunk of my day to get the math correct, but it is only half of the math towards the way I want this to function. I want to be able to select/place an ENTIRE tile in the correct position - not a half-way overlapping another.

    Here's the .cap file:

    IsoShadowPosTest.cap

    dl.dropbox.com/s/niqblvktqcpbtvc/IsoShadowPosTest.cap

    Right now it only goes halfsies. I am unsure as to how to make it full cell selection, but I managed to stop the jittering by flooring all the MouseX/MouseY positions. Any help in this small project will help my larger project. Please and Thank you.

  • dl.dropbox.com/u/28629176/gamedev/isosnap.cap

    the snapping here is kinda iffy though so maybe someone else can do it better

    also see here: scirra.com/forum/hex-grid-sorry-if-duplicate-q_topic44313.html

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Wow, that is soooooooooooooooo much shorter and cleaner than my math. Yet it produces the same results with the "iffy" snapping.

    Your X: (int(MouseX/64)*64)+((64/2)*(int(MouseY/16)%2))

    Your Y: (int(MouseY/16)*16)

    My X: (Floor(MouseX)-(Floor(MouseX)%32))+(((((Floor(MouseY)-(Floor(MouseY)%16))%32)/16)*32)-32)

    My Y: (Floor(MouseY)-(Floor(MouseY)%16))+(((((Floor(MouseX)-(Floor(MouseX)%32))%64)/32)*16)-16)

  • Hi guys i was making something last night, there is my first incursion to the tile-based maps, this is my basic idea still i need work in the save/load system and the player customization of tile sets.

    EDIT: I forgot mention you'll need MagicCam and TextureSetter plugins...

    Espect you like this...

    .CAP

  • For snapping to an iso grid first convert the mouse coordinates into isometric:

    isoX = MouseY + MouseX / 2

    isoY = MouseY - MouseX / 2

    But to snap to a grid you need to do math like this: round(n/32)*32

    isoX = round((MouseY + MouseX / 2) / 32 - 32) * 32

    isoY = round((MouseY - MouseX / 2) / 32) * 32

    Note: the -32 in bold to correct the hotspot being on the top left.

    Then convert back to regular coordinates:

    X = isoX - isoY

    Y = (isoX + isoY) /2

    aznmonkeyboy

    Changed my example a bit so that scrolling isn't faked. The tiles are just moved to the other side when they leave the screen. This should be as easy to work with as if all the tiles existed at once.

    http://dl.dropbox.com/u/5426011/examples11/tileScroll2.cap

    I'm still using sprites, it's just a preference. Sprites provide the luxury of hotspots so you can easily have different height tiles. TledBackgrounds have the advantage of rendering almost twice as fast as sprites, but I'm getting a constant 60 fps so it's fast enough.

  • R0J0hound

    Your examples are amazing! Thanks. I hope I'm not asking too much, but I have been caught in a bit snag with zOrdering now. I have attempted a hand full of examples I found around here; unfortunately, it chewed up the frame rate and spat back out a load of lag. I was wondering if there was a better fix for this without causing dramatic drops in frame rate?

    In addition, seeing how the tiles are just shifting to the other side, how might I be able to load objects on top of it (ie. trees, wells, other platforms, whatever is else stationary)?

    Yaottabyte

    That's nice example. I especially like how when placing a dirt tile, the dirt sort of bleeds into nearby grass tiles and vice-versa. Cool stuff.

    PS. If anyone wants to know, I am trying to create something like the game Dofus/Wakfu by Ankama (a rare game that captivated me and that I enjoyed more than MOST I have played). I just hope I am going in the right direction with all of this. I am currently trying to get a hang of construct. I am mostly trying to learn and understand how an isometric style game would work as I have barely any idea where to start when trying to even barely reach the level of Wakfu.

  • solar

    I don't have visual studio installed atm, so I can't tinker with the Texture Setter source right now. But it should be possible to get it to work with tiledBackgrounds, in fact I'm pretty sure I had it working at some point when I was making it.

    it occurred to me that the image manipulator object also does not affect the tiled background object, is there a relation?

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