1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

best way to add more value to something

Discussion in 'Development' started by Levi, Jun 30, 2018.

  1. Levi

    Levi Skeleton

    Messages:
    955
    GitHub:
    captainleviftw
    how can i make a levelup system that easy to code

    like i wont have to
    PHP:
    if(players level equals 1){
    set level up cost(22)
    }
    if(
    players level equals 2){
    set level up cost (44)
    }
    i could just make it add 22 per levelup
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Both — a linear and exponential levelling system are easy to code.
    You specified you wanted to add 22 xp per level, which is a linear levelling system.

    Growth chart of linear vs exponential:
    1200px-Exponential.svg.png
    Red = Linear
    Blue = Exponential
    Green = Exponential
    Code:
    levelup_cost = 22 * x
    //x = xp level
    
    While that code is only applicable for levels 1 to infinity, if you are starting from level 0, you could simply add a +1 to the level.
    Code:
    levelup_cost = 22 * (x + 1)
    
    If you want to go with an exponential growth, you could try:
    Code:
    levelup_cost = x ** 2
    //Or 2 ** x (NOTE: they're not the same, see the graph)
    //2 is the growth factor
    //The bigger the growth factor, the larger is the levelup_cost
    
    Both seem simple, preferences?
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.