subject

Write a program that draws a stoplight. You should have a gray rectangle, and then three circles in the rectangle. The circles should be red, then yellow, then green. The rectangle should be centered on the screen. The yellow light should be centered on the screen, and the red and green light should be offset by BUFFER amount. BUFFER amount represents the distance from the center of one circle to the center of another circle.

Implement the function draw_circle that draws a single circle. Use it to draw the red, yellow, and green lights. Since all of the lights are the same size and aligned vertically, the function only needs to take the y position and color as arguments.

Note: Be sure to include comments for all functions that you use or create.

THIS IS WHAT I HAVE and I have error codes: any help??

# This program should draw a stop light

LIGHT_RADIUS = 25
STOPLIGHT_WIDTH = 100
STOPLIGHT_HEIGHT = 250
BUFFER = 75

# Implement a function that draws a single circle
# with radius LIGHT_RADIUS.
# The circle should be in the center of the screen horizontally.
# Use the parameters for the y position and color
def draw_circle(y_pos, color):
circ = Circle(LIGHT_RADIUS)
circ. set_postition(get_width()/2, y-pos)
circ. set_color(color)
add(circ)
draw_circle(get_height()/2 - BUFFER, Color. red)
draw_circle(get_height()/2, Color. yellow)
draw_circle(get_height()/2 + BUFFER, Color. green)

def draw_rectangle():
rect= Rectangle(STOPLIGHT_WIDTH, STOPLIGHT_HEIGHT)
rect. set_postion(get_width()/2 - STOPLIGHT_WIDTH/2, get_height()/2 - STOPLIGHT_HEIGHT/2)
rect. set_color(Color. grey)
add(rect)
draw_rectangle()

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:30, yayamcneal05
Which cultural aspect does this type of song best portray? a german polka dance
Answers: 1
image
Computers and Technology, 23.06.2019 17:00, Need1ng
The more powerful, 60 volt cables and the main power shut-off on an hev are both colored orange.
Answers: 1
image
Computers and Technology, 23.06.2019 20:40, bobby3350
On nba 2k 19, every time i try to join a my park game, it leads ro a website telling my dad that he needs ps plus. i already have ps plus though. how do i fix this?
Answers: 2
image
Computers and Technology, 24.06.2019 08:00, Maxxboogie
Can someone work out the answer as it comes up in one of my computer science exams and i don't understand the cryptovariables
Answers: 1
You know the right answer?
Write a program that draws a stoplight. You should have a gray rectangle, and then three circles in...

Questions in other subjects:

Konu
English, 19.10.2019 23:30
Konu
Mathematics, 19.10.2019 23:30