Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How can I have a maximum speed for my objects?

New Here ,
Nov 17, 2013 Nov 17, 2013

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?

TOPICS
ActionScript
306
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Nov 18, 2013 Nov 18, 2013
LATEST

const MAXSPEED:Number = 6;

level < 5 ? tempEnemy.speed = enemyBaseSpeed + ((level - 1) * speedLevelInc) : tempEnemy.speed = MAXSPEED ;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines