jspsych/plugins/jspsych-rdk.js
//Update the dots with their new location

Update the dots with their new location
Update the dots with their new location
function updateDots() {
			if (currentSetArray[currentApertureNumber] == nSets - 1) {
				currentSetArray[currentApertureNumber] = 0;
			} else {
				currentSetArray[currentApertureNumber] = currentSetArray[currentApertureNumber] + 1;
			}
    		var dotArray = dotArray2d[currentSetArray[currentApertureNumber]];
			for (var i = 0; i < nDots; i++) {
				var dot = dotArray[i]; 
			    var randomValue = Math.random();
				if (dot.updateType == "constant direction") {
					dot = constantDirectionUpdate(dot);
				} else if (dot.updateType == "opposite direction") {
					dot = oppositeDirectionUpdate(dot);
				} else if (dot.updateType == "random position") {
					dot = resetLocation(dot);
				} else if (dot.updateType == "random walk") {
					dot = randomWalkUpdate(dot);
				} else if (dot.updateType == "random direction") {
					dot = randomDirectionUpdate(dot);
				} else if (dot.updateType == "constant direction or opposite direction or random position") {
					if (randomValue < coherence) {
						dot = constantDirectionUpdate(dot);
					}  else if(randomValue >= coherence && randomValue < (coherence + oppositeCoherence)){
						dot = oppositeDirectionUpdate(dot);
					}  else {
						dot = resetLocation(dot);
					}
				} else if (dot.updateType == "constant direction or opposite direction or random walk") {
					if (randomValue < coherence) {
						dot = constantDirectionUpdate(dot);
					} else if(randomValue >= coherence && randomValue < (coherence + oppositeCoherence)){
						dot = oppositeDirectionUpdate(dot);
					} else {
						dot = randomWalkUpdate(dot);
					}
				} else if (dot.updateType == "constant direction or opposite direction or random direction") {
					if (randomValue < coherence) {
						dot = constantDirectionUpdate(dot);
					} else if(randomValue >= coherence && randomValue < (coherence + oppositeCoherence)){
						dot = oppositeDirectionUpdate(dot);
					} else {
						dot = randomDirectionUpdate(dot);
					}
				}
				dot.lifeCount++;
				if (lifeEnded(dot)) {
					dot = resetLocation(dot);
				}
				if (outOfBounds(dot)) {
					switch (reinsertType) {
						case 1:
							dot = resetLocation(dot);
							break;
						case 2:
							dot = reinsertOnOppositeEdge(dot);
							break;
					} 
				} 
			} 
		} 
function updateDots ( ) { if ( currentSetArray [ currentApertureNumber ] == nSets - 1 ) { currentSetArray [ currentApertureNumber ] = 0 ; } else { currentSetArray [ currentApertureNumber ] = currentSetArray [ currentApertureNumber ] + 1 ; } var dotArray = dotArray2d [ currentSetArray [ currentApertureNumber ] ] ; for ( var i = 0 ; i < nDots ; i ++ ) { var dot = dotArray [ i ] ; var randomValue = Math . random ( ) ; if ( dot . updateType == "constant direction" ) { dot = constantDirectionUpdate ( dot ) ; } else if ( dot . updateType == "opposite direction" ) { dot = oppositeDirectionUpdate ( dot ) ; } else if ( dot . updateType == "random position" ) { dot = resetLocation ( dot ) ; } else if ( dot . updateType == "random walk" ) { dot = randomWalkUpdate ( dot ) ; } else if ( dot . updateType == "random direction" ) { dot = randomDirectionUpdate ( dot ) ; } else if ( dot . updateType == "constant direction or opposite direction or random position" ) { if ( randomValue < coherence ) { dot = constantDirectionUpdate ( dot ) ; } else if ( randomValue >= coherence && randomValue < ( coherence + oppositeCoherence ) ) { dot = oppositeDirectionUpdate ( dot ) ; } else { dot = resetLocation ( dot ) ; } } else if ( dot . updateType == "constant direction or opposite direction or random walk" ) { if ( randomValue < coherence ) { dot = constantDirectionUpdate ( dot ) ; } else if ( randomValue >= coherence && randomValue < ( coherence + oppositeCoherence ) ) { dot = oppositeDirectionUpdate ( dot ) ; } else { dot = randomWalkUpdate ( dot ) ; } } else if ( dot . updateType == "constant direction or opposite direction or random direction" ) { if ( randomValue < coherence ) { dot = constantDirectionUpdate ( dot ) ; } else if ( randomValue >= coherence && randomValue < ( coherence + oppositeCoherence ) ) { dot = oppositeDirectionUpdate ( dot ) ; } else { dot = randomDirectionUpdate ( dot ) ; } } dot . lifeCount ++ ; if ( lifeEnded ( dot ) ) { dot = resetLocation ( dot ) ; } if ( outOfBounds ( dot ) ) { switch ( reinsertType ) { case 1 : dot = resetLocation ( dot ) ; break ; case 2 : dot = reinsertOnOppositeEdge ( dot ) ; break ; } } } }
Update the dots with their new location
Update the dots with their new location
//Cycle through to the next set of dots
 //Load in the current set of dot array for easy handling
 //Load in the current set of dot array for easy handling
 //dotArray = dotArray2d[currentSetArray[currentApertureNumber]]; //Global variable, so the draw function also uses this array
 //Loop through the dots one by one and update them accordingly
 //Load the current dot into the variable for easy handling
 //Generate a random value
 //Update based on the dot's update type
 //Randomly select if the dot goes in a constant direction or random position, weighted based on the coherence level
 //Randomly select if the dot goes in a constant direction or random walk, weighted based on the coherence level
 //Randomly select if the dot goes in a constant direction or random direction, weighted based on the coherence level
 //End of if dot.updateType == ...
 //Increment the life count
 //Check if out of bounds or if life ended
 //If it goes out of bounds, do what is necessary (reinsert randomly or reinsert on the opposite edge) based on the parameter chosen
 //End of switch statement
 //End of if
 //End of for loop
 //End of updateDots function
