Copy link to clipboard
Copied
I have an array that are considered enemies. Their base speed is 2 (enemyBaseSpeed). Depending on what level the user on, the speed increases each time and is multiplied by (speedLevelInc) which is .5. The equation is as follows:
tempEnemy.speed = enemyBaseSpeed + ((level - 1) * speedLevelInc);
I want to give the enemies a maximum speed once they reach a specific level, let's say level 5. When they reach level 5, I want them to run on a constant max speed of let's say 6. Even if they do get to level 6,7,8... I want all of them to run on the max speed. How can I do this?
Copy link to clipboard
Copied
const MAXSPEED:Number = 6;
level < 5 ? tempEnemy.speed = enemyBaseSpeed + ((level - 1) * speedLevelInc) : tempEnemy.speed = MAXSPEED ;
Find more inspiration, events, and resources on the new Adobe Community
Explore Now