From acdd7303eb0d5abe95ecadaf14e490d9d0e125dd Mon Sep 17 00:00:00 2001 From: Thaum Date: Tue, 4 Nov 2014 06:55:51 +0000 Subject: [PATCH] Added health bars --- rpg-docs/client/views/healthBar/healthBar.css | 23 ++++ .../client/views/healthBar/healthBar.html | 8 ++ rpg-docs/client/views/healthBar/healthBar.js | 13 +++ rpg-docs/public/svg/bar-border.svg | 109 ++++++++++++++++++ 4 files changed, 153 insertions(+) create mode 100644 rpg-docs/client/views/healthBar/healthBar.css create mode 100644 rpg-docs/client/views/healthBar/healthBar.html create mode 100644 rpg-docs/client/views/healthBar/healthBar.js create mode 100644 rpg-docs/public/svg/bar-border.svg diff --git a/rpg-docs/client/views/healthBar/healthBar.css b/rpg-docs/client/views/healthBar/healthBar.css new file mode 100644 index 00000000..22af9fd4 --- /dev/null +++ b/rpg-docs/client/views/healthBar/healthBar.css @@ -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 */ +} \ No newline at end of file diff --git a/rpg-docs/client/views/healthBar/healthBar.html b/rpg-docs/client/views/healthBar/healthBar.html new file mode 100644 index 00000000..2fcbf80c --- /dev/null +++ b/rpg-docs/client/views/healthBar/healthBar.html @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/rpg-docs/client/views/healthBar/healthBar.js b/rpg-docs/client/views/healthBar/healthBar.js new file mode 100644 index 00000000..08603011 --- /dev/null +++ b/rpg-docs/client/views/healthBar/healthBar.js @@ -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; + } +}); \ No newline at end of file diff --git a/rpg-docs/public/svg/bar-border.svg b/rpg-docs/public/svg/bar-border.svg new file mode 100644 index 00000000..ff833bfa --- /dev/null +++ b/rpg-docs/public/svg/bar-border.svg @@ -0,0 +1,109 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + +