• 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!

Locked Levels

J

Januxor

Guest
Ok so! I dont know what is wrong with this code:
I made create event for LEVEL_UNLOCKED and I made creation event like level = 0; , level = 1; , level = 2;
Can somebody help?When I run the game nothing happends with levels(I mean msg).And this is left pressed event!
switch(level){
case 0: {
if(global.LEVEL_UNLOCKED >= 1) {
show_message("Level One");
}else show_message("Level not unlocked");
break;
}
case 1: {
if(global.LEVEL_UNLOCKED >= 2) {
show_message("Level Two");
}else show_message("Level not unlocked");
break;
}
case 2: {
if(global.LEVEL_UNLOCKED >= 3) {
show_message("Level Three");
}else show_message("Level not unlocked");
break;

}
}
 
F

fxokz

Guest
Ok so! I dont know what is wrong with this code:
I made create event for LEVEL_UNLOCKED and I made creation event like level = 0; , level = 1; , level = 2;
Can somebody help?When I run the game nothing happends with levels(I mean msg).And this is left pressed event!
switch(level){
case 0: {
if(global.LEVEL_UNLOCKED >= 1) {
show_message("Level One");
}else show_message("Level not unlocked");
break;
}
case 1: {
if(global.LEVEL_UNLOCKED >= 2) {
show_message("Level Two");
}else show_message("Level not unlocked");
break;
}
case 2: {
if(global.LEVEL_UNLOCKED >= 3) {
show_message("Level Three");
}else show_message("Level not unlocked");
break;

}
}
Okay so im just going to go ahead and say you probably used realtutsgmls tutorial am i correct? Also what exactly is the problem you have with the code? Is it not showing a message? are you getting an error?
 
S

signal

Guest
If your levels are unlocked in numerical order, you can simply do something like this:

Create:
Code:
mLevel = 1; // the level the player is trying to play
mMaxLevel = 1; // the maximum unlocked level
On click:
Code:
if mLevel <= mMaxLevel {
    show_message("Level " + string(mLevel));
} else {
    show_message("Level locked");
}
 
F

fxokz

Guest
Ok so! I dont know what is wrong with this code:
I made create event for LEVEL_UNLOCKED and I made creation event like level = 0; , level = 1; , level = 2;
Can somebody help?When I run the game nothing happends with levels(I mean msg).And this is left pressed event!
switch(level){
case 0: {
if(global.LEVEL_UNLOCKED >= 1) {
show_message("Level One");
}else show_message("Level not unlocked");
break;
}
case 1: {
if(global.LEVEL_UNLOCKED >= 2) {
show_message("Level Two");
}else show_message("Level not unlocked");
break;
}
case 2: {
if(global.LEVEL_UNLOCKED >= 3) {
show_message("Level Three");
}else show_message("Level not unlocked");
break;

}
}
Just use this formula.
Code:
if (global.LEVEL_UNLOCKED >= level)
{
    room_goto(asset_get_index("roomprefix" + string(level)));
}
so the level variable should be the same as the rooms name for example you have 2 rooms in your game:

room_1
room_2

you should use:
Code:
room_goto(asset_get_index("room_" + string(level)));
level should be in the create event of the button you are clicking
 
J

Januxor

Guest
Okay so im just going to go ahead and say you probably used realtutsgmls tutorial am i correct? Also what exactly is the problem you have with the code? Is it not showing a message? are you getting an error?
Yes cause I wasn't sure how to do that.And I am not getting any error but I guess I will do something like you.


edit: and no its not showing anything but idk why only once it showed o_O
 
J

Januxor

Guest
I am really bad at this :( , I tried again and its still not working. I am trying to do that I can unlock level with points.
 
Top