Requirements: 1) input/output 2) Code segments that have different effects on the code 3) Use of a list that shows complexity (without the list the code shouldn’t work the same) 4) A procedure with a...

Hello. Need Python help (Brython: Python for browser).


Requirements: 1) input/output 2) Code segments that have different effects on the code 3) Use of a list that shows complexity (without the list the code shouldn’t work the same) 4) A procedure with a parameter that affects the functionality of the procedure 5) An algorithm within a procedure that includes sequencing, selection and iteration (they should all have an affect on the code) 6) (For the response…) What are two calls to the selected procedure? (What is a call to the procedure) General Objective: Have a working piece of code that meets all of the requirements. Thus far, code defines a soccer field, places ball on the field, and moves the ball around. Potential additions: If ball hits a target, it will bounce back to a certain fixed location. If ball goes into the net, it will register a goal. Total goals will be calculated and displayed. Usernames appear on corner of the screen. Phython code thus far (Brython – Python for Browser) points_1 = 0 points_2 = 0 #Parameters# set_size(680,450) turf = Rectangle(1000,1000) turf.set_position(0, 0) turf.set_color(Color.green) add(turf) #Perimeter# line_1 = Rectangle(670,3) line_1.set_position(5,5) line_1.set_color(Color.white) add(line_1) line_2 = Rectangle(3,440) line_2.set_position(5,5) line_2.set_color(Color.white) add(line_2) line_3 = Rectangle(670,3) line_3.set_position(5,443) line_3.set_color(Color.white) add(line_3) line_4 = Rectangle(3,440) line_4.set_position(673,5) line_4.set_color(Color.white) add(line_4) #Goal box(left side)# line_5 = Rectangle(85,3) line_5.set_position(5,337.5) line_5.set_color(Color.white) add(line_5) line_6 = Rectangle(85,3) line_6.set_position(5,112.5) line_6.set_color(Color.white) add(line_6) line_7 = Rectangle(3,228) line_7.set_position(90,112.5) line_7.set_color(Color.white) add(line_7) line_8 = Rectangle(42.5,3) line_8.set_position(5,168.75) line_8.set_color(Color.white) add(line_8) line_9 = Rectangle(42.5,3) line_9.set_position(5,281.25) line_9.set_color(Color.white) add(line_9) line_10 = Rectangle(3,113.5) line_10.set_position(45.5,169.75) line_10.set_color(Color.white) add(line_10) #Goal box(right side)# line_11 = Rectangle(85,3) line_11.set_position(590,337.5) line_11.set_color(Color.white) add(line_11) line_12 = Rectangle(85,3) line_12.set_position(590,112.5) line_12.set_color(Color.white) add(line_12) line_13 = Rectangle(3,226.5) line_13.set_position(590,113.5) line_13.set_color(Color.white) add(line_13) line_15 = Rectangle(42.5,3) line_15.set_position(632.5,168.75) line_15.set_color(Color.white) add(line_15) line_16 = Rectangle(42.5,3) line_16.set_position(632.5,281.25) line_16.set_color(Color.white) add(line_16) line_17 = Rectangle(3,113.5) line_17.set_position(632.5,169.75) line_17.set_color(Color.white) add(line_17) #Center of field# center_field_1 = Circle(55,55) center_field_1.set_position(341.5,225) center_field_1.set_color(Color.white) add(center_field_1) center_field_2 = Circle(52,52) center_field_2.set_position(341.5,225) center_field_2.set_color(Color.green) add(center_field_2) center_field_3 = Circle(5,5) center_field_3.set_position(341.5,225) center_field_3.set_color(Color.white) add(center_field_3) line_18 = Rectangle(3,440) line_18.set_position(340,5) line_18.set_color(Color.white) add(line_18) def write_1(txt, color, x_pos, y_pos): txt = Text(txt) txt.set_position(x_pos, y_pos) txt.set_color(Color.blue) add(txt) def write_2(txt, color, x_pos, y_pos): txt = Text(txt) txt.set_position(x_pos, y_pos) txt.set_color(Color.red) add(txt) #Lines 4-22 are inspired by Keyboard Events in CodeHS Docs# soccer_ball = Circle(15,15) soccer_ball.set_position(341.5,225) soccer_ball.set_color(Color.black) add(soccer_ball) def move_ball(): #def move_soccer_ball(movement): #soccer_ball = movement.key points_1 = 0 def move_soccer_ball(movement): if movement.key == "ArrowUp": soccer_ball.move(0,-10) elif movement.key == "ArrowDown": soccer_ball.move(0,10) elif movement.key == "ArrowRight": soccer_ball.move(10,0) elif movement.key == "ArrowLeft": soccer_ball.move(-10,0) if soccer_ball.get_x() < 0="" and="" soccer_ball.get_y()=""> 168 and soccer_ball.get_y() < 280:="" soccer_ball.set_position(341.5,225)="" txt="Text(str(points_1" +="" 1))="" txt.set_position(150,200)="" txt.set_color(color.blue)="" add(txt)="" points_1="points_1" +="" 1="" if="" soccer_ball.get_x()=""> 680 and soccer_ball.get_y() > 168 and soccer_ball.get_y() < 280:="" soccer_ball.set_position(341.5,225)="" write_2("goal!",="" color.red,="" 550,="" 100)="" if="" soccer_ball.get_x()=""> 680 or soccer_ball.get_x() < 0:="" soccer_ball.set_position(341.5,225)="" if="" soccer_ball.get_y()=""> 450 or soccer_ball.get_y() < 0: soccer_ball.set_position(341.5,225) add_key_down_handler(move_soccer_ball) move_ball() 0:="" soccer_ball.set_position(341.5,225)="" add_key_down_handler(move_soccer_ball)="">
Mar 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here