Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I need help I am trying to make a game called Pong which is very famous, I have practically created the ball and both paddle
I need help I am trying to make a game called Pong which is very famous, I have practically created the ball and both paddle in code ... I have problems making the ball move constantly and bounce off the walls and on the paddle and on create a score .... according to the instructions I cannot use another library other than graphics.py .... here is my python code:
1 fron graphics import * PongGame.py > w N def paddleA_up(paddleA): paddleA.move(0, -20) def paddleA_down (paddleA) : paddleA.move(0, 20) 8 9 def paddleB_up(paddleB): paddleB.move(0, -20) def paddleB_down (paddleB) : paddleB.move(0, 20) 10 11 12 13 14 15 16 17 18 19 20 21 def main(): #Window win = GraphWin("Pong Game", 600, 400) win.setBackground("black") #Paddles paddleA = Rectangle(Point(5,1), Point(10, 70)) paddlea.setOutline("white") paddlea.setFill("white") paddlea.draulvin) paddlea.move(5, 170) #PaddleB paddles = Rectangle(Point(5,1), Point(10, 1)) paddles.setOutline("white") paddles. setFill("white") paddles.draulvin) paddles.move(580, 170) #Ball ball = Circle(Point(20, 20), 8) ball.setOutline("white") ball.setFill("white") ball.draw(win) ball.nove(290, 170) PongGame.p DatL.araw(win) ball.move(290, 170) dx = 1 dy = 1 #Move Paddle while True: key = win.checkKey() if key == "o": break elif key "Up": paddleA_up(paddleA) elif key == "Down": paddleA_down{paddleA) elif key paddleB_up(paddleB) elif key == "s": paddleB_down{paddleB) PongGame.py > ... pada lea_up ipada LEA) elif key = "Down": paddleA_down (paddleA) elif key == "W": paddleB_up (paddleB) elif key == "s": paddleb_down (paddleB) #Move Ball for i in range (10000): ball = ball.move(290, 170) if ball.getX() > 20: dx = -1 elif ball.getX() 20: dy = -1 elif ball.getY() 20: I AttributeError: None Type object has no attribute 'getX Johnatans-MBP-3: Johnatanortiz$ /usr/local/bin/python3 /Users/johnatanortiz/Desktop/PongGame.py Traceback (most recent call last): File "/Users/johnatanortiz/Desktop/PongGane.py", line 95, in modules main() File "/Users/johnatanortiz/Desktop/PongGame.py", line 78, in main if ball.getX() > 20: AttributeError: 'None Type' object has no attribute 'get' Johnatans-MBP-3: johnatanortizs I Ln 2, Col1 Sp Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started