Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The code should be written in Processing 3 in Python The Outdoorsy family have had their fill of the city life. They want to pack
The code should be written in Processing 3 in Python
The Outdoorsy family have had their fill of the city life. They want to pack up and move to the woods! They've already picked a remote location in which to settle. Before they can move in though, they need to figure out exactly where they want to situate their new house. Your program will display a picture of the outdoors setting where the drawing of the family's house follows the mouse cursor. This will allow the user to see what the whole scene would look like with the house in different places. To gain more practice using functions and parameters, you will break up your program into lat least the following functions. You can divide up the work further into other functions if you like as long as you have these ones: - A function called draw_tren (x,y). This function must have two parameters, which are the x.y coordinates at which to draw a tree. - A function callod draw houne (x,y). This function must have two parameters, which are the x.y coordinates at which to draw the house. - You will noed netup() and drau() as woll. For this program, nothing happens when the mouse is clicked or when keys are pressed, so you shouldn't nood any other interactive functions. The following list gives more dotails about the functions above, as woll as laying out a suggosted order for completing all the tasks for this problem. (a) Start by writing function drav_tree (x,y) that draws a troe to the canvas centrod at pixol coordinates (x,y). Use a brown rectangle as the troe trunk, a groen circle as the troetop and throe small red coloured circles representing flowers. For the purpose of drawing the troe, the tree's center is the center of its treetop. (b) Draw the woods sotting. The background colour should be a dark groen to represent the grass, contain one large blue lake (with a fish), and have five treos scatterod across the land. Use multiple function calls to your draw_tree() function to place the treos. You can place these anywhere you like, as tong as it looks nico. (c) Write function draw_house (x,y) that draws a white house to the canvas centred at pixol coordinates (x,y). The base of the house should be 70 pocets 50 pixels in size. The centre of the house is considered to be the center of this rectangle. You might find it holpful to use extra variables while writing this function to keep track of intermediate values in your calculations. Noto that x and y must be parameters to the function, the function itself should not DIRECTLY use moeseX and mouseY. Instead. mouseX and mouseY will be used as arguments when the drav_house () function is called. (d) Draw a red front door for the house within drav_house (). The red door should be 20 pixels 40 pixols, drawn so that the bottom of the door is flush with the bottom of the house, and drawn so that the centre of the door lines up with the centre of the house. You might find it helpful to use extra variables while writing this function to keep track of intermediate values in your calculations. (e) Draw a blue triangular roof for the house within drau house (). The blue roof should be as wide as the house, 30 pixels tall, and situated immediately above the base of the house. Hint: Processing does, in fact, have a triangle() function, which takes 6 arguments, these arguments are the (x,y) coordinates of the corners of the triangle. (f) Finally. make your program interactive by having the house follow the mouse cursor across the screen with the woods setting as the canvas background The final program output might look something like Figure 2 (below). igure 2: The house in front of some trees in the woods. The mouse location should be center of the house. It is highly recommended you test each feature after its implementation and make sure it works before moving on to the next. Why? It is much easier to detect and squash errors in your program sooner rather than later. What to Hand InStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started