resolves #27
This commit is contained in:
@@ -41,6 +41,7 @@ class MazeQuizGame extends EventDispatcher {
|
||||
constructor(engine, data) {
|
||||
super();
|
||||
data.noPhysics = true;
|
||||
params.mazeFile = data.style || 'quiz-s2.gltf';
|
||||
return new Promise(async (resolve, reject)=>{
|
||||
let questions = data.shuffle ? Utils.shuffleArray(data.questions) : data.questions;
|
||||
let def = this.generate(questions);
|
||||
@@ -94,18 +95,18 @@ class MazeQuizGame extends EventDispatcher {
|
||||
|
||||
generate(questions, qid = 0, len){
|
||||
let question = questions[qid]
|
||||
len = len || Math.round(Math.random()*tl) + 2;
|
||||
if (!question) return {
|
||||
len:3,
|
||||
len,
|
||||
userData: { finish: true },
|
||||
objects:[
|
||||
{
|
||||
type: 'Gltf',
|
||||
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'] )
|
||||
|
||||
@@ -131,19 +132,19 @@ class MazeQuizGame extends EventDispatcher {
|
||||
dd = d == 'l' ? 'r' : 'l'
|
||||
}
|
||||
if (i == 0){
|
||||
let next = this.generate(questions, qid + 1, 3)
|
||||
let next = this.generate(questions, qid + 1, 5)
|
||||
next.userData.corner = { question };
|
||||
mo[d] = {
|
||||
len: 4,
|
||||
len: 5,
|
||||
[dd]: next
|
||||
}
|
||||
}else{
|
||||
mo[d] = {
|
||||
userData: { question, qid, answer: i },
|
||||
len: 4,
|
||||
len: 5,
|
||||
[dd]: {
|
||||
userData: { corner: { question, penalty: true } },
|
||||
len: 2,
|
||||
len: 3,
|
||||
objects:[
|
||||
{
|
||||
...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