Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Computer science find the solution by processing time program structure, and the global constants . loll? _ 'mplete the program by adding a few state

Computer science find the solution by processing

image text in transcribed
time program structure, and the global constants . loll? _ 'mplete the program by adding a few state '9 , _ tvvo functions, so that it will draw a circle that moves ,1: nd rth along ahorizontal line, as shown here. The circle will " onn'ally move at a constant speed, but will freeze in place whenever mouse button is pressed, resuming its motion when the mouse button is released. 1; _ The following constants are supplied. X__!.EFT and X_RIGHT are the at coordinates of the ends of the line, and Y is the y coordinate of everything (both ends of the line, and the centre of the circle). BALL_DIAM and BALL_SPEED give the diameter of the circle (in pixels) and the speed of motion of the circle (in pixels per frame). (But that motion will change between right-to-left and left-toright.) . Dene the \"state variables\" needed to keep track of the current situation. You need to know the current position of the centre of the circle (use a float) and whether the circle is moving to the left, or to the right (you must use a boolean variable for this). . Add the drauAIlO function which will erase the window to grey, and draw the line and the circle. . Add the moveBa 11 () function which will cause the circle to move back and forth along the line. Whenever the centre of the circle goes beyond either end of the line, it should change direction. Whenever the mouse button is pressed, the circle should not move. Otherwise it should move BALL_SPEED pixels to the left, or to the right, according to the value of your boolean state variable. Use IF statements to do these things (you will need at least 3 of them, perhaps 4)

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

Algebra And Trigonometry

Authors: Cynthia Y Young

3rd Edition

1118475755, 9781118475751

More Books

Students also viewed these Mathematics questions

Question

How many three-digit numbers are divisible by 7?

Answered: 1 week ago

Question

What is Indian Polity and Governance ?

Answered: 1 week ago