C
Crossoni
Guest
I was wondering why flooring does not work with this code:
For some reason when my skill_bar[1] returns 10, the floor(skill_bar[1]) returns 9. Here is couple ways that fixes it though:
I want to understand why it does this, so can someone tell me what is the problem here?
Code:
//Step event
//Replenish skill bar
skill_bar_restore[1] = 0.004;
if (skill_bar[1] < 10) then skill_bar[1] += skill_bar_restore[1];
//Draw event
if (skill[1] != "empty") then draw_sprite(spr_skill_bar,floor(skill_bar[1]),xx_left+margin,yy_top+space*1.5);
Code:
//Change < to <=
if (skill_bar[1] <= 10) then skill_bar[1] += skill_bar_restore[1];
//Change 10 to 10.01
if (skill_bar[1] < 10.01) then skill_bar[1] += skill_bar_restore[1];