Erayd
Member
This is code which adds to an alpha value to a certain point and then goes in the other direction. Creating a flash. I'm going over some old code and putting some more thought in to it and my brain is telling me that there are better ways of doing this. How have you done something similarly? Is there a built in method combination that makes this a whole lot better? I think there is.
This is how I have refactored it for now:
Code:
if(taking_Damage){
if(goingDown) current_Alpha -= 0.02;
if(goingUp) current_Alpha += 0.02;
if(current_Alpha == 0.99) {
goingDown = true;
goingUp = false;
}
if(current_Alpha == 0.81){
goingDown = false;
goingUp = true;
}
}
Code:
taking_damage_a += adding ? 0.02 : -0.02;
if(taking_damage_a >= 0.69 || taking_damage_a <= 0.51) adding = !adding;
Last edited: