xxxxxxxxxx
let ball_obj;
function setup() {
createCanvas(windowWidth, windowHeight);
background(100);
ball_obj = new Ball();
_pos = new createVector(windowWidth/2, windowHeight/2);
_vel = new createVector(2.5, -2);
}
function draw() {
_pos.add(_vel);
ellipse(_pos.x, _pos.y, 20, 20);
ball_obj.draw();
ball_obj.move();
}
class Ball
{
constructor()
{
this.ball_pos = new createVector(windowWidth/2, windowHeight/2);
this.ball_vel = new createVector(2, -2);
print("ball obj constructed");
} // END CONSTRUCTOR
move()
{
this.ball_pos.add(this.ball_vel);
}
draw()
{
noStroke();
fill(255,10);
//ellipse(windowWidth/2, windowHeight/2, 100, 100);
ellipse(this.ball_pos.x, this.ball_pos.y, 100, 100);
}
}// End Ball class