I am currently trying to develop a minigolf game but that is the main problem. The error that is displaying is: TypeError: invalid position for blit
power = 0
angle = 0
ballPos = (width//2 - golfBallWidth//2, 550)
ballVel = [0, 0] # x and y velocity components of the ball
ballAcc = [0, 0] # x and y acceleration components of the ball
ballMass = 0.0459 # mass of the golf ball in kg
frictionCoeff = 0.15 # coefficient of friction between ball and ground
holePos = (holePosX, holePosY)
def friction():
global ballVel, ballAcc
frictionalForce = frictionCoeff * ballMass * 9.81 #Calculates frictional force
frictionalDirection = math.atan2(-ballVel[1], -ballVel[0]) #Direction of friction
frictionalX = frictionalForce * math.cos(frictionalDirection) #components of frictional force
frictionalY = frictionalForce * math.sin(frictionalDirection)
ballAcc[0] += frictionalX/ballMass #applying fric force to ball
ballAcc[1] += frictionalY/ballMass
def setBallVelocity(power, angle, ballVel):
ballVel[0] = power * math.cos(angle)
ballVel[1] = power * math.sin(angle)
def ballPositioning():
global ballPos
ballPos = list(ballPos)
ballPos[0] += ballVel[0] * oneFrame
ballPos[1] += ballVel[1] * oneFrame
ballPos = tuple(ballPos)
def drawLevelOne(ballPos)
friction()
setBallVelocity(power, angle, ballVel)
ballPositioning()
WIN.blit(levelBackground, (0,0))
WIN.blit(courseHole, (holePosX, holePosY))
WIN.blit(golfBall, (ballPos))
pygame.display.update()`
I tried to print the variable ballPos at two different places. One right after the line
ballPos = tuple(ballPos)
and once right before the line
WIN.blit(golfBall, (ballPos))
I thought that both would have a tuple value but only the one that prints after the ballPos = tuple(ballPos)
line is printing and actually has a value within it. Im honestly not too sure whats wrong. The output after the 2nd line is simply just '()'