I would like to always display Vida: 0
in the last block, even if the value is negative, without doing this "Gambiarra" that I made just below.
Is there a function that rounds vidaInimigo
, without having to create an additional condition: Se(vidaInimigo <= 0) entao EscrevaL("Vida: 0")
?
Becausetheenemyhad4
ofLife,received%with%ofDamage,andgot39
oflife.
IwantedLifetobedisplayedequalto-35
,not0
.
Iimaginethereissomefunctionthatroundsup.
Followthealgorithmcode:
algoritmo"RPG"
var
danoCausado, vidaInimigo, baseDanoPlayer: Inteiro
inicio
baseDanoPlayer <- 50
vidaInimigo <- 100
EscrevaL("Vida: ", vidaInimigo)
Repita
danoCausado <- randi(baseDanoPlayer)
vidaInimigo <- vidaInimigo - danoCausado
EscrevaL(" >>> Dano causado: ", danoCausado)
Se(vidaInimigo <= 0) entao
EscrevaL("Vida: 0")
senao
EscrevaL("Vida: ", vidaInimigo)
FimSe
Ate(vidaInimigo <= 0)
Se (vidaInimigo <= 0) entao
EscrevaL("Inimigo abatido!")
FimSe
fimalgoritmo