Interaktive BallWeltalle

Ein bisschen ActioncodingZ

Der ActionCode dazu ist nicht besonders kompliziert.

// SOURCECODE FROM STORY Stars*
// ————————-
// || STARS * |||
// ————————-

function getTitle() { return ‚STARS *‘; }
function getStory() { return ‚…‘; }

var sizeStone = 20;
var radicalVersion = true;

class Obj {
constructor(x,y,typeo) {
this.active = true;
this.x = x;
this.y = y;
this.vx = random(1,4);
this.vy = 0;
this.typeo = typeo;
this.size = 10;
}
}

var arrObjects = [];

function addObj( x, y, typeo ) {
var objx = new Obj(x,y,typeo);
arrObjects.push(objx);
return objx;
}

for (var z=1;z<90;z++) {
var ob = addObj( 0,0, „stone“ );
ob.x = random(0,width/2);
ob.y = random(10,height-10);
}

var score = 0;
var timerz = 0;

var selectedObj = null;

function drawAfter() {

fill(0,0,0,128);
text(score,20,20);

for (var t=0;t<arrObjects.length;t++) {
var ob = arrObjects[t];
if (ob.active) {

fill(0,0,0,128);

if (selectedObj==ob) fill(0,0,255,128);

var sizT = ob.size;

sizT = sin(ob.x*4)*30.0;

circle(ob.x,ob.y, sizT );




//if (ob.typeo==“ball“) {
ob.x += ob.vx;
ob.y += ob.vy;
//}

if (ob.x>width) {
ob.x = -100;
}

// dist to obj
var di = dist(ob.x,ob.y,mouseX,mouseY);
if (di<20) {
// cprint(“ AAA „);
// ob.active = false;
selectedObj = ob;
ob.size += 2;
}
}
}
}

// editorcode

function update() {
// radicalVersion = false;
// cclear();
// ccVM.executorSpeed = 20;
// ccVM.executorSpeed = 1;
selectedObj.x += 3;
// timerz ++;
}




Interaktiver:

// SOURCECODE FROM  STORY Stars*
// -------------------------
// || STARS *            |||
// -------------------------

function getTitle() { return 'STARS *'; }
function getStory() { return '...'; }

var sizeStone = 20;
var radicalVersion = true;

class Obj {
	constructor(x,y,typeo) {
      this.active = true;
      this.x = x;
      this.y = y;
      this.vx = random(1,4);
      this.vy = 0;
      this.typeo = typeo;
      this.size = 10;
    }
}

var arrObjects = [];

function addObj( x, y, typeo ) {
  var objx = new Obj(x,y,typeo);
  arrObjects.push(objx);  
  return objx;
}

for (var z=1;z<90;z++) {
  var ob = addObj( 0,0, "stone" );
  ob.x = random(0,width/2);
  ob.y = random(10,height-10);
}

var score = 0;
var timerz = 0;

var selectedObj = null;

function drawAfter() {
    
  fill(0,0,0,128);
  text(score,20,20);

  for (var t=0;t<arrObjects.length;t++) {
  	var ob = arrObjects[t];
    if (ob.active) {

	   fill(0,0,0,128);
       
       if (selectedObj==ob) fill(0,0,255,128);
       
       var sizT = ob.size;
       
        sizT = sin(ob.x*4)*ob.size;
       
      circle(ob.x,ob.y, sizT ); 
      
       
       
    
       //if (ob.typeo=="ball") {
         ob.x += ob.vx;
         ob.y += ob.vy;
       //}
       
       if (ob.x>width) {
       	ob.x = -100;
       }
    
       // dist to obj
       	 var di = dist(ob.x,ob.y,mouseX,mouseY);
       	 if (di<20) {
           // cprint(" AAA ");
           // ob.active = false;
           selectedObj = ob;
           ob.size += 2;
         }
    } 
  }
}

// editorcode  

function update() {
  // radicalVersion = false; 
  // cclear();
  // ccVM.executorSpeed = 20;
  // ccVM.executorSpeed = 1;
  selectedObj.x += 3;
  // timerz ++;
}

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert