In a regular shoot em up the player flickers and is invincible for a couple of seconds after losing a life.
It was easy to implement this feature but i wonder if there is a better/smarter way to do this.
This is what i do in the update routine of the player object:
Code: Select all
if invincible then
invincible_indicator_timer = invincible_indicator_timer + 1 * dt
if invincible_indicator_timer <= 2 then
invincible_timer = invincible_timer + 1 * dt
if invincible_timer >= 0.05 then
active_image = 'invincible'
invincible_timer = 0
else
active_image = 'normal'
end
else
active_image = 'normal'
invincible = false
invincible_indicator_timer = 0
end
end
In the collision detection routine i check for player.invincible to ignore collisions.
Is this how i should do stuff like this or are there better ways?
Regards, TM