|
|
@ -48,18 +48,12 @@ Oh non, les lettres de ton prenom ont ete melangees. Pince chacune avec ta main |
|
|
|
|
|
|
|
|
|
|
|
AFRAME.registerComponent('startfunctions', { |
|
|
|
AFRAME.registerComponent('startfunctions', { |
|
|
|
init: function(){ |
|
|
|
init: function(){ |
|
|
|
addGames() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// example of adding a game programmatically |
|
|
|
let untestedGames = ["checkers", "carcassone"] |
|
|
|
let newEl = document.createElement('a-entity') |
|
|
|
addGame("voxelpaint") |
|
|
|
//let gamename = "checkers" |
|
|
|
addGame("simon") |
|
|
|
//let gamename = "carcassone" |
|
|
|
|
|
|
|
//let gamename = "simon" |
|
|
|
addGames() |
|
|
|
let gamename = "voxelpaint" |
|
|
|
|
|
|
|
newEl.id = gamename |
|
|
|
|
|
|
|
newEl.setAttribute(gamename, "") |
|
|
|
|
|
|
|
newEl.classList.add( "game" ) |
|
|
|
|
|
|
|
AFRAME.scenes[0].appendChild(newEl) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
@ -78,6 +72,15 @@ game manager component |
|
|
|
|
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function addGame(gamename, visible="false"){ |
|
|
|
|
|
|
|
let newEl = document.createElement('a-entity') |
|
|
|
|
|
|
|
newEl.id = gamename |
|
|
|
|
|
|
|
newEl.setAttribute(gamename, "") |
|
|
|
|
|
|
|
newEl.setAttribute("visible", visible) |
|
|
|
|
|
|
|
newEl.classList.add( "game" ) |
|
|
|
|
|
|
|
AFRAME.scenes[0].appendChild(newEl) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function addGames(){ |
|
|
|
function addGames(){ |
|
|
|
const imgPath = "../content/games/previews/" |
|
|
|
const imgPath = "../content/games/previews/" |
|
|
|
const imgExtension = ".jpg" |
|
|
|
const imgExtension = ".jpg" |
|
|
@ -102,6 +105,7 @@ function addGames(){ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function showOnlyThisGame(name){ |
|
|
|
function showOnlyThisGame(name){ |
|
|
|
|
|
|
|
// should also work via URL, e.g hash or query parameter |
|
|
|
Array.from( document.querySelectorAll('.game') ).map( (g,i) => g.setAttribute("visible", "false") ) |
|
|
|
Array.from( document.querySelectorAll('.game') ).map( (g,i) => g.setAttribute("visible", "false") ) |
|
|
|
document.getElementById(name).setAttribute("visible", "true") |
|
|
|
document.getElementById(name).setAttribute("visible", "true") |
|
|
|
document.querySelector("["+name+"]").emit("reset") |
|
|
|
document.querySelector("["+name+"]").emit("reset") |
|
|
@ -217,7 +221,7 @@ AFRAME.registerComponent('simon', { |
|
|
|
el.appendChild(newEl) |
|
|
|
el.appendChild(newEl) |
|
|
|
if (i==1) j++ |
|
|
|
if (i==1) j++ |
|
|
|
}) |
|
|
|
}) |
|
|
|
setTimeout( _ => { document.querySelector("["+generatorName+"]").emit('playSequence') }, 1000) |
|
|
|
//setTimeout( _ => { document.querySelector("["+generatorName+"]").emit('playSequence') }, 1000) |
|
|
|
}, |
|
|
|
}, |
|
|
|
events: { |
|
|
|
events: { |
|
|
|
reset: function (evt) { |
|
|
|
reset: function (evt) { |
|
|
|