diff --git a/src/components/text-counter.js b/src/components/text-counter.js
new file mode 100644
index 0000000..54c9f7e
--- /dev/null
+++ b/src/components/text-counter.js
@@ -0,0 +1,46 @@
+AFRAME.registerComponent('text-counter', {
+ dependencies: ['text'],
+ schema: {
+ value: {default: 0.0, type: 'float'},
+ dur: {default: 2000, type: 'int'},
+ prefix: {default: ''},
+ suffix: {default: ''},
+ decimals: {default: 0}
+ },
+
+ init: function () {
+ this.startTime = null;
+ this.currentValue = -1;
+ },
+
+ decimals: function (n) {
+ var d = Math.pow(10, this.data.decimals);
+ return (parseInt(n * d) / d).toFixed(this.data.decimals);
+ },
+
+ update: function (oldData) {
+ this.startTime = null;
+ this.currentValue = -1;
+ this.el.setAttribute('text', {
+ value: `${this.data.prefix} ${this.decimals(0)} ${this.data.suffix}`
+ });
+ },
+
+ tick: function (time) {
+ if (this.currentValue < this.data.value) {
+ if (this.startTime === null) { this.startTime = time};
+ const prevValue = Math.floor(this.currentValue);
+ this.currentValue = this.data.value * (time - this.startTime) / this.data.dur;
+ if (Math.floor(this.currentValue) !== prevValue) {
+ if (this.currentValue >= this.data.value) {
+ this.currentValue = this.data.value;
+ document.getElementById('victoryInfoRank').emit('appear');
+ document.getElementById('victoryButtons').emit('appear');
+ }
+ this.el.setAttribute('text', {
+ value: `${this.data.prefix} ${this.decimals(this.currentValue)} ${this.data.suffix}`
+ });
+ }
+ }
+ }
+})
\ No newline at end of file
diff --git a/src/state/index.js b/src/state/index.js
index 5b57734..15b9692 100644
--- a/src/state/index.js
+++ b/src/state/index.js
@@ -7,7 +7,7 @@ const SONG_NAME_TRUNCATE = 24;
const SONG_SUB_NAME_TRUNCATE = 32;
const DAMAGE_DECAY = 0.25;
-const DAMAGE_MAX = 10;
+const DAMAGE_MAX = 1000000;
const DEBUG_CHALLENGE = {
author: 'Superman',
@@ -77,12 +77,10 @@ AFRAME.registerState({
},
score: {
accuracy: 0,
- accuracyText: '',
beatsHit: 0,
beatsMissed: 0,
combo: 0,
maxCombo: 0,
- maxComboText: 0,
multiplier: 1,
rank: '', // Grade (S to F).
score: 0
@@ -210,9 +208,8 @@ AFRAME.registerState({
Object.assign(state.challenge, DEBUG_CHALLENGE);
state.isVictory = true;
state.menuActive = false;
- state.score.accuracy = .88;
- state.score.accuracyText = '99.99%';
- state.score.maxComboText = 'MAX COMBO - 123';
+ state.score.accuracy = 74.99;
+ state.score.maxCombo = 123;
state.score.rank = 'B';
state.score.score = 9001;
},
@@ -401,8 +398,6 @@ AFRAME.registerState({
state.score.beatsHit /
(state.score.beatsMissed + state.score.beatsHit);
state.score.accuracy = accuracy;
- state.score.accuracyText = `${(accuracy * 100).toFixed()}%`;
- state.score.maxComboText = `MAX COMBO - ${state.score.maxCombo}`;
if (accuracy === 1) {
state.score.rank = 'S';
diff --git a/src/templates/gameMenu.html b/src/templates/gameMenu.html
index 7ae95d6..c73930d 100644
--- a/src/templates/gameMenu.html
+++ b/src/templates/gameMenu.html
@@ -39,7 +39,8 @@
@@ -47,12 +48,40 @@
+
+
+
+
+
+
+
+
+
+
+
+
+ text="align: center; color: #FAFAFA; wrapCount: 22; baseline: top; width: 1"
+ text-counter="prefix: MAX COMBO: ;"
+ bind__text-counter="value: score.maxCombo"
+ position="0 -0.3 0">