愚蠢的简单代数有助于一些编程

时间:2016-11-16 23:04:21

标签: math

我正在为一个游戏编写一个“风”的东西,如果你运行一个特定的风指令,它就会让人们在你周围的半径范围内被吹走。

x is the maximum distance a player can be from the wind source
y is the actual distance a player is from the source of the wind
z is some number between 0 and 10 where if the player is
right next to the wind source z would equal 0 and if
the player is 30 blocks away it would equal 10.
15 blocks away would make z = 5, etc.

x = 30
z = y / x * 10

这一切都很好,但我需要z对面。当玩家在附近时我需要z为10而玩家在30个街区时需要0。 15个街区之外应该是5个等等。

我的数学让我无法理解如何以简单的方式反转这些数字

1 个答案:

答案 0 :(得分:1)

z=(1-y/x)*10

为你工作?