[HELP] Saving Level data in an Array

For questions about using Classic.

Post » Tue Jan 18, 2011 5:18 am

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. 8) )
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Tue Jan 18, 2011 12:47 pm

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: viewtopic.php?f=8&t=8162&start=0
Haven't tried that one myself.

[quote="Phobos002":16tjhw0c]Please help if you can. (And I know you can. 8) )[/quote:16tjhw0c]
You're right about that. :D
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.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Wed Jan 19, 2011 2:20 am

[quote="PixelRebirth":racaw3lf]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: viewtopic.php?f=8&t=8162&start=0
Haven't tried that one myself.

[quote="Phobos002":racaw3lf]Please help if you can. (And I know you can. 8) )[/quote:racaw3lf]
You're right about that. :D
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.[/quote:racaw3lf]

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. :)
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Wed Jan 19, 2011 10:26 am

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

[url:2k66x6gs]http://dl.dropbox.com/u/2306601/plinus_edit.cap[/url:2k66x6gs]

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. :)
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Thu Jan 20, 2011 12:41 am

[quote="PixelRebirth":o8brb7zl]Okay, I took a look at your cap and made some edits:

[url:o8brb7zl]http://dl.dropbox.com/u/2306601/plinus_edit.cap[/url:o8brb7zl]

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. :)[/quote:o8brb7zl]

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? :cry:
B
26
S
7
G
5
Posts: 202
Reputation: 5,235

Post » Thu Jan 20, 2011 1:52 am

[quote="Phobos002":1lnqevo2]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.[/quote:1lnqevo2]

Hehe, well, as I said:

[quote="PixelRebirth":1lnqevo2]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.[/quote:1lnqevo2]

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

[quote="Phobos002":1lnqevo2]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? :cry:[/quote:1lnqevo2]

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.
B
21
S
6
G
10
Posts: 1,024
Reputation: 7,445

Post » Thu Jan 20, 2011 4:09 am

[quote="PixelRebirth":yue95z2d]

So the different objects are just frames of the edi_block sprite. To add a new object, add a new frame. That's all. [/quote:yue95z2d]

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:



[quote="PixelAwesome":yue95z2d]
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.[/quote:yue95z2d]

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. :)
B
26
S
7
G
5
Posts: 202
Reputation: 5,235


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests