D
deva56
Guest
Hello everyone. Been messing around with this problem for a few days now and I really cant find any solution as there is no tutorials for this on net as far as I have found , and I really have no more ideas to try anymore combinations as not a single one isnt working the way I want it. So the thing is im creating an android game and i have just two levels now for testing purposes only. When the game starts it goes into the room which is shown in the picture under. Main menu to be exact thing. If you press play it takes you to another room on second picture where you can select between level 1 and 2.
First level is always unlocked , even when you start ur game for the first time but each next level like level 2 can be unlocked only by colliding with the object from the previous level of the level being unlocked. So for instance in level 1 i have a planet that needs to be collided and only when u collide with that planet only for once at least you can then play level 2. I would make this for all levels in the game but i made only two for now for testing. Problem is that without using ini files everything is working as it should only it affcourse doesnt remember anything and when u exit the game you need to start everything again which i dont want to and it has some minor bugs when it resets its value under some condition but nevermind. Things is when i try to make it with ini files it doesnt do properly and doesnt remember things. As much as I hit the plannet in level 1 level 2 wont unlock. I really tried all combinations and it isnt working. Maybe im doing something in wrong order or simply messing something really nice.So lets start. Firstly I have controller object in which i have create event with this code :
global.archive = 0;
ini_open("LevelsData");
ini_write_real("GeneralLevels", "Points", global.archive = 0);
ini_close();
It is defyning a variable that is later used to determine that some level is unlocked or not. The object is persistent to stay inside every room.
Secondly I have object in my first level that when collided with my player adds a point to unlock the next level.
It is collision event with the next code.
ini_open("LevelsData");
ini_read_real("GeneralLevels", "Points", 0);
if global.archive<1
{
ini_write_real("Level2", "Points", global.archive = 1);
ini_close();
}
room_goto(rm_LevelSelect);
It checks if the code from the controller object is less then 1 and if it is adds a value of 1 to the ini file and then goes to to room where you can again chose levels and where you now should be able to play level 2 but u cant .
Thirdly I have my object to select level 2 with room start and left mouse pressed code.
Room start code :
ini_open("LevelsData");
ini_read_real("Level2", "Points", 0);
ini_close();
left mouse pressed code:
if global.archive >= 1
{
room_goto(rm_Level1);
}
else
{
show_message("Not unlocked");
}
In room start code it reads the ini file that should have the value od 1 so when u press left mouse button it checks that it is at least 1 or more and then get you to the next level. But it doesnt it always show that level is not unlocked. So i hope I presented it right, probably too much text but i wanted to give u as many informations as possible . Any help would be aprreciated . Thank you in advance.
First level is always unlocked , even when you start ur game for the first time but each next level like level 2 can be unlocked only by colliding with the object from the previous level of the level being unlocked. So for instance in level 1 i have a planet that needs to be collided and only when u collide with that planet only for once at least you can then play level 2. I would make this for all levels in the game but i made only two for now for testing. Problem is that without using ini files everything is working as it should only it affcourse doesnt remember anything and when u exit the game you need to start everything again which i dont want to and it has some minor bugs when it resets its value under some condition but nevermind. Things is when i try to make it with ini files it doesnt do properly and doesnt remember things. As much as I hit the plannet in level 1 level 2 wont unlock. I really tried all combinations and it isnt working. Maybe im doing something in wrong order or simply messing something really nice.So lets start. Firstly I have controller object in which i have create event with this code :
global.archive = 0;
ini_open("LevelsData");
ini_write_real("GeneralLevels", "Points", global.archive = 0);
ini_close();
It is defyning a variable that is later used to determine that some level is unlocked or not. The object is persistent to stay inside every room.
Secondly I have object in my first level that when collided with my player adds a point to unlock the next level.
It is collision event with the next code.
ini_open("LevelsData");
ini_read_real("GeneralLevels", "Points", 0);
if global.archive<1
{
ini_write_real("Level2", "Points", global.archive = 1);
ini_close();
}
room_goto(rm_LevelSelect);
It checks if the code from the controller object is less then 1 and if it is adds a value of 1 to the ini file and then goes to to room where you can again chose levels and where you now should be able to play level 2 but u cant .
Thirdly I have my object to select level 2 with room start and left mouse pressed code.
Room start code :
ini_open("LevelsData");
ini_read_real("Level2", "Points", 0);
ini_close();
left mouse pressed code:
if global.archive >= 1
{
room_goto(rm_Level1);
}
else
{
show_message("Not unlocked");
}
In room start code it reads the ini file that should have the value od 1 so when u press left mouse button it checks that it is at least 1 or more and then get you to the next level. But it doesnt it always show that level is not unlocked. So i hope I presented it right, probably too much text but i wanted to give u as many informations as possible . Any help would be aprreciated . Thank you in advance.