S
S
Simple1112022-03-07 19:15:30
C++ / C#
Simple111, 2022-03-07 19:15:30

How to set up an unusual health system?

We have a character whose initial xp=1, when he gets 50 points, his xp++, when he gets 100 points his xp++ again, and so on, I can't do it, I don't understand how to write the condition correctly. Note points are not scored equally, it is possible to go from 49 to 58.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
F
Farawa, 2022-03-07
@Farawa

Make an array of how much experience you need for a certain amount: 50 100 160 280 500 900 and so on.
Keep the total amount of experience, and when starting the scene / adding experience, recalculate the amount of hp

K
Kirill Gusarev, 2022-03-07
@kaka888

Pseudocode

function experienceUp(int amount)
{
    if (player.exp < 50 <= player.exp + amount) {
        player.health++
    } else if (player.exp < 100 <= player.exp + amount) {
        player.health++
    }
    player.exp += amount
}

F
freeExec, 2022-03-08
@freeExec

public int Health => Exp / 50 + 1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question