How to find a number between two numbers based on a proportion.

110 Views Asked by At

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.

1

There are 1 best solutions below

0
On BEST ANSWER

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.