Idkwhatimdoing
Idkwhatimdoing

Reputation: 59

How to fix boundaries

I'm trying to follow the tutorial by Christian Thompson - the tutorial is here.

However, the ball and paddles aren't affected by the boundary.

I've tried rewriting the code and copying it exactly but it always ends up failing

if ball.ycor() > 290:
    ball.sety(290)
    ball.dy *= -1
    score_b += 1

if ball.ycor() > -290:
    ball.sety(-290)
    ball.dy *= -1
    score_a += 1

Upvotes: 2

Views: 29

Answers (1)

Ahndwoo
Ahndwoo

Reputation: 1025

One thing I immediately notice is that the second if statement should read:

if ball.ycor() < -290:

You want to check if it's less than -290. Any ball in play will always be greater than -290, which is probably why it's breaking, because that if statement is firing every loop.

Upvotes: 3

Related Questions