GMS 2 temporary buffs

kureoni

Member
so, in my game there is a store and you can buy buffs, such as movement speed increase buff etc.
right now, when you buy the buff, you gain extra movement speed, but it needs to end after some seconds, but i'm not being able to program that.

so, there is an object in the store and when you click on it, you pay 20 coins and activates an alarm:

left click code:

GML:
if global.coins >= 20{
    global.coins-=20
    alarm[0]=60
}
alarm[0] code:

Code:
global.fast=true

step event:

GML:
if global.fast=true{
    global.playerspd+=4
}
(i also need to know in which event to code the move speed gain, because in the step event it gains 4 speed per frame)

so what i need now is to make the buff ends, i tried programming another alarm but it went wrong

any ideas?
 

woods

Member
something like..?

player create event
spd = 4

player step event
if fast = true {spd = 8}
else
{spd = 4}
 

woods

Member
where are you setting global.fast to false?

should go something along the lines of..



player create event
spd = 4
timer = room_speed * 3 // this is 3 seconds, change for how long you want it to last
fast = false


player step event
if (timer > 0)
{
fast = true;
timer -= 1;
spd = 8;
}
else
{
fast = false;
timer = room_speed * 3; //resets timer
spd = 4;
}
 
Top