CEIS 100 student needs help with my pong python 3 pygame please help!

Ok I have added my code. I figured how to import a png image but im having trouble making that image move. The image is supposed to me the ball moving by itself. I then want to import a backround image and an image to use for my pong paddles. They havent really taught us anything its really a self teach class and Im doing my best. my course project is due on sat at 12am. In total I need to add image for paddles, add paddles, make paddles move (collision, etc), same with ball, then I want a score board and a start menu.

This is where I get my error:

def moveBall(drawBall, drawBallDirX, drawBallDirY):
drawBall.x += drawBallDirX
drawBall.y += drawBallDirY
drawBallDirX = -1
drawBallDirY = -1
if event.move == drawBallDirX:
if event.drawBallDirX:
x_change = -5
elif event.drawBallDirX:
x_change = 5

if event.move == drawBallDirY:
if event.drawBallDirY:
y_change = 0
return ball

This is what my shell tells me about my error:

Traceback (most recent call last): File “/home/pi/python_games/test.py”, line 112, in <module> drawBall = moveBall(drawBall, drawBallDirX, drawBallDirY) File “/home/pi/python_games/test.py”, line 53, in moveBall drawBall.x += drawBallDirX AttributeError: ‘function’ object has no attribute ‘x’

This is my whole code( Its mainly my own build with the little knowledge I have and has influences of other code I copied and tried to make my own):

import pygame

pygame.init()

display_width = 800
display_height = 600
lineThickness = 20
paddleSize = 80

black = (0 ,0 ,0 )
white = (255,255,255)
violet = (138,43 ,226)
gold = (255,185,15 )
green = (0 ,201,87 )
red = (205,0 ,0 )

gameDisplay = pygame.display.set_mode((display_width,display_height))
pygame.display.set_caption(‘Star Pong’)
clock = pygame.time.Clock()

ballImg = pygame.image.load(‘gem4.png’)
drawBall = ballImg
drawBallDirX = -1 ## -1 = left 1 = right
drawBallDirY = -1

def drawArena():
global paddle1Img, paddle2Img, ball

gameDisplay.fill(violet)
#Draw outlne of arena
pygame.draw.rect(gameDisplay, gold, ((0,0),(display_width,display_height)), lineThickness * 2)
#Draw center line
pygame.draw.line(gameDisplay, gold, [display_width / 2, 0],[display_width / 2, display_height], 2)
pygame.draw.line(gameDisplay, green, [paddleSize, 0],[paddleSize, display_height], 2)
pygame.draw.line(gameDisplay, green, [display_width - paddleSize, 0],[display_width - paddleSize, display_height], 2)
pygame.draw.circle(gameDisplay, red, [display_width//2, display_height//2], 80, 10)

def drawBall(x,y):
gameDisplay.blit(ballImg,(x,y))

x = (display_width * 0.46)
y = (display_height * 0.42)

x_change = 0
y_change = 0

def moveBall(drawBall, drawBallDirX, drawBallDirY):
drawBall.x += drawBallDirX
drawBall.y += drawBallDirY
drawBallDirX = -1
drawBallDirY = -1
if event.move == drawBallDirX:
if event.drawBallDirX:
x_change = -5
elif event.drawBallDirX:
x_change = 5

if event.move == drawBallDirY:
if event.drawBallDirY:
y_change = 0
return ball

def main():
pygame.init()
global gameDisplay

Font information

global BASICFONT, BASICFONTSIZE
BASICFONTSIZE = 20
BASICFONT = pygame.font.Font(‘freesansbold.ttf’, BASICFONTSIZE)

#Initiate variable and set starting positionss
#any future changes made within rectangles
ballX = display_width/2 - lineThickness/2
ballY = display_height/2 - LineThickness/2
playerOnePosition = (display_height - paddleSize) /2
playerTwoPosition = (display_height - paddleSize) /2

#Keps track of ball direction
drawBallDirX = -1 ## -1 = left 1 = right
drawBallDirY = -1 ## -1 = up 1 = down

#creates rectangles for ball and padles.
ball = pygame.Rect(ballX, ballY, lineThickness, lineThickness)

#Draws the starting position of the Arena
drawArena()
drawBall(x,y)

pygame.mouse.set_visible(0)

loser = False

while not loser:

for event in pygame.event.get():
if event.type == pygame.QUIT:
loser = True

x ± x_change
y ± y_change

gameDisplay.fill(violet)
drawArena()
drawBall(x,y)

drawBall = moveBall(drawBall, drawBallDirX, drawBallDirY)
drawBallDirX, drawBallDirY = (drawBall, drawBallDirX, drawBallDirY)

pygame.display.update()
clock.tick(60)

pygame.quit()
quit()

Finally if anyone lives in chicago and wants to get together to code some games or make some apps hit me up this all is so fun and frustrating, I was doing this for 14 hrs yesterday started that started over I hated but I loved it. Thank you for all your help everyone.

Hi @scarpelli1210,

The GitHub Learning Lab board is to discuss the new GitHub Learning Lab. As you’re looking to get help outside of this topic, I moved this post to a different board that fits your topic of discussion a bit better. This means you’ll get better engagement on your post, and it keeps our Community organized so users can more easily find information.

As you’ll notice, your Topic is now in the Project Development Help and Advice board. No action is needed on your part; you can continue the conversation as normal here.

Let me know if you have any other questions or if I can help with anything else.

Cheers!