That’s the code i’m currently working on. I need to reduce the amount of global variables and create more passing arguments but i’m not really sure how to go about it.
Have a look at this tutorial: https://processing.org/tutorials/objects/
Then attempt to make some changes. If you run into a road block, ask here and provide your attempt.
You can format your code by using the </> button when you paste some in the forum. Try and edit your post !
As for your problem why do you need to get rid of those global variables ? In your case, since you are using them in draw, you can’t really do otherwise.
You can use classes as @kfrajer mentioned to order your code a bit more but you’ll still have some global variables.
I had already attempted to move variables around within functions first and nothing seemed to work so I moved them all to global.
I don’t technically HAVE to, but it’s for a school project and in order for me to get the maximum grade possible I need to eliminate global variables and use passing arguments in my functions.
drawWin() and printWin() are 2 new functions I added. In printWin if I try to call the variables declared in drawWin, I get an error stating “The variable ‘drawWin’ does not exist”. Of course it doesn’t exist because it’s not a variable.
Also yes I know I don’t have a return for printWin just yet. I was starting to set it up til i ran into the error stated.
I know about scoping but that’s why i’m confused Even with what you tell me i’m not sure how I can do that with my code. It’s getting difficult to think about this code due today. with all the variables declared in global, i’m not sure how to make those available only in the functions that they’re used in.