Loops
Last weeks attempt
I struggled again this week. I tried to make my Tic Tac Toe from last week into a loop. I’m very conscious of when I write code that I’m repeating the same task over and over again. Often times this repeating of code can be replaced with a “for loop”. The construction of the “O” and “X” and be broke down into rows and columns. I made the loop for the “O” but I didn’t know how to turn off each “O” since the construction draw all the “O”’s for the board. I thought about having a rectangle that covers the “O” and the player clicking on the grid to reveal what’s underneath. This didn’t work and again I had to switch gears. I was able to do more research on the formation of rows and columns which led to nested “for loops” and 2d arrays. I couldn’t find any real examples in java that didn’t use a print line function. A print line function only printed, I want to make an object inside the nested “for loop”. With this knowledge I found an example of 2d array and array object from Processing’s web site. They basically use constructs to pass the values to the object. So I went back to my building I was trying to make last week but failed at. Again it had the same idea behind it. The building is a given height and width and that means that it has a certain number of windows. Essentially rows and columns of windows. I wanted to be able to scale the building and the windows scale with the size of the building. The building scaled with the mouse x and y position.
I was able to get the windows to scale with the building but ran out of time to add any detail. I push myself really hard in this class. Maybe to much but I get ideas in my head that I want to make reality. Much like that of making art. It seems easy for me with art but with coding I need to know what I can and can’t do with the code language. Overall, it was a good learning experience and I keep piling on the knowledge from the week before. Even if the end result doesn’t look very good.