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.