Code viewer for World: P5 Mouse tracker (clone by...

// Cloned by Przemyslaw Majda on 27 Sep 2022 from World "P5 Mouse tracker (clone by Przemyslaw Majda)" by Przemyslaw Majda 
// Please leave this clone trail here.
 


// Cloned by Przemyslaw Majda on 27 Sep 2022 from World "P5 Mouse tracker" by Starter user 
// Please leave this clone trail here.
 


// ==== Starter World =================================================================================================
// This code is designed for use on the Ancient Brain site.
// This code may be freely copied and edited by anyone on the Ancient Brain site.
// To include a working run of this program on another site, see the "Embed code" links provided on Ancient Brain.
// ====================================================================================================================




// Starter World for P5 AB API  




// ===================================================================================================================
// === Start of tweaker's box ======================================================================================== 
// ===================================================================================================================

// The easiest things to modify are in this box.
// You should be able to change things in this box without being a JavaScript programmer.
// Go ahead and change some of these. What's the worst that could happen?

AB.clockTick       = 1;    

AB.maxSteps        = 1000000;    

AB.screenshotStep  = 200;   
  
AB.drawRunControls = false;
	
const SKYCOLOR = "LightBlue";       // any format color that is accepted by P5 background()
                                    // https://p5js.org/reference/#/p5/background
	
const MUSIC_BACK  = '/uploads/starter/Defense.Line.mp3' ;

var wd = 30;
var ln = 30;

  
// ===================================================================================================================
// === End of tweaker's box ==========================================================================================
// ===================================================================================================================


// You will need to be some sort of JavaScript programmer to change things below the tweaker's box.



var img;

function preload() 
{
   img = loadImage ( '/uploads/przemyslawmajda/waltuh.jpeg' );
}

function randInt(p1) {
    return ((25 - (Math.random() * 50)) + p1)
}

    AB.world.newRun = function()                 
    {
		// console.log ( "newRun" );
		ABWorld.init (  SKYCOLOR  ); 
    };


    AB.world.nextStep = function()                
    {
		// can put P5 instructions to be executed every step here, or in draw()  
 
        // fill color white
        noFill();
		
		
		// draw ellipses on desktop 
		// draw ellipse on mouse hover, wherever the mouse is, each step
		if ( AB.onDesktop() ) {
		    triangle(randInt(mouseX), randInt(mouseY), randInt(mouseX), randInt(mouseY), randInt(mouseX), randInt(mouseY));
		    wd += 0.1;
		    ln += 0.1;
		    if (wd > 100) {
		        wd =10;
		        ln = 10;
		    }
		}
    };

	

// draw ellipses on mobile   
// on touch there is no hover
// so respond directly to touch events rather than run on its own 
// https://github.com/processing/p5.js/wiki/p5.js-overview#mouse-and-touch-interaction

function touchStarted() 
{
    triangle(mouseX, mouseY, ); 
    // prevent default
    return false;
}



//---- setup -------------------------------------------------------
// Do NOT create a setup function 
// But you can create these functions.

function beforesetup()        // Optional
{

}

function aftersetup()         // Optional
{
    // Anything you want to run at the start AFTER the canvas is created 	
}



//---- draw -------------------------------------------------------
// draw() is not needed. 
// Can use nextStep() or takeAction() instead.

function draw()               // Optional
{
	// can put P5 instructions to be executed every step here, or in nextStep()  
}





// --- music ----------------------------------------

 AB.backgroundMusic ( MUSIC_BACK );