How do I store level data, array perhaps

Get help using Construct 2

Post » Wed Feb 15, 2017 3:31 pm

Hello,

Lets say I have a layout with 5 square sprites on it. Each square would be a different color on the start of each level and I would like to store these for example like this:

Level 1 - Orange, Yellow, Blue, Red, Green
Level 2 - Brown, Pink, Yellow, Red, Blue
Level 3 - Green, Yellow, Red, Blue, Pink


I just want a single layout that I can use over and over again with the data above. So when the game starts it will load level 1 data and color the squares as indicated. When the player completes level 1 it will then grab the data for level 2 and color the squares accordingly...and so on.

How is best to store this information and get it when needed.

If anyone can also give me a basic example capx or something that would really help.

Thank you.
B
8
S
1
Posts: 17
Reputation: 634

Post » Wed Feb 15, 2017 4:59 pm

Don't think array is required here in any way.
If that's as simple as it sounds you can just create global variable for all levels.

Image
I'm a Magician, not a Developer.
B
21
S
8
G
25
Posts: 105
Reputation: 14,252

Post » Wed Feb 15, 2017 10:25 pm

Use an array where the index of "X" axis is your level (ZERO base, so, index + 1) and "Y" is used to store sprite colors.
Then, in each "On Start Layout" you set the animation to the value at Array[level][sprite], where the value "sprite" is an instance variable you set before to each Sprite.
Lead developer at Octeto Studios

Visit our portfolio at: http://www.octetostudios.com/ :)

Facebook || Twitter || Youtube
B
37
S
7
G
5
Posts: 217
Reputation: 5,614

Post » Thu Feb 16, 2017 12:23 pm

Thanks I'll give those a try.

The game is basically a puzzle game where on each level the player is shown a number of colored squares and then after X seconds the squares go blank and the player must replicate the colors they were shown.

So I just need a way of storing each level/stage of colors and then check the players 'input' to see if they match in order to progress to the next level.
B
8
S
1
Posts: 17
Reputation: 634


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 14 guests