Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please use python and pygame example output: Please complete the following code in python for the above program Part 1: The Drawable Class In this

Please use python and pygame

image text in transcribed

example output:

image text in transcribed

Please complete the following code in python for the above program

image text in transcribed

Part 1: The Drawable Class In this week's lecture we discussed how we can used object oriented programming concepts to make graphics applications more organized and easier to create. One of the things that we'll leverage is inheritance, polymorphism, and abstract base classes We have included drawable.py that contains an abstract base class called (shocker) Drawable. This class has the following methods: . A constructorinitmethod where you can set the x and y locations for your object . Accessor and mutator methods for the x and y locations. .An abstract method called draw that takes a surface to draw on as a parameter Part 2: Rectangle class Now we're going to derive from this dass. The first derived class you'll want to make is Rectangle To instantlate the Rectangie class you need The (x, y) location where the Rectangle is to be drawn It's width and height . . It's color Then in the class's draw method you draw a rectangle starting at (xy) of dimensions (width, height) on the surface in the chosen color NOTE: For credit you must derive from Drawable and use it's constructor Part 3: The Snowflake Class Now switch roles! Next up let's create a Snowflakel A Snowflake will be made up of 4 lines. If the Snowflake is to be centered at (xy)then those four lines are Line1: (x5,yx+5,y) Line2 (xy-5)x.y+5) To instantiate the Snowflake class you need .The (x) location where the Snowflake will start (its y location will always start as 0) And in its draw method you draw a the four lines as mentioned based on the current (x y) location in white. NOTE: For credit you must derive from Drawable and use it's constructor Part 4: The Main Application Switch roles againl Here's the main application: .Draw a'ground plane". Presumably a green rectangle Draw a'sky plane". Presumably a blue reclangle Every iteration of your graphics loop o Loop through all your drawable objects and draw them. lf the current drawable is of type Snowflake (hint use the isinstance function) increment the y coordinate of that Snowflake o Spawn a new Snowflake instance

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions

Question

3. What strategies might you use?

Answered: 1 week ago

Question

3. Write a policy statement to address these issues.

Answered: 1 week ago