I am trying to make a function that will power down my ship up grades in a 2d shooter. My thought is if the player picks up a power-up then every 30 seconds it goes down one level till back at base ship level. But I can’t figure it out I read and did the tutorials found on the web e.g. walker boys but all I can get done is move up in the power level but then reset in one swoop to beginning level. It is like going up a ladder and then jumping off. Her is the code I have been working on to have the player go down in levels and not jump there.
function PowerDown(powerUP_levle:int, powerUP_count:int, powerUP_time:string)
{
//First loop will be number of powerups which will need to be added to when another power up it touched
//Second loop will be the timer in seconds
//After each run of the timer decament by one the power up level
var Count : int = powerUP_count;
var Time : int = powerUP_time;
private var C : int;
private var T : int;
//If powerup count is greater then the current count reset the counter to zero and start loop again with new limit
//also reset timer;
if (Count != 0)
{
C=0;
Count++;
T=0;
Time = powerup_time;
}
for (C=0;C<Count;C++)
{
for (T=0; T<Time; T++)
{
yeid;
}
//Once the counter is at zero decament the powerup level
powerUP_level--;
}
return void;
}