Skip to content

Homework Dan ‐ Thursday

Daniel Shiffman edited this page Oct 23, 2023 · 159 revisions
Shiffman Section Info  
Meeting Time Thurs 12:30pm - 3:00pm EST
Location 409
Contact daniel.shiffman@nyu.edu
Office Hours (check email for calendar link)
Additional Help Resident office hours (schedule)
The Coding Lab (schedule or drop-in help)
How to ask code-related questions: examples

Week 7: First Half Wrap-Up

Resources from Class

Assignment

  • Review your understanding of objects and arrays with Worksheet 6. Take a look at Worksheet 7 as well which we will discuss in class.

Material to Review for next class

Week 6: Objects and Arrays

Code from class

Other resources from class

Assignment

  • Worksheet 6 - Take your time with this one, maybe save it for after next week (no assignment between weeks 7-8)
  • Prepare a short presentation of one of your sketches.
    • You can focus on what's happening in your sketch computationally. Clarify the vocabulary. Plan in advance what you're going to say and prepare any diagrams that will help you explain what's going on. See Mimi's demo video (It is much longer than the time you will have!)
    • Take your time to demo the sketch.
    • Discuss something you learned in making your sketch. Feel free to talk about what programming concept(s) you are using (e.g. objects and arrays, nested for loops, toggle logic, portable functions)
  • What sketch should you prepare?
    • Take this opportunity to clean-up your code. You are welcome to pick a previous assignment. You don’t even need to add any functionality!
      • Add descriptive comments.
      • Carefully name your variables and functions.
      • Remove unnecessary repetition.
    • Another idea is to mash up a couple of your past assignments into a new sketch.
    • You are not required to work with objects and arrays, but you could consider re-organizing a previous sketch into objects or creating a new one based on the "particle system" concepts explored in class. One idea is to augment this Confetti Party!
      • How might you re-organize your sketch and break down the elements into classes. Can they be the "smallest functional units" possible?
      • Are the objects interactive? Do they "communicate" with each other?

Reading and Videos

Questions

  • Add questions here!

Homework Links

Week 5: Functions

Code from class

Other resources from class

Assignment

  • Week 5 Worksheet
  • Functions are the basic unit of labor in your code. Take a sketch you’ve already done and re-organize the code into functional units of labor that you define. You can also conceive of an entirely new world of labor. What kinds of labor does it take to make your sketch run?
    • Aim to keep setup() and draw() as clean as possible, and do everything (calculations, drawing, etc.) in functions that you define.
    • Take care to name your functions precisely and accurately. Whenever possible, use verbs to name your functions. A good test of whether your functions are well-named is: Can someone else comment in/out individual function calls and predict what behaviors will start / stop working in your sketch?
    • Challenge: Write a re-usable function, a function you can call in multiple ways to do the same thing slightly differently each time. Here is an example with three functions, two re-usable.
    • Challenge: Incorporate recursion into your function. You can read more about recursion in the Nature of Code, though note this chapter also uses concepts we haven't covered yet. And here is a recursion code example, and recursion video tutorial.

Reading and Videos

Questions

  • Add questions here!

Homework Links

Week 4: Loops

Code from class

Other resources from class

Assignment

  • Worksheet 4
  • Our ability to see patterns is what makes us human. However we also see patterns where none exist because our brains are biased towards detecting certain kinds of patterns over others (e.g. faces). Create a pattern by making something with a lot of repetition. Is the resulting pattern easy to see or hard to see? What would it mean to create the illusion of pattern? Can you predict what the pattern will be when you run your code or does it surprise you? You could take something you've already done where there was a lot of repetition in the code (e.g. your self-portrait) and see if you can re-write it using a loop so that instead of 28 lines of code that call rect(), you have 1 line of code calls rect() inside of a loop that goes around 28 times. How do you need to rework the way you position that rect() in order to make it work in a loop? Try creating an algorithmic design with simple parameters. (Feel free to continue exploring 10PRINT, but now using a for or while loop!

Reading and Videos

Questions

  • Add questions here!
  • https://editor.p5js.org/p0ndraverr/sketches/NX7i7edAfC question: why if I put the code line 10-15 before line 17 if statement, the color fill will not be accurate following the mouse? while if I put the rect() after line 17-26 if() statement, it will be accurate again.

Homework Links

Week 3: Conditionals

Code from class

Other resources from class

Assignment

  • Worksheet 3 for self-study.
  • Two roads diverged in a yellow wood, And sorry I could not travel both... Life is full of difficult choices, use conditional statements to control the flow of your programs. In general this week, you should work with rule-based animation, motion, and interaction. You can use the ideas below or invent your own scenario.
    • Try making a rollover, button, or slider from scratch. Compare your code to these interface element examples. Later we'll look at how this compare to built-in "DOM" elements in the browser.
    • Create an algorithmic design with simple parameters. (One example is 10PRINT, see: 10PRINT code example and this accompanying video.
    • Tie the above two together and have an interface element control the visual design or behavior of other elements in your sketch.

Reading and Videos

Questions

  • Add questions here!

Homework Links

Week 2: Variables

Code from class

Other resources from class

Assignment

  • Week 2 worksheet: will go over solutions next week in class
  • Consider the following cliches / pearls of wisdom: No man is an island. There is no such thing as a new idea. Everything is related to everything else. It’s all relative. The world is defined through relationships and those relationships shape our perspectives. Use variables to build in some relationships between two or more elements in your sketch and think about how the perception of what’s happening is different depending on which element's perspective you take on. Think about:
    • What’s related to what?
    • How are they related?
  • You should definitely take a mathematical approach to answering these questions but you can also take a figurative, metaphorical approach.
  • The elements common to all of your sketches are: position, dimensions, stroke thickness, color values. Can you relate one or more of these elements to:
    • itself over time (so it changes over time)
    • a different element in your sketch
    • frameCount (which frame of animation is now)
    • mouseX or mouseY or the combined (mouseX, mouseY) mouse position
    • or something else!
  • You can revisit your self-portrait to build relationships (link the eyeballs together!) or create something new.
  • Another prompt this week is your own clock design. Here's a video building a clock in p5.js.

Reading and Videos

Questions

Homework Links

Week 1: Introduction

Add Your Homework