Shared by: prowebber.ru
Created: 30/8/2017
By: demonisblack
Email: demonisblack@gmail.com
Thank you for purchasing my game. If you have any questions that are beyond the scope of this help file, please feel free to email via my user page contact form here. Thanks so much!
Quiz Game 2 is a HTML5 game with free general knowledge quiz questions and multiple choice answers, it is rebuild without canvas which can support responsive for landscape and portrait layout, and include the new fill in the blank and video question.
The ZIP package contains the game with 1200×650 resolution that scales to fit the whole screen device, but it may not be perfectly full screen.




To install the game just upload folder 'game' to your server. The game won't run locally with some browser like Chrome due to some security mode.
You need a website that runs PHP to make facebook share button work, and make sure to change Facebook Open Graph meta and Twitter meta in index.html, just replace [GAME_URL] to your game URL.
<!-- for Facebook -->
<meta property="og:image" content="[GAME_URL]/share.jpg" />
<meta property="og:url" content="[GAME_URL]" />
<!-- for Twitter -->
<meta name="twitter:image" content="[GAME_URL]/share.jpg" />
You can easily customize game text and settings in game.js file
var stageW=1200; //game width
var stageH=650; //game height
var portraitW=380; //game portrait width
var portraitH=600; //game portrait height
var fitToScreen = true; //fit to browser screen
var maintainAspectRatio = true; //maintain aspect ratio
var loaderText = 'Loading question...'; //game loading text
var categoryPage = true; //show/hide category select page
var categoryAllOption = true; //add ALL category select option
var categoryAllText = 'All'; //text for all category select option
var questionTotalDisplay = '[NUMBER]/[TOTAL]:'; //current question and total question display
var totalQuestions = 0; //set 0 for all questions, set more than 0 to limit questions
var enableRandomQuestion = true; //enable question in random sequence
var enableRandomAnswer = true; //enable answer in random sequence
var enableRevealAnswer = true; //enable reveal answer
var enableExplanation = true; //enable show explanation
var enableCountdownTimer = true; //enable countdown timer
var coundownTimer = 25; //countdown timer
//question property
var questionFontSize = 50;
var questionLineHeight = 50;
var questionColor = '#fff';
var questionTop = 25;
var questionLeft = 5;
var questionWidth = 90;
var questionHeight = 30;
var questionAlign = 'center';
//video property
var videoTop = 15;
var videoLeft = 30;
var videoWidth = 40;
var videoHeight = 41;
var videoAutoplay = true;
var videoControls = true;
//answers property
var answerFontSize = 40;
var answerLineHeight = 40;
var answerColor = '#fff';
var answerAlign = 'center';
var answerWidth = 30;
var answerHeight = 14;
var answerOffsetTop = -15;
var answerListsEnable = true; //enable answer list style
var answerLists = ['a) ','b) ','c) ','d) ','e) ','f) ','g) ','h) ']; //answer list style formatn, maximum 8
var answerAnimationEnable = true; //enable answer animation
var answerButtonBgEnable = true; //toggle answer button background
var answerButtonBgRoundNumber = 15; //answer button background round corner number
var answerButtonBgColour = '#a2cd4a'; //answer button background colour
var answerButtonBgShadowColour = '#6fad4e'; //answer button background shadow colour
var answeredButtonBgColour = '#f89a31'; //answered button background colour
var answeredButtonBgShadowColour = '#dc4832'; //answered button background shadow colour
var wrongButtonBgColour = '#989898'; //answered button background colour
var wrongButtonBgShadowColour = '#666'; //answered button background shadow colour
var audioQuestionDelay = 300; //timer delay to play question audio
var audioAnswerDelay = 100; //timer delay to play answer audio
//inputs property
var inputFontSize = 40;
var inputLineHeight = 40;
var inputColor = '#333';
var inputBackground = '#fff';
var inputAlign = 'center';
var inputWidth = 20;
var inputHeight = 10;
var inputTop = 50;
var inputLeft = 40;
var inputOffsetTop = -15;
//correct or wrong property
var correctDisplayText = 'That\'s Correct!';
var wrongDisplayText = 'INCORRECT!';
var quesResultFontSize = 50;
var quesResultLineHeight = 50;
var quesResultColor = '#fff';
var quesResultTop = 30;
var quesResultLeft = 5;
var quesResultWidth = 90;
var quesResultHeight = 30;
var quesResultAlign = 'center';
//explanation property
var explanationFontSize = 35;
var explanationLineHeight = 35;
var explanationColor = '#fff';
var explanationTop = 45;
var explanationLeft = 5;
var explanationWidth = 90;
var explanationHeight = 30;
var explanationAlign = 'center';
//result
var scoreDisplayText = 'You score : [NUMBER]!'; //score result display text
//Social share, [SCORE] will replace with game score
var shareEnable = true; //toggle share
var shareTitle = 'Highscore on Quiz Game 2 Game is [SCORE]pts';//social share score title
var shareMessage = '[SCORE] is mine new highscore on Quiz Game 2 Game! Try it now!'; //social share score message
If you wish to customize the question and answer via XML file, check out XML File section.
If you wish to customize the question and answer with build-in tool, check out Build-In Editor Tool section.
If you wish to check out question templates, check out Question Templates section.
If you wish to enable scorebard, check out Scorebard section.
The sound can be easily disabled to avoid compatibility issues in sound.js file:
var enableMobileSound = true;
The page start with the loader wrapper that covering the whole screen in the body. It shows loader progress when calls the function initPreload()
<!-- PERCENT LOADER START-->
<div id="mainLoader"><img src="assets/loader.png" /><br><span>0</span></div>
<!-- PERCENT LOADER END-->
Follow by one HTML tag in the body. The game start initiatie by calls the main function of the game initMain().
<!-- CONTENT START-->
<div id="mainHolder">
</div>
<!-- CONTENT END-->
I'm using two CSS files in this game. The first one is a generic reset file. Many browser interpret the default behavior of html elements differently. By using a general reset CSS file, we can work round this. This file also contains some general styling, such as anchor tag colors, font-sizes, etc. Keep in mind, that these values might be overridden somewhere else in the file.
The second file contains all of the specific stylings for the page.
This game using Javascript files below.
Complete game flow:
The most important functions used for page.
The most important functions used for game.
The game contain 'design' folder which include following:
The folder 'assets' in 'game' folder contains all the images of the game that can be replaced. Is better to have the same size of the old ones if you want to reskin the game graphic without coding.
You can easily build or edit Question and Answer in questions.xml file
All Question and Answer are store in each XML item, sample code below:.
<item>
<category>IQ Questions</category>
<landscape>
<question type="text" top="17" audio="assets/sounds/questions/iq_q8.ogg"><![CDATA[If Bob sold 15 apples in a working week, what is the average number of apples he sells each day?]]></question>
<answers correctAnswer="2">
<answer type="text" top="48" width="35" left="14" audio="assets/sounds/questions/iq_q8_a.ogg"><![CDATA[1]]></answer>
<answer top="48" type="text" left="51" width="35" audio="assets/sounds/questions/iq_q8_b.ogg"><![CDATA[3]]></answer>
<answer top="65" type="text" left="14" width="35" audio="assets/sounds/questions/iq_q8_c.ogg"><![CDATA[6]]></answer>
<answer top="65" type="text" left="51" width="35" audio="assets/sounds/questions/iq_q8_d.ogg"><![CDATA[15]]></answer>
</answers>
<inputs/>
<explanation audio="assets/sounds/questions/iq_q8_explain.ogg"><![CDATA[ There are 5 days in a working week, so you divide 15 by 5 = 3. ]]></explanation>
<video left="5" top="22" width="90" height="33" autoplay="true" controls="true">assets/questions/mov_bbb.mp4</video>
</landscape>
<portrait>
<question type="text" top="12" fontSize="25" lineHeight="25" audio="assets/sounds/questions/iq_q8.ogg"><![CDATA[If Bob sold 15 apples in a working week, what is the average number of apples he sells each day?]]></question>
<answers correctAnswer="2">
<answer type="text" width="90" height="10" top="35" fontSize="35" lineHeight="35" offsetTop="-15" audio="assets/sounds/questions/iq_q8_a.ogg"><![CDATA[1]]></answer>
<answer width="90" height="10" top="47" type="text" fontSize="35" lineHeight="35" offsetTop="-15" audio="assets/sounds/questions/iq_q8_b.ogg"><![CDATA[3]]></answer>
<answer width="90" height="10" top="59" type="text" fontSize="35" lineHeight="35" offsetTop="-15" audio="assets/sounds/questions/iq_q8_c.ogg"><![CDATA[6]]></answer>
<answer width="90" height="10" top="71" type="text" fontSize="35" lineHeight="35" offsetTop="-15" audio="assets/sounds/questions/iq_q8_d.ogg"><![CDATA[15]]></answer>
</answers>
<inputs/>
<explanation type="text" fontSize="30" lineHeight="30" audio="assets/sounds/questions/iq_q8_explain.ogg"><![CDATA[ There are 5 days in a working week, so you divide 15 by 5 = 3. ]]></explanation>
<video left="5" top="22" width="90" height="33" autoplay="true" controls="true">assets/questions/mov_bbb.mp4</video>
</portrait>
</item>
Below is the explanation of each most important XML elements:
<category>IQ Questions</category>
<landscape></landscape>
<portrait></portrait>
<question type='image'>assets/questions/blank1.png</question>
#IMPORTANS:
- Each questions must only have either answers/inputs only one of these settings, it will not run with both
- For multiple choice answers it must have at least one submit button for user to submit answer
- For input it must have at least one type of BLANK and a submit button for user to submit answer
You can add category thumbnail with format below.
<category>
<thumb name="IQ Questions">assets/item_thumb_1.png</thumb>
<thumb name="Math Puzzles">assets/item_thumb_2.png</thumb>
<thumb name="All">assets/item_thumb_3.png</thumb>
</category>
This is the section where you can preview or edit the question with the tool by running edit.html.
You may check out Question Templates section.
There are total 18 type of templates:


















