How can i include power up in my game like an extra life or allowing double jump in platformer for a short period of time?
I can’t explain a complete solution but I can help you with the idea of how something like this can be done.
Basically you need to use variables. If you don’t know what a variable is and how to use them, please read the tutorials on the wiki first.
For example to add extra life after a power up is collected, first you need a variable to store the number of life the player has.
For example life = 2. The actual power up can be an object and you can check collision with the specific object.
If player is in collision with object life_powerup then Do + 1 to life
Or in case by life you mean “health” and you want to increase the maximum health the player can have, you going to need a variable to store the maximum health let say max_health = 100. And basically just do the same:
If player is in collision with object health_powerup then Do + 50 to max_health
Double jump is similar, you can store a value in a variable to set if the player can do double jump or single jump.
If jump = 1 then play can do single jump
If jump = 2 then player can do double jump
If player is in collision with object jump_powerup then Do = 2 to jump
To make the double jump active only for a specific amount of time, you can use a timer
If jump > 1 than reset and unpause timer
If timer >= 10 seconds then Do = 1 to jump and pause timer
You can also use object variables and expressions to set how much a power up object increase something to make it varied. If you don’t know what an object variable and expression is, please read the tutorials on the wiki.
health_powerup.Variable(power) = Random(50)
If player is in collision with object health_powerup then Do + health_powerup.Variable(power) to max_health
Obviously, after each time the player had a collision with a power up, you need to delete the actual object so the player can’t collect it any more and also consider using Trigger Once event and For each object event as necessary. Also, remember if you plan to use a timer multiple times in your scene, don’t forget to pause the timer when it not used any more and reset the timer and unpause when you plan to use it.