Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

SpriteLab Validation Templates

Dan edited this page Nov 3, 2022 · 7 revisions

General Validation Template

To be used in individual levels

//Make sure [CSC Module Helper Library] is included as a library in this level
if (World.frameCount == 1) {
  //Everything in this if-statement will just run once, during the first frame of your level
  //README() //uncomment this to see the README for the helper library in the console of this level
  //turnOnDebugging() //uncomment this to use a DEBUG global variable to control console.log statements in your code
  
  setFailTime(150); // Frames to wait before failing student
  setDelayTime(90); // Frames to wait after success before stopping program
  setupPrevious(); //Defines the validationProps.previous{} object. To use it, call updatePrevious() at the end of this box
  
  //use addCriteria to setup the validation logic.
  //You can use criterion commands as helper functions: 
  //https://github.com/code-dot-org/code-dot-org/blob/staging/apps/src/p5lab/spritelab/commands/criterionCommands.js
  addCriteria(function() {
    //You can write code in here like if-statements and such, but if possible, try to abstract to a function.
    //This isn't always possible, but should be the goal
    return someFunction();
    /* //alternatively:
      if(someCondition) {
        return true;
      }
      return false;
    */

  }, "noSprites");  // include i18n feedback string
}
//Everything after this will run during each 'tick' of the draw loop in your level
//Be careful about putting console.log statements here

//Always have this first to get most up-to-date helper variables
getHelperVars();

//This is what calls updateValidation in 
//https://github.com/code-dot-org/code-dot-org/blob/staging/apps/src/p5lab/spritelab/commands/validationCommands.js
//To check the validation criteria
check();

//Always have this at end to store previous state in validationProps.previous
updatePrevious();

Clone this wiki locally

Morty Proxy This is a proxified and sanitized view of the page, visit original site.