clean up state
This commit is contained in:
@@ -9,7 +9,7 @@ AFRAME.registerComponent('beat-loader', {
|
||||
beatSpeed: {default: 4.0},
|
||||
challengeId: {type: 'string'},
|
||||
difficulty: {type: 'string'},
|
||||
isPaused: {default: false}
|
||||
isPlaying: {default: false}
|
||||
},
|
||||
|
||||
orientations: [180, 0, 270, 90, 225, 135, 315, 45, 0],
|
||||
@@ -88,7 +88,7 @@ AFRAME.registerComponent('beat-loader', {
|
||||
|
||||
delta *= this.speed;
|
||||
|
||||
if (this.data.isPaused || !this.data.challengeId || !this.beatData || !audioEl) { return; }
|
||||
if (!this.data.isPlaying || !this.data.challengeId || !this.beatData || !audioEl) { return; }
|
||||
|
||||
notes = this.beatData._notes;
|
||||
obstacles = this.beatData._obstacles;
|
||||
|
||||
@@ -1,25 +1,27 @@
|
||||
AFRAME.registerComponent('gameover', {
|
||||
schema: {
|
||||
start: {default: false},
|
||||
reset: {default: false}
|
||||
isGameOver: {default: false}
|
||||
},
|
||||
|
||||
init: function () {
|
||||
this.beatContainer = document.getElementById('beatContainer');
|
||||
},
|
||||
|
||||
update: function (oldData) {
|
||||
var data = this.data;
|
||||
if (data.start){
|
||||
if (!oldData.isGameOver && this.data.isGameOver){
|
||||
console.log('starting slow down...');
|
||||
this.el.sceneEl.setAttribute('stage-colors', 'red');
|
||||
this.countDown = 1;
|
||||
this.lastTime = performance.now();
|
||||
}
|
||||
if (data.reset && data.reset !== oldData.reset){
|
||||
if (oldData.isGameOver && !this.data.isGameOver){
|
||||
this.resetStage();
|
||||
}
|
||||
},
|
||||
|
||||
tick: function (time, delta) {
|
||||
if (!this.data.start) return;
|
||||
if (!this.data.isGameOver) { return; }
|
||||
if (this.countDown >= 0){
|
||||
this.el.sceneEl.emit('slowdown', {progress: this.countDown});
|
||||
//this.beatContainer.object3D.position.z = -Math.pow(1 - this.countDown, 2) * 1.5;
|
||||
@@ -37,4 +39,4 @@ AFRAME.registerComponent('gameover', {
|
||||
this.el.sceneEl.systems.beat.speed = 1.0;
|
||||
this.el.sceneEl.setAttribute('stage-colors', 'blue');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -8,15 +8,13 @@
|
||||
<body>
|
||||
<audio id="introSong" src="assets/sounds/introSong.ogg" loop></audio>
|
||||
|
||||
{% include './templates/debugStates.html' %}
|
||||
|
||||
<a-scene
|
||||
bind__beat-loader="challengeId: challenge.id; difficulty: challenge.difficulty; isPaused: !isPlaying && !isGameOver"
|
||||
bind__beat-loader="challengeId: challenge.id; difficulty: challenge.difficulty; isPaused: !isPlaying"
|
||||
bind__gameover="isGameOver: isGameOver"
|
||||
bind__intro-song="isPlaying: menu.active && !menuSelectedChallenge.id"
|
||||
bind__song="challengeId: challenge.id; isPlaying: isPlaying && !challenge.isLoading"
|
||||
bind__song-preview-system="selectedChallengeId: menuSelectedChallenge.id"
|
||||
bind__overlay="enabled: !isPlaying"
|
||||
bind__debug-states="isPlaying: isPlaying; isPaused: isPaused; isGameOver: isGameOver"
|
||||
console-shortcuts
|
||||
debug-controller
|
||||
effect-bloom="strength: 1"
|
||||
@@ -32,7 +30,6 @@
|
||||
proxy-event__cleargame2="event: pausemenurestart; as: cleargame; to: a-scene"
|
||||
search
|
||||
stage-colors="blue"
|
||||
bind__gameover="start: isGameOver; reset: isPlaying && !isGameOver || menu.active"
|
||||
fog="color: #a00; density: 0.035; type: exponential">
|
||||
<a-assets timeout="10000">
|
||||
<a-asset-item id="arrowObj" src="assets/models/arrow.obj"></a-asset-item>
|
||||
|
||||
@@ -234,7 +234,7 @@ AFRAME.registerState({
|
||||
* Post-process the state after each action.
|
||||
*/
|
||||
computeState: (state) => {
|
||||
state.isPlaying = !state.menu.active && !state.isPaused && !state.isVictory;
|
||||
state.isPlaying = !state.menu.active && !state.isPaused && !state.isVictory && !state.isGameOver;
|
||||
state.leftRaycasterActive = !state.isPlaying && state.activeHand === 'left' && state.inVR;
|
||||
state.rightRaycasterActive = !state.isPlaying && state.activeHand === 'right' && state.inVR;
|
||||
state.multiplierText = `${state.score.multiplier}x`;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
<a-entity mixin="dialogButtonText" text="value: GAME OVER; color: #ff7171; width: 4" bind__visible="isGameOver" position="0 1.8 -2.3"></a-entity>
|
||||
|
||||
<a-entity id="pauseDialog" position="0 1.6 -2" bind__visible="isPaused">
|
||||
<a-entity position="0 1.6 -2" bind__visible="!isPlaying && !menu.active">
|
||||
<a-entity
|
||||
id="resumeButton"
|
||||
mixin="dialogButton"
|
||||
|
||||
Reference in New Issue
Block a user