Using an array for level data [solved]

This forum is currently in read-only mode.
From the Asset Store
With this template you will learn how to use the GooglePlay Games native plugin
  • I'd like to make a game with an inbuilt map editor, and I'm trying to decide how to store the level data.

    The example I've seen on the forums is to have the array's X and Y values correspond to positions in a tiled grid, with the identity of the object stored as a string. Like this:

    http://dl.dropbox.com/u/906550/Construct/mapeditor.cap

    ...but that's no good for me, because my world will be large and mostly empty, so the array would end up having an unfeasibly large filesize.

    So I'm thinking of using a one-dimensional array as a list of all the objects in the world, and saving the actual information about objects as comma-separated values inside the array. (For example, if the object with ID 1 is a standard block tile at X 250, Y 300, then the first entry in the array would equal "block, 250, 300".)

    Here's a quick example I made:

    http://dl.dropbox.com/u/906550/Construc ... earray.cap

    Does this sound like a sensible approach? I've tested it up to about 1500 objects and it seems to run well - small delay when loading, but acceptable. I'd hate to go ahead with this and find out there's a better way, though.

    (On that note, I'm thinking about trying the same technique with the List Box object, to see if there's any difference in performance.)

  • you should use ini files instead, it'll allow for an non-finite number of objects to be saved, and it'll work essentially how you'd do it with an array, except you could add extra properties to be saved in easily and it's just an overall better way to do it.

    Arrays are faster for operations that need to be preformed rather frequently, but for level data an ini file is much more scalable and easy to use, the loading at the beginning is the only loading that'll be done, so the small improvements gained through an array will be pretty negligible. also, an ini will make life simpler, and you wont have to organise objects by numbers and cryptic coordinates.

    heres a good tut

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks Quazi! I'll do that.

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