I needed all of the images on my book-game "Lonely Girl" to be clicked a least once in order do advance to the next page.
Being such a newbie at coding it, I figured out a solution using only click and drag programming features on Game Maker.
I created an object control named obj_count with an event setting lives to 5 (3 in my test project):
The Set lives action number is absolute, do not check relative:
Then I added the event No More Lives to print on the screen an arrow that enables us to go to the next pages. This obj_arrow is only created if lives go down to zero:
Then placed this control object on the room (it is not set to visible and it has no sprite).
To make lives go down only once per object clicked, I created a variable that prevents that clicking the same object more than once would decrease lives multiple times.
Added a Create Event and set a variable unique to that object, in this case var_bola:
then set the value to absolute 1:
Created an Event Left Mouse Release, (i have chosen release because left mouse pressed is counted multiple times depending on how much time we press the button - this way I am sure it count only one click).
Added a test variable event, indicating that, if the variable var_bola is greater than zero, it should decrease it by 1 (set variable var_bola to -1), decrease lives by 1 (set lives relative to -1) and change the sprite in some way (this step is not needed - this is just a game effect).
This time we need to check the lives to relative -1 so it decreases on the absolute number of lives:
We need to do also the same to the Variable var_bola, check the relative box:
This way, as any object is clicked, if his value is greater than 0, it decreases its value and decreases the live. If it zero, it does nothing (not decreasing lives either). This way, the object obj_arrow needed to advance to the next room is only created after clicking all the object I wish to be clicked.
Take note that the absolute number of lives is always equal to the number of object to be clicked.
Being such a newbie at coding it, I figured out a solution using only click and drag programming features on Game Maker.
I created an object control named obj_count with an event setting lives to 5 (3 in my test project):
The Set lives action number is absolute, do not check relative:
Then I added the event No More Lives to print on the screen an arrow that enables us to go to the next pages. This obj_arrow is only created if lives go down to zero:
Then placed this control object on the room (it is not set to visible and it has no sprite).
To make lives go down only once per object clicked, I created a variable that prevents that clicking the same object more than once would decrease lives multiple times.
Added a Create Event and set a variable unique to that object, in this case var_bola:
then set the value to absolute 1:
Created an Event Left Mouse Release, (i have chosen release because left mouse pressed is counted multiple times depending on how much time we press the button - this way I am sure it count only one click).
Added a test variable event, indicating that, if the variable var_bola is greater than zero, it should decrease it by 1 (set variable var_bola to -1), decrease lives by 1 (set lives relative to -1) and change the sprite in some way (this step is not needed - this is just a game effect).
This time we need to check the lives to relative -1 so it decreases on the absolute number of lives:
We need to do also the same to the Variable var_bola, check the relative box:
This way, as any object is clicked, if his value is greater than 0, it decreases its value and decreases the live. If it zero, it does nothing (not decreasing lives either). This way, the object obj_arrow needed to advance to the next room is only created after clicking all the object I wish to be clicked.
Take note that the absolute number of lives is always equal to the number of object to be clicked.
Comments
Post a Comment