php游戏,根据exp计算等级的公式 [英] php game, formula to calculate a level based on exp

查看:131
本文介绍了php游戏,根据exp计算等级的公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个基于浏览器的PHP游戏,并在我的玩家数据库中记录了该玩家的总EXP或经验.

Im making a browser based PHP game and in my database for the players it has a record of that players total EXP or experience.

我需要的是一个公式,可以将该exp转换为100级或等级.

What i need is a formula to translate that exp into a level or rank, out of 100.

所以他们从第1级开始,当他们说出50 exp时,进入第2级,然后当他们达到125/150,即第2级时.

So they start off at level 1, and when they hit say, 50 exp, go to level 2, then when they hit maybe 125/150, level 2.

基本上是一个公式,该公式稳定地使每个级别更长(更多exp)

Basically a formula that steadily makes each level longer (more exp)

任何人都可以帮忙吗?我不是很擅长数学:P

Can anyone help? I'm not very good at maths :P

推荐答案

许多公式可能都满足您的需求,具体取决于您希望所需的exp增长的速度.

Many formulas may suit your needs, depending on how fast you want the required exp to go up.

实际上,您确实应该使此配置(或至少在一个中央位置轻松更改),以便以后可以平衡游戏.在大多数游戏中,这些(和其他)公式仅在playtesting之后并尝试几种方法确定.

In fact, you really should make this configurable (or at least easily changed in one central location), so that you can balance the game later. In most games these (and other) formulas are determined only after playtesting and trying out several options.

这里是一个公式:第一次升级发生在50 exp;以150exp排名第二;在300 exp时排名第三;在500 exp上排名第四;换句话说,首先,您必须收集50 exp,然后收集100 exp,然后收集150exp,依此类推.这是算术级数.

Here's one formula: First level-up happens at 50 exp; second at 150exp; third at 300 exp; fourth at 500 exp; etc. In other words, first you have to gather 50 exp, then 100 exp, then 150exp, etc. It's an Arithmetic Progression.

要升级X,则需要25*X*(1+X) exp.

For levelup X then you need 25*X*(1+X) exp.

已添加:相反,您只需使用基本数学即可.像这样:

Added: To get it the other way round you just use basic math. Like this:

y=25*X*(1+X)
0=25*X*X+25*X-y

这是标准的二次方程,您可以使用以下方法求解X:

That's a standard Quadratic equation, and you can solve for X with:

X = (-25±sqrt(625+100y))/50

现在,由于我们希望X和Y都大于0,因此我们可以删除其中一个答案并保留:

Now, since we want both X and Y to be greater than 0, we can drop one of the answers and are left with:

X = (sqrt(625+100y)-25)/50

例如,如果我们有300 exp,我们会看到:

So, for example, if we have 300 exp, we see that:

(sqrt(625+100*300)-25)/50 = (sqrt(30625)-25)/50 = (175-25)/50 = 150/50 = 3

现在,这是第三个 levelup ,即4级.

Now, this is the 3rd levelup, so that means level 4.

这篇关于php游戏,根据exp计算等级的公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