January 15, 2021

example p5.js javascript creating-functions

This sketch builds off of the drawHouse example:

This sketch defines a drawTown() function that calls the drawBlock() function four times, and the drawBlock() function calls the drawHouse() function four times.


Remix Ideas

  • Add some variety: give every house a random color.
  • Make some of the houses skyscrapers, or schools, or gardens.
  • Try different patterns: maybe your block only has 3 houses, or maybe your town has 6 blocks.

Creating Functions Examples


Happy Coding is a community of folks just like you learning about coding.
Do you have a comment or question? Post it here!

Comments are powered by the Happy Coding forum. This page has a corresponding forum post, and replies to that post show up as comments here. Click the button above to go to the forum to post a comment!