Runs on the Ancient Brain system have the following global variable defined:

 AB;               // instance of class ABClass   

The AB object contains general Ancient Brain settings. Here are some core settings you can change (default values shown):


AB.clockTick       = 100;    

	// Speed of run: Step every n milliseconds.  
AB.maxSteps        = 1000;    

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

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

AB.drawRunControls = true;			

	// Add run controls (Run/Step/Pause) to the run window  

Here are AB functions for run header, loading screens and splash screens. The normal use is that a loading screen vanishes automatically when resources load, while splash screen needs user interaction to dismiss.


AB.loadingScreen();                  // draw standard loading screen   
AB.removeLoading();                  // remove loading screen 

AB.newSplash();                      // draw standard splash screen  
AB.newSplash ( html );               // draw standard splash screen with this html as the message 
AB.removeSplash();                   // remove splash screen 

AB.showRunHeader();     // show run header (in case does not show automatically)
AB.headerLHS();         // put run header on LHS   
AB.headerRHS();         // put run header on RHS 

Here are further AB functions which may be useful:


AB.isScreenshotRun();                // is this a run that generates a screenshot 

AB.onDesktop();                      // return if running on desktop
AB.onMobile();                       // return if running on mobile 

AB.randomFloatAtoB ( A, B );         // return random float between A and B
AB.randomIntAtoB ( A, B );           // return random int between A and B
AB.randomBoolean();                  // return random true or false 
AB.randomPick ( a, b );              // return a or b randomly 
AB.randomPick3 ( a, b, c );          // return a, b or c randomly 
AB.randomElementOfArray ( array );   // return random element of this array 

AB.distance2D ( x1, y1, x2, y2 );    // return distance between two points on 2D plane 

AB.audioIsPlaying ( audio );         // return if this audio is currently playing 
AB.standardAudioButtons ( audio );   // draw standard play/pause buttons for this audio 
AB.backgroundMusic ( musicfile );    // play background music, draw buttons, return audio object 

AB support for logged in runs

Here are AB data and functions useful for when you run logged in.

These functions are asynchronous and return at some point in the future. When they do, they call World functions that the World author needs to define.

Here is an example of a World that uses these functions.


AB.runloggedin;                 // Boolean. Are we running logged in.  
AB.myuserid;                    // The userid of the run, if running logged in.  

AB.saveData();  // Save data for this World for this user (the user running the World).
                // Only works if user is running logged in.
                // Data is public and can be browsed in user uploads. 
                // This calls World.saveData to get the data. 

AB.restoreData();   // Recover the data saved for this World for this user.
                    // When this returns, it calls World.restoreData to process the data. 	

AB.queryDataExists();  // Query if data exists on the server for this World for this user.
                       // When this returns, it calls World.queryDataExists.
AB.getAllData();    // Get all data saved for this World for all users.
                    // Returns array of items ( userid, username, object ). 
                    // When this returns, it calls World.getAllData to process the array. 	

The background is a program, showing the JavaScript graphics used on this site.

© Ancient Brain Ltd. 2018-19. All rights reserved.

Ancient Brain ™ is a trademark of Ancient Brain Ltd.

Platforms      Bug bounty      Contact

Stats      The name      Terms and conditions

Classes in Dublin      Call for partners