Group: Player Blink
In this group we want to set a local variable every 1.5 seconds to and integer random number from 0 to 3. If this number is 1, then we want to play the blink animation.
Create the event System: Every X seconds. Interval (seconds) = 1.5 seconds.
Select this event and hit V on the keyboard to add a local variable. Name it Blink.
For the action, set the Blink variable to an integer random number from 0 to 3.
Create another event which compares the Blink variable. This must equal 1.
The actions for this event are:
-obj_Player start animation from beginning
-obj_Player set the animation speed to 5
Group: Scoring
When the player passes between the girders, we want to add 1 to the current score. We can achieve this by comparing obj_Girder's Y position with obj_Player's Y position.
Select obj_Player from the Projects panel or from the Game layout and take a look at its Y position. This value will never change throughout the game.
The girders travel from top to bottom, thus giving us a change in the Y position. Moving from top to bottom increases the Y position. So, if the girder's Y position is greater than the player's Y positon, then we add 1 to the current score.
The girder's origin is set to the center, while the player's origin is set to the bottom center. We will have to add around 18 pixels to the obj_Player's Y position so that it actually passes the top of the girder. The girder's Y position will then be always greater than the player's Y position. This will cause the score to keep adding up. To fix this, we will have to add a second condition, Trigger once. This will ensure us that the condition will only be executed once while true.
The 2 conditions in 1 event block:
-obj_Girder: Compare Y, and comparison is greater than obj_Player.Y 18
-System: Trigger once
The actions:
-Add 1 to the Global variable Score
-Set spf_Score text to the Global variable Score
-Play the audio file point