Castle

Castle

Draw a tower of a castle.

A tower of a castle has a battlement. The battlement has a number of merlons, the solid upright low wall sections. The space between the merlons is called a crenel. A series of merlons and crenels is called a crenellation. Merlons were used in medieval fortifications to protect the defenders from enemy fire and to allow them to launch projectiles from behind the cover.

Make


Write a program to draw a single tower with a variable number of merlons.

Use this boilerplate code as a starting point:

Success Criteria

Remember to add a comment before a subprogram, condition or iteration to explain its purpose.

Complete the subprogram called `draw_tower` that:

  1. Draws a tower using the parameter `merlons` to determine the number of merlons that should be drawn.
  2. The number of crenels is always one less than the number of merlons.
  3. The width of a crenel is 20 pixels.

Complete the subprogram called `draw_merlon` that:

  1. Draws one merlon and can be used repeatedly by the draw_tower subprogram.
  2. The height and width of a merlon is 20 pixels.

Typical inputs and outputs from the program would be:

draw_tower(4)

4 merlon tower

Knowledge Organiser

Use these resources as a reference to help you meet the success criteria.

Programming guide:

Evaluate


Check that your program outputs the expected result and has met the success criteria.

draw_tower(3)

draw_tower(5)

Check that you have:

  • Used comments within the code to describe the purpose of subprograms, conditions and iterations.
  • Used meaningful identifier names. That means the names of subprograms and variables indicate what they are for.