I learned processing.js through Kahn academy, where you declare any type of variable simply by using var
. However, I see that instead of var
, terms like int
and float
are used. But how do you declare an object type? And, how do you declare an array of objects? Below is the relevant code that works fine in the the realm of Kahn Academy. Can you tell me how I would rewrite the lines that use var
? Many thanks.
var Mover = function (xPos, yPos, cloudColor){
this.xPos = xPos;
this.yPos = yPos;
this.cloudColor = cloudColor;
};
var movers = [];
//I know the var below gets replaced with “int”:
for (var i = 0; i <=1000; i++){
movers[i] = new Mover(random(-22,width), random(-22,height), random(188,255));
}
As I understand your question, you want to translate your code from processing.js based on JavaScript to processing based on Java. You can do it like this: