HTML and CSS Reference
In-Depth Information
5. In the quest.js file, we represent the level of data in arrays. The number is the
patern. We will discuss how we come up with this special array structure later:
(function(){
var game = this.colorQuestGame = this.colorQuestGame || {};
// level data
var questLevels = [
[ [5, 6], [3] ],
[ [6], [1, 2]],
[ [5, 6] ],
[ [3], [1, 2], [4] ],
[ [1, 2], [3], [4], [5, 6]],
];
// quest model definition
// quest is a kind of composition, the difference is that
quest is specifically used as the question for player to give the
answer.
// so it comes with comparing logic.
var Quest = game.Quest = (function(){
function Quest(level){
var questData = questLevels[level];
this.data = questData;
}
Quest.prototype = new game.Composition();
// extends the Quest prototype from Composition.
return Quest;
})();
})();
6. Since we have removed the dummy gameover and have finished with the link of
the game scene, now, from the scenes.js file, we will also remove the onclick
event for these two links inside the handleInput method.
7. We add a new method to the gameScene instance that displays the data in the
game scene. This method creates the paterns in the quest area of the game
according to the given data:
gameScene.visualize = function(quest) {
var questData = quest.data;
var patternsToShow = [];
for (var i in questData) {
for (var j in questData[i]) {
patternsToShow.push(questData[i][j]);
}
}
 
Search WWH ::




Custom Search