Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Part 1: Housekeeping Read this lab all the way through BEFORE completing it. This lab is broken into multiple parts. Your goal is to complete

Part 1: Housekeeping Read this lab all the way through BEFORE completing it.

This lab is broken into multiple parts. Your goal is to complete as many parts as you can by the end of the lab. If you do not complete all of them, you can still get full points; show that you have worked hard and put in effort and complete the minimum amount of problems and this will be accomplishable. You need to complete Part 3 to receive full points.

This lab will expand on our GUI abilities and will have you work with animating a ball across a canvas.

Part 2: Studying the In-Class Example (10 minutes) Locate the file VerticalBouncingBall.py, which should contain code that shows a red ball bouncing up and down on the left side of the screen. Ensure that you understand each line of code found in this program before proceeding.

Part 3: GUI Layout (60 minutes) This is the last problem required for full credit.

Using VerticalBouncingBall.py as inspiration, create a similar program that has the ball bouncing across the screen. The ball should start at the coordinates (0, 0) and begin moving southeast. Each time it hits a wall, it should bounce from it at a 45-degree angle in the opposite direction. For example, a ball moving northwest should bounce from a western wall in the northeast direction. If it were to hit a northern (i.e., top) wall, it should bounce and go southwest. The program should end only when the user presses the red x on the window to close the GUI application.

Remark: It is easier and less coding to consider the east-west ball movement as independent from the north-south movement inside the animation loop.

Part 4: Extra Features (20 minutes) This is not required for full credit, but should be completed if time permits.

Choose one or both of the following features to implement:

Every time the ball hits a wall, change its color. This can be done by executing the statement self.canvas.itemconfig(ball, fill = color), where self.canvas is the variable containing the canvas, ball is the tag given to the oval shape, and color is a string containing a color from a given list of colors. Each time the ball hits a wall, it speeds up. This can be done by incrementing the delta counter by 1, formerly called dy in the original program. Once the counter has reached 10, it begins to decrement, only incrementing again once it has returned to its original value.

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

Step: 3

blur-text-image

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

Students also viewed these Databases questions

Question

dy dx Find the derivative of the function y=(4x+3)5(2x+1)2.

Answered: 1 week ago