Day Three- Coding in The Dark

Today in class we had our first “Code in The Dark” challenge, or CITD.

I found this to be a little stressful, but ultimately very satisfying. I left class upset because I didn’t completely finish the second challenge, but I can happily say at almost 12:30 AM I finally got it.

Our first challenge was to replicate an animation of constantly generating varied circles that Professor D showed us.

My initial thought was to create a loop that continued to offset the fill, x coordinate, y coordinate, and diameter. I’ve seen these types of functions referenced but could not recall how to do it… panic set in.

I decided to go ahead and just start creating values in the hopes that the coding for the infinite repetition would come to me.

Thankfully I overheard somebody mention Random.

This was so obvious that it actually hurt.

by setting every value to random I made it so that the draw would loop and create new values for every circle.
The real trick to this was moving the background fill to the setup and out of the draw function. Before doing this my image would look as though the circles were popping instantly. What was happening was that with every circle loop my white background was being recalled and therefore erasing each circle.

For our second challenge we had to create a circle that seemed to drag along on the canvas in conjunction with our mouse, just like if you were using the paintbrush in MS Paint (RIP).

Just like this:


This took me down a mouse command worm hole,

After reading through a few different references I found the mouseX and mouseY values. These variables change to reflect the cursor’s location on the X and Y axis respectively, so as you move the mouse your shape’s coordinates are moving too- very cool.

The second part of this challenge was to create a command that cleared the board.

Now this is the part that I didn’t finish until about 20 minutes ago. In class I got up to function keyPressed, which is a function that creates a reaction to pressing any key, but then became overwhelmed by incorrect syntax with clear().

I didn’t screenshot my messy code because of course I didn’t realize that it would be so funny in contrast to the final answer, but I wish I had.

Check out the correct code:

Man that’s embarrassing.

I think truly my biggest take away from today is that I need to work on managing my performance anxiety. I let the frustration derail me today but in the future I’ll remember this moment and use that to pull focus.

Check out my first challenge here, and my second one here.


PS:

I learned how to stop my beach ball from yesterday’s assignment (a small victory) check that out here.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with WordPress.com
Get started
<span>%d</span> bloggers like this: