from visual import *
# > for top and right
# < for bottom and left
# x = side to side
# y = up and down
R1 = 0
L1 = 0
RightScore = text(pos=vector(4,6,0),text=str(R1), align='center', depth=0.1, color=color.green)
LeftScore = text(pos=vector(-4,6,0),text=str(L1), align='center', depth=0.1, color=color.green)
#Ball itself
ball = sphere(pos=(-5,0,0),radius=0.5, color=color.cyan)
#Walls
wallR = box(pos=(6,0,0), size=(0.2,12,12), color=color.green, opacity=0)
wallL = box(pos=(-6,0,0), size=(0.2,12,12), color=color.green, opacity=0)
wallT = box(pos=(0,6,0), size=(12,0.2,12), color=color.yellow, opacity=0)
wallB = box(pos=(0,-6,0), size=(12,0.2,12), color=color.yellow, opacity=0)
wallBack = box(pos=(0,0,-6), size=(12,12,0.2), color=color.cyan, opacity=0)
paddleRight = box(pos=(5.5,0,0), size=(1,4,0), color=color.green)
paddleLeft = box(pos=(-5.5,0,0), size=(1,4,0), color=color.green)
ball.velocity=vector(25,35,0)
deltat=0.005
t=1
while 1 >0:
rate(55)
if ball.pos.x >= wallR.pos.x:
ball.velocity.x=-25
if ball.pos.x == wallL.pos.x:
ball.velocity.x=25
if ball.pos.y >= wallT.pos.y:
ball.velocity.y=-35
if ball.pos.y <= wallB.pos.y:
ball.velocity.y=35
### SCOREBOARD ########################
if ball.pos.x == wallL.pos.x :
R1 = R1 + 1
RightScore.text = str(R1)
if ball.pos.x == wallR.pos.x :
L1 = L1 + 1
LeftScore.text = str(R1)
######################################
KEY PRESS EVENTS
if scene.kb.keys:
key = scene.kb.getkey()
if key == "up":
paddleLeft.pos.y = paddleLeft.pos.y + 0.5
elif key == "down":
paddleLeft.pos.y = paddleLeft.pos.y - 0.5
paddleRight.pos.y = ball.pos.y
ball.pos = ball.pos + ball.velocity * deltat
Everytime the ball hits either wall it counts as a point anyways, and I do not want that. The ball should only be able to bounce off the paddle and if the ball lands off the paddle then it registers as a point to whom ever scored it. I really hope you guys can understand what I am trying to get at.
Thank you so much for your time and consideration in mentioning a couple of steps to help me out, it really is much appreciated.