75 HealthBar - JcerelusDev/CanvasGameJs GitHub Wiki
HealthBar
What is HealthBar ? As its name can describe it,it is used to create healthbar for player"enemies and boss. It has an update method , a draw method and a flip property to reverse the bar if needed in case of fighting game, player bar can decrease from right to left and opponent from left to right
How to use it ?
new HealthBar({x,y},height,borderColor,juiceColor,obj)
player.health = 10
player.healthbar = new HealthBar({x:15,y:30},8,"cyan","dodgerblue",player)
eneemy.health = 10
enemy.healthbar = new HealthBar({x:250,y:30},8,"cyan","gold",enemy)
enemy.healthbar.flip = true
game.update = function(){
player.healthbar.update()
enemy.healthbar.update()
}
game.render = function(){
player.healthbar.draw()
enemy.healthbar.draw()
}