ahandrewh teaches IAT-165game design and development

E6: Arrayed (due February 18)

Instructions

This exercise helps you practice refactoring your code to simplify functionality.

Please complete the following:

  1. Continuing from the file built in the code tutorial on arrays you will be creating a revised updateStars() function to allow it to directly change how the stars are drawn using arguments provided with the function.
  2. Read through the documentation on functions in p5.js, pay attention to how you can provide a function with input (aka. arguments) to pass values along to inside the function.
  3. Comment out the original updateStars() function and create a new updateStarsN(star_number) function that will take the number of the star from the array to update.
  4. Simplify the original updateStars() function in the new updateStarsN() function using the star_number argument/variable to select which star is being updated. For example if calling on the variable in the updateStarsN() function we would likely use something like stars[star_number[0] = ...]
  5. Change the use of updateStars() to the new updateStarsN() function within the draw() function to update the movement of each of the stars.
  6. Run the sketch using the play symbol to ensure the output is as you expect.
  7. Save the sketch to your computer.

Submission

Once done please submit a ZIP of your exercise to Canvas before class on February 18.

You are allowed to use this exercise as part of your projects if useful.

Grading rubric

This code exercise is worth 1% (1 point) of your final grade for completing the exercise steps.

Exercise rules

Please note the rules for exercises in this course: