I need to create a healthbar for my game that decreases along with a player's health, so I came up with this piece of code which is called once every game loop. It works as it should, but slows the game down horribly. Does anyone know what's wrong with this method?
The 'HealthDisplay_Handle' is a 1x8 res image which makes up the healthbar. 236 is the total possible length in pixels of the healthbar.
[CODE]
For x = 1 To 236
For player1.entity = Each entity
P1_HealthUnit# = 236/player1\MaxHealth
P1_TranslatedHealth# = player1\health# * P1_HealthUnit#
If x <= P1_TranslatedHealth#
DrawImageBB HealthDisplay_Handle,(P1_PicX+36)+x,(P1_PicY-8)+ScreenLimitTop
EndIf
Next
Next
[/CODE]
The 'HealthDisplay_Handle' is a 1x8 res image which makes up the healthbar. 236 is the total possible length in pixels of the healthbar.
[CODE]
For x = 1 To 236
For player1.entity = Each entity
P1_HealthUnit# = 236/player1\MaxHealth
P1_TranslatedHealth# = player1\health# * P1_HealthUnit#
If x <= P1_TranslatedHealth#
DrawImageBB HealthDisplay_Handle,(P1_PicX+36)+x,(P1_PicY-8)+ScreenLimitTop
EndIf
Next
Next
[/CODE]