Cabin in the Woods

by megan22
See Code Download Embed
This snap program was created to draw a scene of a cabin in the woods at night. The Reset function ensures that the scene is reset so that each time the green flag is clicked, the scene starts correctly. It clears the canvas, positions the sprite at (0, 0) and points it in the correct direction.

The Make Background function draws the "ground" and the "sky" by sending the sprite back and forth across the screen and changing the pen color part way through. 

The Make Forest function draws the trees at different positions in the picture. Each size tree has a function of its own, but the pine trees are drawn by stacking 3 equilateral triangles on top of each other. The top triangle's sides are 1/4 the height of the tree, the middle triangle's are 1/3 the height of the tree and the bottom triangle has sides that are 1/2 the height of the tree. By drawing larger trees, it gives the illusion that the trees are actually closer to the viewer. Once 4 trees of varying sizes and colors have been drawn, the program moves on to the draw cabin function. 

Draw Cabin begins by making a square outline of the cabin. Then the sprite "draws boards" by going back and forth across the outline, changing pen color each pass. After the boards have been drawn, the function calls "Draw Roof". The roof is an isoceles triangle and is filled in with 2 other triangles of smaller size. Then the chimney is drawn as a rectangle, the door is drawn as a rectangle, and the window is drawn as a square. The pen makes two passes over the window to draw panes. 

Finally, Draw Moon draws two different circles, one to outline the moon, and the other to fill it in. The final part of the program sends the sprite off screen.

Created September 2, 2022

Last updated September 4, 2022

Shared September 4, 2022