Creating a Bouncing DVD Logo using p5.js & Javascript

Posted by

Coding a Bouncing DVD Logo with p5.js & Javascript

body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}

let x, y;
let xspeed, yspeed;
let dvd;

function preload() {
dvd = loadImage(‘dvd_logo.png’);
}

function setup() {
createCanvas(windowWidth, windowHeight);
x = random(width);
y = random(height);
xspeed = 5;
yspeed = 5;
}

function draw() {
background(0);
image(dvd, x, y, 100, 100);
x += xspeed;
y += yspeed;

if (x + dvd.width >= width || x = height || y <= 0) {
yspeed *= -1;
}
}

0 0 votes
Article Rating
3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
@oynozan_
11 months ago
@youtuberbooster6422
11 months ago

Plz sir, what's this app? I don't even know where you're typing these stuffs

@lasthacker4789
11 months ago

Good Work!