[HELP] Saving Level data in an Array

This forum is currently in read-only mode.
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • I am trying to make a editor for my game so that I can make levels easier, but I am having issues with saving arrays. How exactally does an array work, and how would I save it in this case? I tried using R0J0Hounds array saving application as a guide to the right direction, but, alas, I don't honestly know what I am doing.

    http://www.megaupload.com/?d=PXREUT8D

    There is the cap file.

    CONTROLS:

    1 - Solid Block

    2 - Empty Space

    3 - Plinus block (More will be explained for this object later)

    There is also objects:

    SPACE - Spawn interchangeable object. (Only player spawn atm)

    Please help if you can. (And I know you can. )

  • I do believe there are quite a few examples around the forum for this. A recently added array map editor seems like a good match:

    Haven't tried that one myself.

    Please help if you can. (And I know you can. )

    You're right about that.

    In case you absolutely need specific help with your cap, say so and I - or someone who's faster - will take a look at it.

  • I do believe there are quite a few examples around the forum for this. A recently added array map editor seems like a good match:

    Haven't tried that one myself.

    > Please help if you can. (And I know you can. )

    >

    You're right about that.

    In case you absolutely need specific help with your cap, say so and I - or someone who's faster - will take a look at it.

    Yes. My game has a border around the edges, and I just don't know the right formula for having the objects inside the thing and not the borders, and also save it.

    Here is another cap: http://www.megaupload.com/?d=X6NN82FA

    Please help if you can.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Okay, I took a look at your cap and made some edits:

    http://dl.dropbox.com/u/2306601/plinus_edit.cap

    First of all I noticed that you placed the gameplay area full of blocks in the layout editor, which is unnecessary. Even if you do want blocks sitting everywhere right from the startup, you should use a loop to create them (toggle event 2).

    Also you didn't seem to have made up your mind whether to use different objects or different animations to represent the different blocks/gameplay elements in the level editor. I think it's usually best to have one single object with different frames in a 0 speed animation. So I added that in.

    And I didn't see that you set the size of the array anywhere. You can just calculate the array size from the size of the layout/display on startup (first event in my edited cap, note that the -2 accounts for the border). Also it's a good idea in a game like this to have a global variable representing the size of a cell (Global('cellsize')). So you can easily reuse it where needed and your game will still work if you suddenly decide to change the size of a cell too.

    Well, loading and saving, it's obviously just some array loops. Checking for blocks at the currently looped position. And eventually storing the frame number/creating the object and setting the frame number. If there's no object at the current array position, the value is 0. Anything above 0 represents the animation frame number.

    So yeah, take a look at the cap. I hope this is helping. For further questions you know what to do.

  • Okay, I took a look at your cap and made some edits:

    http://dl.dropbox.com/u/2306601/plinus_edit.cap

    First of all I noticed that you placed the gameplay area full of blocks in the layout editor, which is unnecessary. Even if you do want blocks sitting everywhere right from the startup, you should use a loop to create them (toggle event 2).

    Also you didn't seem to have made up your mind whether to use different objects or different animations to represent the different blocks/gameplay elements in the level editor. I think it's usually best to have one single object with different frames in a 0 speed animation. So I added that in.

    And I didn't see that you set the size of the array anywhere. You can just calculate the array size from the size of the layout/display on startup (first event in my edited cap, note that the -2 accounts for the border). Also it's a good idea in a game like this to have a global variable representing the size of a cell (Global('cellsize')). So you can easily reuse it where needed and your game will still work if you suddenly decide to change the size of a cell too.

    Well, loading and saving, it's obviously just some array loops. Checking for blocks at the currently looped position. And eventually storing the frame number/creating the object and setting the frame number. If there's no object at the current array position, the value is 0. Anything above 0 represents the animation frame number.

    So yeah, take a look at the cap. I hope this is helping. For further questions you know what to do.

    It helps a lot! But what confuses me is that I don't know how you saved the blocks, because I created a new object and it didn't save it.

    And all you did( for saving ), as far as I can see, is clearing the array with a value. Where are the events that save the information about the blocks?

  • It helps a lot! But what confuses me is that I don't know how you saved the blocks, because I created a new object and it didn't save it.

    Hehe, well, as I said:

    Also you didn't seem to have made up your mind whether to use different objects or different animations to represent the different blocks/gameplay elements in the level editor. I think it's usually best to have one single object with different frames in a 0 speed animation. So I added that in.

    So the different objects are just frames of the edi_block sprite. To add a new object, add a new frame. That's all.

    And all you did( for saving ), as far as I can see, is clearing the array with a value. Where are the events that save the information about the blocks?

    Click on the small plus sign to the left of the condition to reveal the whole event tree. There's actually a loop below that, which sets the value at the current array position to the frame number.

  • So the different objects are just frames of the edi_block sprite. To add a new object, add a new frame. That's all.

    Yes, but the problem is that the blue background is a VOID that is not meant to be seen. I would rather like a second object representing object spawns that overlap the terrain. I fixed this any-who, thanks to the below information:

    Click on the small plus sign to the left of the condition to reveal the whole event tree. There's actually a loop below that, which sets the value at the current array position to the frame number.

    My reaction: WAZZAWHAT?!?

    But thank you so much for the help! I am defiantly crediting you in the credits!

    EDIT: Actually I guess I will end up using objects in the thingamajig because its easier. I forgot I can set the things back to a space after the layout starts.

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