Skip to content

Added levels of complexity for passiveOn and motionCommotion #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 43 additions & 8 deletions js/motionCommotion.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,22 @@ var left;
var right;
var startGame = 0;

var numOfFigures = 7;

var figOne;
var figTwo;
var figThree;
var figFour;
var figFive;
var figSix;
var figSeven;
//Higher complexity
var complexityLevel=0;
var figEight;
var figNine;
var figTen;
var figEleven;

var decider=[];
var sprites=[];
var currSprite;
Expand Down Expand Up @@ -110,7 +119,7 @@ function spriteCreation()
sprites=[figOne, figTwo, figThree, figFour, figFive, figSix, figSeven];


for (var i = 0; i < 7; i++) {
for (var i = 0; i < numOfFigures; i++) {
currSprite = sprites[i];
currSprite.scale.setTo(0.65,0.65);
game.physics.p2.enable(currSprite);
Expand Down Expand Up @@ -148,7 +157,7 @@ function update()
playpause.events.onInputUp.add(pauseAndPlay);


for (var j = 0; j < 7; j++) {
for (var j = 0; j < numOfFigures; j++) {
currSprite = sprites[j];
if (decider[j]===0) {
currSprite.body.rotateRight(150);
Expand Down Expand Up @@ -179,7 +188,7 @@ function updateRotations()
answer=10;
answered=19;

for (var i = 0; i < 7; i++)
for (var i = 0; i < numOfFigures; i++)
{
decider[i] = game.rnd.integerInRange(1,100) % 2 ;
}
Expand Down Expand Up @@ -400,10 +409,41 @@ function updateLevel()
{
mylevel.setText(level);
}
//check complexity level (0 - 7 figures, 1 - 9 figures, 2 - 11 figures)
if((level===4 && complexityLevel===0) || (level===8 && complexityLevel===1))
{
updateComplexity();
}
if (levelFlag != level)
updateLife();
}

function updateComplexity()
{
complexityLevel++;
if (complexityLevel===1)
{
figEight = game.add.sprite(155, 130, 'figure');
figNine = game.add.sprite(485, 130, 'figure');
sprites.push(figEight, figNine);
numOfFigures = 9;
}
else if (complexityLevel===2)
{
figTen = game.add.sprite(155, 290, 'figure');
figEleven = game.add.sprite(485, 290, 'figure');
sprites.push(figTen, figEleven);
numOfFigures = 11;
}
for (var i = numOfFigures-2; i < numOfFigures; i++)
{
currSprite = sprites[i];
currSprite.scale.setTo(0.65,0.65);
game.physics.p2.enable(currSprite);
currSprite.anchor.setTo(.5, .5);
}
}

function updateLife()
{

Expand Down Expand Up @@ -461,8 +501,3 @@ function finishGame()
{
gameOver();
}





109 changes: 73 additions & 36 deletions js/passiveOn.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ var life;
var startScreen;
var startButton;

var complexityLevel = 1;

var inputcheck;
var inputcross;
var pause;
Expand Down Expand Up @@ -358,62 +360,91 @@ function updateQuestion()
break;
}

var sentRandom = game.rnd.integerInRange(1,100) % 2 ;
var sentRandom = game.rnd.integerInRange(1,100) % complexityLevel*2 ;
var negateRandom;
var tempText;
if(sentRandom === 0)
switch(sentRandom)
{
negateRandom = game.rnd.integerInRange(1,100) % 2 ;
if(negateRandom === 0)
{
tempText = "The " + foregroundName + " is enclosed within the " + backgroundName;
isCorrectText = 1;
}
else
{
tempText = "The " + foregroundName + " is NOT enclosed within the " + backgroundName;
isCorrectText = 0;
case 0:
negateRandom = game.rnd.integerInRange(1,100) % 2 ;
if(negateRandom === 0)
{
tempText = "The " + foregroundName + " is enclosed within the " + backgroundName;
isCorrectText = 1;
}
else
{
tempText = "The " + foregroundName + " is NOT enclosed within the " + backgroundName;
isCorrectText = 0;
}
break;
case 1:
negateRandom = game.rnd.integerInRange(1,100) % 2 ;
if(negateRandom === 0)
{
tempText = "The " + backgroundName + " is enclosed within the " + foregroundName;
isCorrectText = 0;

}
else
{
tempText = "The " + backgroundName + " is NOT enclosed within the " + foregroundName;
isCorrectText = 1;
}
break;
case 2:
negateRandom = game.rnd.integerInRange(1,100) % 2 ;
if(negateRandom === 0)
{
tempText = "The " + backgroundName + " surrounds the " + foregroundName;
isCorrectText = 1;
}
else
{
tempText = "The " + backgroundName + " does NOT surround the " + foregroundName;
isCorrectText = 0;
}
break;
case 3:
negateRandom = game.rnd.integerInRange(1,100) % 2 ;
if(negateRandom === 0)
{
tempText = "The " + foregroundName + " surrounds the " + backgroundName;
isCorrectText = 0;
}
else
{
tempText = "The " + foregroundName + " does NOT surround the " + backgroundName;
isCorrectText = 1;
}
break;

}
}
if ((sentRandom===2 || sentRandom===3) && negateRandom===0)
{
questionText.x = 170;
}
else
{
negateRandom = game.rnd.integerInRange(1,100) % 2 ;
if(negateRandom === 0)
{
tempText = "The " + backgroundName + " is enclosed within the " + foregroundName;
isCorrectText = 0;

}
else
{
tempText = "The " + backgroundName + " is NOT enclosed within the " + foregroundName;
isCorrectText = 1;

}
questionText.x = 150;
}
questionText.setText(tempText);

}
var isCorrectText = null;
function updateScore()
{

if (answer && isCorrectText)
// js-version of XOR
if (answer ? !isCorrectText : isCorrectText)
{
score += 25;
isCorrect = 1;
isCorrect = 0;
lifeline--;
}
else if(!answer && !isCorrectText)
else
{
score += 25;
isCorrect = 1;
}
else
{
isCorrect = 0;
lifeline--;
}

if (score < 100)
{
Expand All @@ -434,6 +465,12 @@ function updateLevel()
{
var levelFlag = level;
level = Math.floor(score/250) + 1;

if(level===6 && complexityLevel===1)
{
complexityLevel=2;
}

if(level < 10)
{
mylevel.setText('0'+level);
Expand Down