Build-In Editor Tool come with the 'Save XML' button, follow steps below to use the feature:
$savePassord = '12345';
$saveEnable = true;
Scoreboard is a option where user can submit score and view top 10 leaderboard, follow the steps below to setup and run scoreboard.
CREATE TABLE quizgame2_scores (
id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(30) NOT NULL DEFAULT 'anonymous',
email VARCHAR(30) NOT NULL,
type VARCHAR(30) NOT NULL,
score INT(100) UNSIGNED NOT NULL DEFAULT 0,
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) CHARSET=utf8 DEFAULT COLLATE utf8_unicode_ci;
$host = "localhost"; // MySQL hostname
$dbUserName = "root"; // MySQL database username
$dbPwd = ""; // MySQL database password
$dbName = "scoreboard"; // The name of the database
$table = "quizgame2_scores"; //the name of the table
Enable the scoreboard by changing 'displayScoreBoard' to true in score.js, you can easily customize other settings in here
var displayScoreBoard = false; //toggle submit and scoreboard button
var scoreBoardTitle = 'TOP 10 Scoreboard'; //text for scoreboard title
var scoreRank_arr = ['1st','2nd','3rd','4th','5th','6th','7th','8th','9th','10th']; //scoreboard ranking list
var submitTitle = 'Submit your score'; //text for submit title
var score_arr = [{col:'RANK', percent:8, align:'center'},
{col:'NAME', percent:42, align:'left'},
{col:'CATEGORY', percent:20, align:'center'},
{col:'SCORE', percent:30, align:'center'}];
This game is build for Desktop browsers that support HTML5 canvas. Any mobile/tablet should work in landscape view, but they are not officially supported.
I've used the following font and sound files as listed.
Once again, thank you so much for purchasing this game. As I said at the beginning, I'd be glad to help you if you have any questions relating to this game. No guarantees, but I'll do my best to assist. If you have a more general question relating to the games on CodeCanyon, you might consider visiting the forums and asking your question in the "Item Discussion" section.
If you like my game, please take a moment to rate it. Thanks! 




demonisblack