This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2013-01-25 11:15:20

Tbtemplex97
Scratcher
Registered: 2011-11-12
Posts: 100+

XP > Level Formula

So i need a Mathematical formula so that it turns xp into a level (max lvl 100)

I want it to double the xp required each time so

Lvl1: 0
Lvl2: 10
Lvl3: 20
Lvl4: 40
Lvl5: 80
Lvl6: 160
Lvl7: 320
Lvl8: 640
Lvl9: 1280
Lvl10: 2560

Etc...


Online Status: http://blocks.scratchr.org/API.php?action=onlineStatus&user=Tbtemplex97
Darkspace Coming Soon!, Try the Singleplayer Demo

Offline

 

#2 2013-01-25 12:01:08

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: XP > Level Formula

Here's the script, and I'll write an explanation below it.http://i47.tinypic.com/34zwthz.gif
(The ExperienceNeeded Variable is unnecessary, it just makes the logic behind the script clearer to someone looking at it.)

The formula to double a certain number for each iteration (or level) is InitialNumber*2^(Iteration-1), or in your case, 10*2^(Level-1), because now each iteration causes the formula to add another *2 into the equation.

Unfortunately, in Scratch there is no exponent ( this symbol:  ^) function, so we need to use other blocks to create one.  An in depth look of how this method works is on the Scratch Wiki, here.

Now all that's left is to make the script check if your Experience variable is greater than the required amount of Experience, and if it's true, to raise the level.

Last edited by Kileymeister (2013-01-25 12:04:57)


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#3 2013-01-25 15:35:26

Tbtemplex97
Scratcher
Registered: 2011-11-12
Posts: 100+

Re: XP > Level Formula

this works very well but, inorder to get lvl 98 you need 1231283091238123812093810238120 xp but lvl 2 is 5xp, is there any way that instead of doubling, the xp required changes by 20% of the former xp required


Online Status: http://blocks.scratchr.org/API.php?action=onlineStatus&user=Tbtemplex97
Darkspace Coming Soon!, Try the Singleplayer Demo

Offline

 

#4 2013-01-25 16:34:35

lalala3
Scratcher
Registered: 2008-10-03
Posts: 100+

Re: XP > Level Formula

Yeah, just change the 2 to 1.2, though exponential growth always gets very extreme very quickly.

Last edited by lalala3 (2013-01-25 16:35:34)


http://img515.imageshack.us/img515/9374/signature2nt.png

Offline

 

Board footer