rounding numbers?

hexedronin

Villager
Member
Joined
May 29, 2016
Messages
19
Reaction score
0
First Language
English
Primarily Uses
I want to kind of inflate my numbers so instead of doing 1 damage, do 10 damage. I want to have my HP and MP always round to a 10. is there a way to do that?
 

mjshi

Jack of Most Trades
Veteran
Joined
Feb 16, 2013
Messages
969
Reaction score
807
First Language
English
Primarily Uses
N/A
This can be done easily in programming, what language is your game in? (i.e., which engine? MV?)


I'll assume MV, and that's Javascript. So, this would round any number to the highest 10 (so 12 would be 20, 101 would be 110, etc)


Math.ceil(NUMBER / 10) * 10


edit: also, if you wanted to make it a function:


function toTen(num) {
return Math.ceil(num / 10) * 10
}


so you could round anything to the highest 10 by calling toTen(number)
 
Last edited by a moderator:

hexedronin

Villager
Member
Joined
May 29, 2016
Messages
19
Reaction score
0
First Language
English
Primarily Uses
Thanks! this was exactly what I was looking for!
 

Kes

Veteran
Veteran
Joined
Aug 3, 2012
Messages
22,299
Reaction score
11,712
First Language
English
Primarily Uses
RMVXA
"How do I...?" questions belong in the Support forum for the engine you are using.  So, 


I've moved this thread to RPGMaker MV. Please be sure to post your threads in the correct forum next time. Thank you.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,862
Messages
1,017,045
Members
137,569
Latest member
Shtelsky
Top