So CyberCrisis is coming along well. There's a few things to be added, like FMV sequences and a few more sound effects, but the bulk of the work is done - now there's just a few pesky bugs left to be fixed. I'd like to thank everyone who's helped so far on the forums, I'll be sure to put a nod to you in the ingame credits. Here's a trailer of the game so far, to show that your assistance has not been in vain! https://vimeo.com/173254063
Now, onto the aforementioned "decimal dilemma". One of the last remaining game bugs is that the health bars do not always accurately depict the health of the units they are floating over, including the player. As this is the only indicator for the players health, this is a pretty major issue.
The reason for this bug, as far as I can tell, is because the system of updating it is so weird - at present, the healthbar(); process is updated by a local variable called "wounded" in the father of the process that called it - which is how processes communicate that they're doing damage to each other in CyberCrisis (via "wounded"). So in the context of the healthbar - "if (father.wounded<>0)" is how the health bar process knows to update itself, taking drawing the red box further to the left of its map. This has an issue when the gameplay gets as frantic as you see in that above trailer there ^^^^ so another solution is required.
Other variables used in the game are health and maxhealth - these should be self explanatory, but essentially maxhealth is the maximum amount of health the player can have, and health is how much health the player currently has. What I thought would be a better idea than using the if (father.wounded<>0) method would be to just update the healthbar(); process every frame, using a calculation between the width of the health bar graphic (50 - 50 pixels wide and 3 pixels high), health and maxhealth - regardless of if the player has taken any damage or not (I would need to somehow adjust this for the enemy units, destructible objects and buildings, as their health variables are private - this could be done with a local variable for health, let's say notplayer_health :p ).
So, the solution I came up with, was firstly to declare some private variables - health_unit and h_unittoremove. health_unit=(50/maxhealth) to come up with the amount of pixels to remove for each health point lost, and h_unittoremove=(health_unit*health), to come up with the total number of pixels to redraw as red (with the red box). Then draw_box(0, 3, h_unittoremove, 3); frame; in the main loop of the process. Now, this works just fine in theory. Maxhealth and health start as the same amount - 300. (you can upgrade the amount of maxhealth you can have later on in the game, through the use of the ingame shop
So, 50/300 (maxhealth) =0.166666666666667 - so 0.166666666666667*300 (health) = 50. Lower the health (the second 300), let's say to halfway - 150 - and you get 0.166666666666667*150 = 25. Perfect. Except, not. Because Bennu does not support floating point maths/decimal points. So what you actually get from 0.166666666666667*300, or 0.166666666666667*150, or 0.166666666666667*anything, is a big fat 0. Doh!
Is there a way around this that anyone can think of? It's a real head scratcher.
Again, thank you so much for everyone's help so far! <3