I'm making a game about colors, and recently ran into a simple problem. When the player collides with a block, the players speed increases based on how red the block is. I have a variable called red, which is between 0 and 1, a predefined variable called normalSpeed and maxSpeed, and one called speed. speed should be between normalSpeed and maxSpeed based on the red. if red = 1, speed would equal maxSpeed. What's an equation to do this? Thanks.
Asked
Active
Viewed 109 times
0
-
Do you want the the new speed depend on the current speed? Or will the new speed simply be a function of the redness, regardless of the current speed of the player? – Bram28 Mar 27 '17 at 02:11
1 Answers
2
speed = normal speed + red (maxspeed - normal speed )
when red is $0$, speed = normal speed.
when red is $1$, speed = max speed.
if red is in between $0$ and $1$, you obtain something in between.
Siong Thye Goh
- 149,520
- 20
- 88
- 149