This week I take a break from Asteroids to build Spiderman waking people up.
This project got progressively difficult for me. First I used the rect() function to build sky scrapers, then I start drawing out windows manually (square by square) so I can get the positions right.
Next, I wrote a function to populate windows in one Sky scraper.
I wrote for-loops for every sky scrapers windows. Tried writing a grand unified for-loop and if-statement to populate windows for all sky scrapers in one block of code, but it didn’t work.
Next, I “draw” spiderman - as defined by a function “spiderellipse()” and make a function called windows() and building() which get called in draw().
Now I want window lights to switch (window with fill yellow) on as Spiderman passes by, waking everyone up. I use if statements within for-loops, that doesn’t work. Next I try getting the spiderellipse() function to generate values to pass to the windows() function that doesn’t work either, I am doing something wrong. And then, I work on writing a separate function for lights-on which gets called. I do that incorrectly too. So I book an appointment and seek help from resident Laura Chen. She’s on the money. She helps me with the if statement (below). The revelation is with using area of the window in the if statement.
Problem: the windows lights switch off when the mouse moves on. Which means people switch the light on when spiderman is infront of their window and as soon as he’s passed by they instantly switch it off. Not realistic.
Solution, which Laura introduced, was to create objects in windows in arrays so they stay on. I have a broad understanding of this code, but will be spending more time to understand the theory behind them. Here’s the final working version:
I wanted to do more. Build a better slinging spidey, but I couldn’t get to that this week