I’ve got a different problem while trying to add a sprite and it says "dvd cannot be resolved to a variable
float x = random(200,300); // x location of square
float y = random(200,300); // y location of square
float xspeed = 1; // speed of square
float yspeed = 1; // speed of square
void setup() {
size(800, 600);
frameRate(240);
//surface.setResizable(true);
PImage dvd; /// dvd
dvd = loadImage("dvd.png"); /// dvd
}
void draw() {
background(255);
fill(0,0,0);
rect(0,0,10000,-1);
// Display the square
fill(dvd); /// highighted line
stroke(0);
rect(x, y, -200, -150);
// Add speed to location.
y = y + yspeed;
x = x + xspeed;
// bounce
if(x > width){
xspeed = xspeed * -1;
}
if(y > height){
yspeed = yspeed * -1;
}
if(x < 200){
xspeed = xspeed * -1;
}
if(y < 150){
yspeed = yspeed * -1;
}
if (keyPressed) {
if (key == 'b' || key == 'B') {
xspeed = xspeed - 0.1f;
yspeed = yspeed - 0.1f;
}
}