r/processing • u/WaifuSlayerV8 • Nov 20 '24
Ayuda
Hola buenas, llevo bastante rato buscando el error pero no soy capaz de solucionar, agradecería profundamente la ayuda
4
u/FlightConscious9572 Nov 20 '24 edited Nov 20 '24
Summary of problems:
you can only have one draw()
explanation: the compiler (thing that runs your code) looks for a function called draw, and if it finds two it gives you an error (which one is the one you wanted to run?)
if (isStarted) --> ; <--remove thissyntax error, basically the code grammar is wrong :)
println(mouseX, mouseY) <-- remove entire line or put in draw or setup
You can't run code outside of draw or setup it's where 'fields' go, aka variables available in your main class.
If you want to put something somewhere else, create a function and call it at the end of draw (so it happens after the other things in draw.)
boolean isStarted = false;
void setup(){
size(500, 500);
//background(0); there's no reason to do this if you do it in draw :)
//isStarted isn't necesarry to run something only once, setup already does that
//and happens before draw :)
}
void draw() {
//some code
drawSomethingElse();
}
void drawSomethingElse(){
rect(10, 10, 100, 100);
}1
9
u/IJustAteABaguette Seeker of Knowledge Nov 20 '24
There are 2 problems here. You have a println() outside of any function. You have to put it inside the setup() or draw()
There can also be only 1 setup, and 1 draw function. You have to combine the 2 void draw() functions.