• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Using Treasures to unlock new rooms[solved]

W

Wild_West

Guest
Okay I was hoping I could get some extra minds to help me with the concept for this setup.

I've started adding additional levels to my game and all is going well, moving from place to place like it should, but for my actual system to unlock new levels to play through, I've run myself into a corner.

I have it et to where the player has to find 3 blocks in each level and set them to a certain color then press enter and he'll be rewarded with a treasure.

The treasure gets stored in a treasure collection array and if you exit the stage with said treasure in hand you unlock the next stage, and keep going through all 6 until you can move to the next world, and play IT'S levels.

So that's all easy enough, but what I now need is a way to clear out the treasures you have upon completing the 6th stage of any world, so you can start collecting the treasures from the next world's stages, but I also need a way to make sure the PREVIOUS world's treasures can't just be recollected and carried over to the next world.

With the exception of the map select, shop, pause and stage select rooms, all my other rooms are set to be persistent upon entering and not persistent upon reaching the goal so they can be played over, which is where my issue of recollecting old treasure comes in.

Any thoughts on how I can keep the blocks from re-spawning treasure once they've been obtained already in any one room?
 
P

piksil_demon

Guest
maybe you can make a global variable for each room that keeps track of how many you have picked up?
(just a thought, i dont quite understand how arrays work yet, so sorry if this solution dosnt apply)
 

NightFrost

Member
Track the pick-up state of each block in an array that resides in a persistent object (for example the same object that tracks the score, lives or whatever you have to persist through the entirety of the game). Instead of placing the blocks directly into rooms through the room editor, put if-checks into room creation code and spawn the blocks only if they haven't been picked up already.
 

Llama_Code

Member
I misread your post.

All you need is a simple variable. If you finish world one, incriment the variable by 1 and clear the array.

In your levels do an if check before spawning the treasure. If your playing a level on world one, and the variable equals one then you have already cleared this world so don't spawn a treasure.

Likewise if your playing a level in world 3 and the variable equals 3, you know the played already cleared that world.
 
Last edited:
W

Wild_West

Guest
Track the pick-up state of each block in an array that resides in a persistent object (for example the same object that tracks the score, lives or whatever you have to persist through the entirety of the game). Instead of placing the blocks directly into rooms through the room editor, put if-checks into room creation code and spawn the blocks only if they haven't been picked up already.
I see what you mean, that sounds like a good idea, only I'm still not sure how I'd place them in each room if that's the case. Because I want each one to be in ind of a little "solve this puzzle" or "overcome this obstcle" to actually reach the block.
So there placement has to be specific.
 
W

Wild_West

Guest
I misread your post.

All you need is a simple variable. If you finish world one, incriment the variable by 1 and clear the array.

In your levels do an if check before spawning the treasure. If your playing a level on world one, and the variable equals one then you have already cleared this world so don't spawn a treasure.

Likewise if your playing a level in world 3 and the variable equals 3, you know the played already cleared that world.
Yeah that's the pattern
 
W

Wild_West

Guest
maybe you can make a global variable for each room that keeps track of how many you have picked up?
(just a thought, i dont quite understand how arrays work yet, so sorry if this solution dosnt apply)
Well it's not so much how many I've picked up as it is what level I've already picked them up in.
 
W

Wild_West

Guest
Oh, right that's perfect! Wow I guess I was way overthinking it lol
Okay then Thanks a lot ^
 

NightFrost

Member
I see what you mean, that sounds like a good idea, only I'm still not sure how I'd place them in each room if that's the case. Because I want each one to be in ind of a little "solve this puzzle" or "overcome this obstcle" to actually reach the block.
So there placement has to be specific.
The blocks are visible in the room and the player needs to walk over to them to pick them up, right? So you can reference the array containing their pick-up state and if necessary, place them into the room with instance_create() at the room coordinates they need to be.
 
W

Wild_West

Guest
The blocks are visible in the room and the player needs to walk over to them to pick them up, right? So you can reference the array containing their pick-up state and if necessary, place them into the room with instance_create() at the room coordinates they need to be.
No actually the player stands over them and presses down to change their color.
Once all 3 of the blocks are the same color, you press enter and then the blocks create a treasure to collect.
It's tied into this whole theme of the world I have where a lot of attributes reference the 6 guardian deities who created the world.
 
P

piksil_demon

Guest
haveyou thought of seting up a global variable for each individual block, and having it to where 0=not used, and 1=used? it may be tedious but it should work
 

Yal

šŸ§ *penguin noises*
GMC Elder
I'd say global variables... a flag array where each treasure is alloted a slot. You'd manually give the treasure objects an array slot via instance creation code, at their room start event they destroy themselves if said slot in the array is true, and when the hero collects them they set said flag to true as well. (The array is initialized to all false in the game start, and saved together with other data when you save/load the game).
 
W

Wild_West

Guest
haveyou thought of seting up a global variable for each individual block, and having it to where 0=not used, and 1=used? it may be tedious but it should work
I'd say global variables... a flag array where each treasure is alloted a slot. You'd manually give the treasure objects an array slot via instance creation code, at their room start event they destroy themselves if said slot in the array is true, and when the hero collects them they set said flag to true as well. (The array is initialized to all false in the game start, and saved together with other data when you save/load the game).

It's okay I used Llama_code's suggestion and it worked out well.
 
Top