resolves #27
This commit is contained in:
@@ -41,6 +41,7 @@ class MazeQuizGame extends EventDispatcher {
|
|||||||
constructor(engine, data) {
|
constructor(engine, data) {
|
||||||
super();
|
super();
|
||||||
data.noPhysics = true;
|
data.noPhysics = true;
|
||||||
|
params.mazeFile = data.style || 'quiz-s2.gltf';
|
||||||
return new Promise(async (resolve, reject)=>{
|
return new Promise(async (resolve, reject)=>{
|
||||||
let questions = data.shuffle ? Utils.shuffleArray(data.questions) : data.questions;
|
let questions = data.shuffle ? Utils.shuffleArray(data.questions) : data.questions;
|
||||||
let def = this.generate(questions);
|
let def = this.generate(questions);
|
||||||
@@ -94,18 +95,18 @@ class MazeQuizGame extends EventDispatcher {
|
|||||||
|
|
||||||
generate(questions, qid = 0, len){
|
generate(questions, qid = 0, len){
|
||||||
let question = questions[qid]
|
let question = questions[qid]
|
||||||
|
len = len || Math.round(Math.random()*tl) + 2;
|
||||||
if (!question) return {
|
if (!question) return {
|
||||||
len:3,
|
len,
|
||||||
userData: { finish: true },
|
userData: { finish: true },
|
||||||
objects:[
|
objects:[
|
||||||
{
|
{
|
||||||
type: 'Gltf',
|
type: 'Gltf',
|
||||||
position:[0,.25,len + .52], scale: [0.037, 0.037, 0.037], rotation: [0, Math.PI/4, 0],
|
position:[0,.25,len + .52], scale: [0.037, 0.037, 0.037], rotation: [0, Math.PI/4, 0],
|
||||||
value: '/static/meshes/award.glb'
|
value: '/static/meshes/quiz/award.glb'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
len = len || Math.round(Math.random()*tl) + 2;
|
|
||||||
|
|
||||||
let directions = Utils.shuffleArray( ['l', 'r', 'f'] )
|
let directions = Utils.shuffleArray( ['l', 'r', 'f'] )
|
||||||
|
|
||||||
@@ -131,19 +132,19 @@ class MazeQuizGame extends EventDispatcher {
|
|||||||
dd = d == 'l' ? 'r' : 'l'
|
dd = d == 'l' ? 'r' : 'l'
|
||||||
}
|
}
|
||||||
if (i == 0){
|
if (i == 0){
|
||||||
let next = this.generate(questions, qid + 1, 3)
|
let next = this.generate(questions, qid + 1, 5)
|
||||||
next.userData.corner = { question };
|
next.userData.corner = { question };
|
||||||
mo[d] = {
|
mo[d] = {
|
||||||
len: 4,
|
len: 5,
|
||||||
[dd]: next
|
[dd]: next
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
mo[d] = {
|
mo[d] = {
|
||||||
userData: { question, qid, answer: i },
|
userData: { question, qid, answer: i },
|
||||||
len: 4,
|
len: 5,
|
||||||
[dd]: {
|
[dd]: {
|
||||||
userData: { corner: { question, penalty: true } },
|
userData: { corner: { question, penalty: true } },
|
||||||
len: 2,
|
len: 3,
|
||||||
objects:[
|
objects:[
|
||||||
{
|
{
|
||||||
...textParams, color:0xff0000, text: question.h, fontSize:0.033, position:[0,.44,2+.96], rotation:[0,Math.PI, 0]
|
...textParams, color:0xff0000, text: question.h, fontSize:0.033, position:[0,.44,2+.96], rotation:[0,Math.PI, 0]
|
||||||
|
|||||||
Reference in New Issue
Block a user