Hello! I’m having trouble displaying an image from my Processing sketch on VSCode with the follofing code:
PImage heart1;
float x,y;
float rot;
void setup() {
size(720, 720);
heart1 = loadImage("heart (1).PNG");
x = 0.0f;
y = width/2.0f;
rot = 0.0f;
}
void draw() {
background(255);
translate(x,y);
rotate(rot);
image(heart1,0,0);
x += 1.0;
rot += 0.01;
if (x > width) {
x = 0;
}
}
image files are placed inside the folder and the code works if I run it on processing, but on VS code there’s this error message:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
at processing.app.Sketch.getMainName(Sketch.java:1697)
at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:145)
at processing.mode.java.JavaBuild.build(JavaBuild.java:111)
at processing.mode.java.Commander.<init>(Commander.java:233)
at processing.mode.java.Commander.main(Commander.java:417)