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 3 function declarations are optional.
	// If not declared, nothing happens and the run continues.
	
	this.newRun = function()
	{
 		// Code for initial graphics drawing of objects.  
		// Canvas setup:
		
		threeworld.init ( arguments ); 	
				
		// To draw on canvas:
			
		var ctx = threeworld.getContext ( type );		// type = "2d" or "webgl"
	};


	this.nextStep = function()		 
	{
		// Code for graphics re-drawing of objects.  
		// To draw on canvas, see threeworld.getContext as above.
		
		if ( some condition )	   // Optional: Check for condition that will end the run early.
		{
			this.endCondition = true;	// This will end the run. 
		}
	};


	this.endRun = function()
	{
	};

}