JS viewer

Syntax-highlighted view of JS of World: New World





// Customise AB run parameters (optional).
// The following 3 parameters can be customised. (They have default values.)

AB.clockTick       = int;    

	// Speed of run: Step every n milliseconds. Default 100.
	
AB.maxSteps        = int;    

	// Length of run: Maximum length of run in steps. Default 1000.

AB.screenshotStep  = int;   
  
	// For automatic generation of World images.
	// Take screenshot on this step. (All resources should have finished loading.) Default 50.

	

function World() { 

	// Optional declaration:
	// If endCondition is declared, runs will check for endCondition true and then terminate.
	// If not declared, runs will make no such check.

	this.endCondition = false;				  

	
	// Optional functions:
	// The following 5 function declarations are optional.
	// If not declared, either nothing happens, or, if a return is expected, return is taken as 0.

	this.newRun = function()
	{
		// Code for Three.js initial drawing of objects.
		// Should include one of:
 		// threeworld.init2d ( arguments ); 	
 		// threeworld.init3d ( arguments ); 	
	};


	this.getState = function()
	{
	  return ( state );  				// State format defined by this World.
	};


	this.takeAction = function ( action )		// Action format defined by this World.
	{
		// Code for Three.js re-drawing of objects.  
		
		if ( some condition )	   // Optional: Check for condition that will end the run early.
		{
			this.endCondition = true;	// This will end the run. 
		}
	};


	this.endRun = function()
	{
	};


	this.getScore = function()
 	{
	 return ( float );		
	};

}