Unlock level please help

svcgamessvcgames Member Posts: 7
edited November -1 in Working with GS (Mac)
I did everything i think but i cant resolve the problem.

I made an unlock attribute integer and set it to 1.

I made self.level at all level buttons like self.level1,self level2 ...

Anyway i did everything at tshirthbooths ( multiscreen menus part3).But the problem is i want to make that when i beat level 1 i just want to unlock level2 and so on...

At another topics they said:

On button 1 say

if touched is pressed and game.unloackedleves is = or greater then 1
go to level 1

when you beat level 1 do this
if game.unloackedlevels is less then 2 ==============}}}}} Where i have to do this and how
can i say when you beat
change game.unloackedleves to 2

Please help me

Comments

  • quantumsheepquantumsheep Member Posts: 8,188
    The problem might be that you're using self. variables - these will reset every time you go into a level.

    Use game. attributes instead so the whole game knows you've completed a level.

    Hope that helps!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • svcgamessvcgames Member Posts: 7
    I am going to try like it

    thanx :)
  • svcgamessvcgames Member Posts: 7
    How we can say ( When you beat a level) to go to next level ?

    How can we say it to game
  • quantumsheepquantumsheep Member Posts: 8,188
    This is basic attribute use - I will try and explain using a real-world example.

    Let's use water.

    Water can have three 'states' - liquid, solid (frozen), and gas (steam)

    In a game, we would give these three states as numbers:
    Liquid: water=0
    Solid: water=1
    Gas: water=2

    So, if we freeze liquid water, the value of water changes from 0 to 1

    In your game, that would be a change behaviour that changes water to 1

    Now rules in your game can be used to change the value e.g.
    Let's say you have three buttons:
    The first one would have a rule so that if you press the button, water = 0
    The second one would have a rule so that if you press the button, water = 1 (frozen)
    The third one would have a rule so that if you press the button, water = 3

    Let's say you pressed another button to 'drink' water

    If water = 0 and button is pressed then display message "mmmmm.... Refreshing!"
    If water = 1 and button is pressed then display message "it's frozen!!!"
    If water = 2 and button is pressed then display message "it burnnnnns!!!!"

    So you can hopefully see how you can use attributes, how you can change them, and how something different happens depending on the value of an attribute!

    In your game, you would have a Boolean attribute for level complete (so it's either true or false)

    So, when *something* happens, change the value of level complete to 'true'

    Now, when level complete is true and you press a button, change to the next level.
    If level complete Is not true (false) then change to the menu (for example)

    I hope this helps. I've seen lots of questions like this, and while my explanation is very basic, I hope it shows that you can use attributes to do nearly anything.

    Remember to think that anything that happens in your game, you need to tell the game what's happened if you want to use that info later.

    So, if you want to count the number of enemies killed, every time you destroy an enemy, make it tell the game that the variable 'enemies killed" is now "enemies killed+1"

    Then you can have a rule that says if enemies killed = 10 then change attribute "level complete" to True.

    I hope that makes sense, and sorry to ramble, I'm on my iPad typing this!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • svcgamessvcgames Member Posts: 7
    Thank yo so much quantumsheep

    this is very helpful for me to understand how it is.. :-)
Sign In or Register to comment.