game-mechanics
Fabien Benetou 2 years ago
parent 01f67fa7b1
commit f7a22ed8a6
  1. 12
      index.html

@ -2964,14 +2964,12 @@ AFRAME.registerComponent('collider-check', {
let c = e.detail.els[0].cloneNode() let c = e.detail.els[0].cloneNode()
AFRAME.scenes[0].appendChild(c) AFRAME.scenes[0].appendChild(c)
let pos = e.detail.els[0].getAttribute("position").clone() let pos = e.detail.els[0].getAttribute("position").clone()
console.log("found at", pos) let rig = document.getElementById("rig").getAttribute("position")
let rig = document.getElementById("rig").getAttribute("position") if ( rig.distanceTo( pos ) == 0 ) rig.y++ // TODO doesn't work if the player itself moved
if ( rig.distanceTo( pos ) == 0 ) rig.y++ // TODO doesn't work if the player itself moved
pos.y = Array.from( document.querySelectorAll(".cubes") ) pos.y = Array.from( document.querySelectorAll(".cubes") )
.filter( c => (c.getAttribute("position").x == pos.x && c.getAttribute("position").z == pos.z ) ) .filter( c => (c.getAttribute("position").x == pos.x && c.getAttribute("position").z == pos.z ) )
.sort( (b,a) => a.getAttribute("position").y - b.getAttribute("position").y )[0] .sort( (b,a) => a.getAttribute("position").y - b.getAttribute("position").y )[0]
.getAttribute("position").y + 1 .getAttribute("position").y + 1
console.log("adding at", pos)
c.setAttribute("position", AFRAME.utils.coordinates.stringify( pos) ) c.setAttribute("position", AFRAME.utils.coordinates.stringify( pos) )
c.setAttribute("material", "wireframe:true") c.setAttribute("material", "wireframe:true")
c.classList.add("cubes") c.classList.add("cubes")
@ -3026,7 +3024,11 @@ AFRAME.registerComponent('startfunctions', {
</a-entity> </a-entity>
<a-box pressable start-on-press id="box" scale="0.05 0.05 0.05" color="pink"> <a-box pressable start-on-press id="box" scale="0.05 0.05 0.05" color="pink">
<!-- could attach functions here... BUT then they have to be activable with the other hand! -->
<!-- visual reminders of shortcuts, a poster on the far left/right of keyboard shortcuts -->
</a-box> </a-box>
<!-- ground to clone with raycaster -->
<a-box class="cubes" color="red" position="0 0 -2"></a-box> <a-box class="cubes" color="red" position="0 0 -2"></a-box>
<a-box class="cubes" color="red" position="1 0 -2"></a-box> <a-box class="cubes" color="red" position="1 0 -2"></a-box>
<a-box class="cubes" color="red" position="-1 0 -2"></a-box> <a-box class="cubes" color="red" position="-1 0 -2"></a-box>
@ -3036,8 +3038,6 @@ AFRAME.registerComponent('startfunctions', {
<a-box class="cubes" color="blue" position="0 0 0"></a-box> <a-box class="cubes" color="blue" position="0 0 0"></a-box>
<a-box class="cubes" color="blue" position="1 0 0"></a-box> <a-box class="cubes" color="blue" position="1 0 0"></a-box>
<a-box class="cubes" color="blue" position="-1 0 0"></a-box> <a-box class="cubes" color="blue" position="-1 0 0"></a-box>
<!-- could attach functions here... BUT then they have to be activable with the other hand! -->
<!-- visual reminders of shortcuts, a poster on the far left/right of keyboard shortcuts -->
<a-entity light="type: ambient; color: #BBB; intensity: 0.6"></a-entity> <a-entity light="type: ambient; color: #BBB; intensity: 0.6"></a-entity>
<a-entity light="type: directional; color: #FFF; intensity: 1.4" position="-0.5 1 1"></a-entity> <a-entity light="type: directional; color: #FFF; intensity: 1.4" position="-0.5 1 1"></a-entity>

Loading…
Cancel
Save