After I got the paddles to move properly, the start screen stopped showing up at the beginning. I want it to show the actual game screen when you press enter, which worked, until I added the paddles. I know for a fact that the problem has to do with the display update, but I'm not sure how to fix it.
Here's the game loop:
while not x:
for event in pygame.event.get():
if event.type == pygame.QUIT:
x = True #quits the game when you press X
if event.type == pygame.KEYUP: #makes start screen go away
if event.key == pygame.K_RETURN:
gameScreen() #has the black background and lines
#moves the paddles
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_w: #makes blue paddle go up
p1Paddle.state = 'up'
p1Paddle.move()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_s: #makes blue paddle go down
p1Paddle.state = 'down'
p1Paddle.move()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP: #makes red paddle go up
p2Paddle.state = 'up'
p2Paddle.move()
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_DOWN: #makes red paddle go down
p2Paddle.state = 'down'
p2Paddle.move()
gameScreen() #updates the display (problem- not sure what to put instead)
p1Paddle.show()
p2Paddle.show()
ball.show()
I added a variable, start
, before the loop and set it as false. Then, at the end of the loop I replaced this:
gameScreen() #updates the display (problem- not sure what to put instead)
p1Paddle.show()
p2Paddle.show()
ball.show()
with this:
if start == True:
gameScreen()
p1Paddle.show() #make the paddles and ball show up vv
p2Paddle.show()
ball.show()
*Now the start screen shows up, but the paddles show up over it at the start- but that's it's own problem.