Lab 3.5: Row of Houses

Unit 1, Lab 3.5

In this project, you’ll use abstractions inside of abstractions to build a row of houses.
a drawing of a row of houses

When you finish, make sure to

  1. “U1L35-Row-of-Houses”Create a new project called U1L35-Row-of-Houses

  2. Create a draw square block that takes a size as input. Be sure to test it with different inputs.

    You learned how to create a block with an input on Lab 3 Page 3: Blocks with Inputs.

    draw square, size: () a drawing of a square

  3. Using draw square as an example of where to start, create and test a draw triangle block that takes a size as input and draws an equilateral triangle.

    You learned about turning angles on Unit 1, Lab 3, Page 2, Angles and Turning.

    draw triangle, size: () a drawing of a triangle

  4. Now, use draw square and draw triangle together to create a draw house blocks that takes a size as input and draws a house shape: a square with a triangular shaped roof sitting on top.

    You might have to do some debugging to get the two shapes to connect properly.

    draw house, size: () a drawing of a house, that is a square with a triangle above it

Using a block inside another block is a form of abstraction.

  1. Use your draw house block together with repeat to create a draw row of houses block that draws a row of number attached houses (each of the same size) with each new one to the right of the previous. draw row of houses, size: () number: () a drawing of a row of houses

  2. Use your draw row of houses block together with repeat to create a draw group of houses block that draws a rows by cols amount of houses (each of the same size) in one place with each row below the previous row. draw group of houses, size: () rows: () cols: () a drawing of a 4 by 6 group of houses

We learned about the pick random block on Unit 1, Lab 2, Page 5: Adding Variety to Gossip.

It is a reporter block that reports a random number within the range of numbers that you specify.

  1. Use your draw group of houses block together with repeat and pick random to create a draw town of houses block that draws a groups number of groups of houses all of a random amount of houses (each of the same size) in random places (try to make sure they don’t overlap!) draw town of houses, size: () groups: ()
  1. Houses aren’t really stuck next to each other like in the examples that we gave! Edit the draw row of houses and draw group of houses block so that there are gaps between the houses.

  2. Customize the look of your houses by editing the code of your draw house block. Things that you can add to the houses include:

    • Windows, doors, garages, greenery, etc.
    • Consider breaking it down first. e.g., create a block draw window that only draws a window then add the block into the draw house block.
  3. Create a better way of generating groups of houses. Edit draw group of houses so that it uses pick random to create a group of houses that can have houses missing (i.e. make it look more “natural”) a drawing of a natural group of houses

  1. Use your draw square block to create a draw flower with square petals block that will draw a flower with square petals with any specified number of petals of the specified size.

    draw flower with (6) square petals of size (50) a drawing of a flower with 6 square petals
  2. Talk with Another PairAfter you’ve worked on this for a bit, take a moment to look at what others have done. If you see something you like, think how you could use that idea in your program.

  3. Now, draw a field of flowers and give each flower a different size, number of petals, and position.

    You will need to use pen up.

    a drawing of a field of flowers each with a random number of square petals

Make sure to turn in your project!