// Cloned by Parth Bhatnagar on 23 Oct 2021 from World "Tutorial 5.1 (1)" by "Coding Train" project
// Please leave this clone trail here.
/*
https://vimeo.com/channels/learningp5js/139587733
*/
var ball = {
x: 300,
y: 200,
xspeed: 4,
yspeed: -3
}
function setup() {
createCanvas(600, 400);
}
function draw() {
background(0);
stroke(255);
strokeWeight(4);
fill(50,0,0);
ellipse(ball.x, ball.y, 24, 24);
if (ball.x > width || ball.x < 0) {
ball.xspeed = ball.xspeed * -1;
}
if (ball.y > height || ball.y < 0) {
ball.yspeed = ball.yspeed * -1;
}
ball.x = ball.x + ball.xspeed;
ball.y = ball.y + ball.yspeed;
}