Answer:
var NUM_CIRCLES = 15;
var radius=getWidth()/(NUM_CIRCLES*2);
var x=radius;
function start(){
for (var i=0; i<NUM_CIRCLES; i++){
if (i%2==0){
drawRedWorm();
}else{
drawGreenWorm();
}
var xPosition=x;
x=xPosition+(radius*2)
}
}
function drawRedWorm(){
var circle=new Circle(getWidth()/(NUM_CIRCLES*2));
circle.setPosition(x , getHeight()/2 );
circle.setColor(Color.red);
add (circle);
}
function drawGreenWorm(){
var circle=new Circle(getWidth()/(NUM_CIRCLES*2));
circle.setPosition(x , getHeight()/2 );
circle.setColor(Color.green);
add (circle);
}
Step-by-step explanation:
codeHs