Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

need help with this assignment its python.. need the code to generate this game.

ID: 3835580 • Letter: N

Question

need help with this assignment its python.. need the code to generate this game. thank you

In the attached file, Assets_Pong.zip, under Our Classroom > Student Data Files > Assets for Chapter 11, are images that may be used to create a background and sprites for a game of pong. Read Challenge #3 on page 360 of the text book.

this is the information about challenge 3 ....

create a simple one-player game of pong, where a player controls a paddle and the ball bounces off three walls. if the ball gets by the player 's paddle, the game is over.

Crazy PONG SCORE

Explanation / Answer

import pygame import random # Paddle properties PADDLE_WIDTH = 25 PADDLE_HEIGHT = 100 PADDLE_COLOR = (0, 0, 0) PADDLE_SPEED = 6 # Ball properties BALL_RADIUS = 20 BALL_COLOR = (0, 0, 0) BALL_INITIAL_VX = -5 BALL_INITIAL_VY = -5 # Base object class class Object: # Initializes the object with coordinates, size and color def __init__(self, x, y, w, h, color): self.x = x self.y = y self.w = w self.h = h self.vx = 0 self.vy = 0 self.color = color # Updates object by moving it and checking if it's in screen range def update(self, screenWidth, screenHeight): self.x += self.vx self.y += self.vy if self.x < 0: self.x = 0 if self.y < 0: self.y = 0 if self.x > screenWidth - self.w: self.x = screenWidth - self.w if self.y > screenHeight - self.h: self.y = screenHeight - self.h # Must be implemented by child classes def draw(self, surface): pass # Returns whether object collides with another object (rectangular collision detection) def collides(self, obj): return self.y obj.y and self.x obj.x # Called when object collides with anoher object, must be implemented by child classes def onCollide(self, obj): pass # Paddle class class Paddle(Object): # Initializes Paddle object def __init__(self, x, y): super(Paddle, self).__init__(x, y, PADDLE_WIDTH, PADDLE_HEIGHT, PADDLE_COLOR) # Draws paddle with a rectangle def draw(self, surface): pygame.draw.rect(surface, self.color, (self.x, self.y, self.w, self.h)) # Moves paddle up def moveUp(self): self.vy -= PADDLE_SPEED # Moves paddle down def moveDown(self): self.vy = PADDLE_SPEED # Stops moving the paddle def stopMoving(self): self.vy = 0 # ComputerPaddle class class ComputerPaddle(Paddle): # Initializes ComputerPaddle object def __init__(self, x, y): super(ComputerPaddle, self).__init__(x, y) # Adjust Y-velocity based on speed and direction of ball def update(self, ball, screenWidth, screenHeight): super(ComputerPaddle, self).update(screenWidth, screenHeight) if ball.vx < 0: self.stopMoving() return ballX = ball.x ballY = ball.y ballVX = ball.vx ballVY = ball.vy while ballX + ball.w screenHeight - ball.h: ballVY = -ballVY if ballY > self.y + self.h: self.moveDown() elif ballY + ball.h