Added health bars

This commit is contained in:
Thaum
2014-11-04 06:55:51 +00:00
parent 0d941bff47
commit acdd7303eb
4 changed files with 153 additions and 0 deletions

View File

@@ -0,0 +1,23 @@
.healthBar{
width: 320px;
height: 30px;
}
.healthBarInner{
height: 100%;
border-radius: 15px;
background-color: green;
}
.healthBarBorder{
position: relative;
left: 0px;
top: -100%;
width: 100%;
height: 100%;
background-image: url('/svg/bar-border.svg');
display: flex;
justify-content: center; /* align horizontal */
align-items: center; /* align vertical */
}

View File

@@ -0,0 +1,8 @@
<template name="healthBar">
<div class= "healthBar">
<div class="healthBarInner" style="width: {{hpPercent}}%"></div>
<div class="healthBarBorder">
<span class="hpReadout">{{attributeValue attributes.hitPoints}}/{{maxHp}}</span>
</div>
</div>
</template>

View File

@@ -0,0 +1,13 @@
Template.healthBar.helpers({
hpPercent: function(){
var currentHp = this.attributeValue(this.attributes.hitPoints);
var damage = this.attributes.hitPoints.base;
return 100*(currentHp/(currentHp - damage));
},
maxHp: function(){
var currentHp = this.attributeValue(this.attributes.hitPoints);
var damage = this.attributes.hitPoints.base;
return currentHp - damage;
}
});