level unlock help
ktfright
Member Posts: 964
preferably at either eastbound, firemaple, and Tshirtbooth, but anyone with the answer can chime in also...
I'm making a new game with multiple levels that need to be unlocked by beating the previous level. How do I save the level and keep it unlocked? What ways did you guys go about it?
I'm making a new game with multiple levels that need to be unlocked by beating the previous level. How do I save the level and keep it unlocked? What ways did you guys go about it?
Comments
Also have a 'level complete' variable.
The level complete is changed to 'true' if the level is completed (whatever the 'win' scenario is).
In addition, the 'level x unlocked' variable is set to the next level (if you've just completed level 2, level x is level 3.
Then on your level select screen, have a button for each level. Level 1 is always unlocked.
Each button should have the rule:
If button is pressed, and level unlocked is greater than the level selected, then go to level.
(e.g. if level 2 button is pressed, and level x is greater than 2, then go to level 2).
Hope that makes sense. I've been up all night so it might not be very clear, but should point you in the right direction I hope!
QS
Dr. Sam Beckett never returned home...
Twitter: https://twitter.com/Quantum_Sheep
Web: https://quantumsheep.itch.io
There are a few ways to go about it. The two most common ways are either to force the player to play through the levels in order, or to allow them to play them in any order.
It is much simpler from a programming perspective to force the player to move through the game sequentially. That way, like QS says above, you just need to track one number - the current unlocked level. You would make this global attribute an integer. It would start at 1, since the first level is unlocked. Each button on the level select screen would have an attribute called something like 'myLevel'. It would be set to the number of the appropriate level.
The logic would look like this
When self.myLevel <= game.currentUnlockedLevel
Show unlocked graphic, button is enabled
Otherwise
Show padlock, button is disabled
The other option, allowing the player to play any level they want - but keeping track of the ones they completed - is a little more tedious. You need to keep a separate boolean attribute for each level like this: level1, level2, level3, etc... And you need to add a specific Rule to each button instance like this:
Inside button 1:
When game.level1 is TRUE
Show my 'complete!' indicator ( a check mark, a little star, a smiley face, whatever)
Joe
Every button instance needs a Rule like this.
In my latest game, stunt squirrels, I am tracking 180 different attributes. It gets a little bit tiring trying to keep track of everything the player does!
When you got to the level select screen the each number checks if LevelsUnlocked is higher than the number it is. If it is higher it'll destroy itself.
Then every time you unlock a new level it adds 1 to that number.
The padlock actor prototype would have a Rule like this:
When self.myLevel <= game.levelsUnlocked
Change Attribute: self.Alpha To: 1
You would create an integer attribute inside the prototype of the padlock actor called myLevel. Then you edit that attribute in each instance on the stage.
I got the whole saving and unlocking down to a point, but randomly today I wanted to do a quick playthrough of my game, and I noticed that when I do a level and beat it, it unlocks a level, but when I beat a previous level, the level I unlocked becomes locked again.
I think my rules are set so if the player beats a boss, change the global attribute LevelsUnlocked to whatever number level is unlocked (there is where the problem may be at)
I really need some help on this. Anyone got an idea?
Since your "change scene" behaviors are likely to the next scene this should work fine.