diff --git a/index.html b/index.html index 88092b4..5a14356 100644 --- a/index.html +++ b/index.html @@ -2985,11 +2985,22 @@ AFRAME.registerComponent('collision-check', { dependencies: ['raycaster'], init: function () { + let lifePoints = 10 this.el.addEventListener('raycaster-intersection', function (e) { color = e.detail.els[0].getAttribute("color") let rig = document.getElementById("rig").getAttribute("position") - if (color == "red") - rig.z += .5 + if (color == "red"){ + rig.z += .5 // very naive, could instead take the opposite direction, lerping away + setFeedbackHUD("wall hit" + " " + --lifePoints + "<3") + if (lifePoints < 1) { + lifePoints = 10 + setFeedbackHUD("dead, respawing") + rig.set(0,0,0) // really origin? + } + } + if (color == "green"){ + setFeedbackHUD("bonus" + " " + lifePoints++ + "<3") + } }); } }); @@ -3034,7 +3045,7 @@ AFRAME.registerComponent('startfunctions', { - +