xxxxxxxxxx
78
let myBouncingBall;
let x= 0
let y=0
let spacing = 20;
function preload() {
font = loadFont("3D.TTF");
}
function setup() {
createCanvas(400, 400);
myBouncingBall = new BouncingBall();
text ("FREE ME PLEASE!!!", 30,100)
}
function draw() {
background(54);
textFont(font);
textSize(50);
noStroke();
text("FREE ME PLEASE!!!", 30, 100)
stroke(56);
if (random(7) < 0.9) {
noStroke();
(x, y, random(8, 12));
fill(random(255), random(0), random(170));
} else {
stroke('#6cd8eb');
line(x + spacing, y + spacing, x, y);
}
x = x + spacing;
if (x > width) {
x = 0;
y = y + spacing;
}
for (let lineX = 0; lineX <= 600; lineX += 9) {
line(lineX, 0, lineX, height);
}
ellipse (width/2, height/2, 154, 154)
myBouncingBall.move();
myBouncingBall.collision();
myBouncingBall.draw();
}
class BouncingBall {
constructor() {
this.xPos = width / 2;
this.yPos = random(100, 300);
this.xSpeed = 4;
this.ySpeed = 7;
}
move() {
this.xPos += this.xSpeed;
this.yPos += this.ySpeed;
}
collision() {
if (this.xPos <= 150 || this.xPos >= (width - 150)) {
this.xSpeed = -this.xSpeed;
}
if (this.yPos <= 150 || this.yPos >= (height - 150)) {
this.ySpeed = -this.ySpeed;
}
}
draw() {
circle(this.xPos, this.yPos, 30);
}
}