
-----------------------------------
FakeSound
Sat May 06, 2006 6:49 pm

pong help plz :(
-----------------------------------
My friend and i are making a game of pong; just a simple game for extra marks in our programming class.
However, we're facing a few problems right now... 
a] i can't get the paddles to stay in the screen (I need to set boundaries, but don't know how)
b] the ball doesn't bounce off the paddles (We're not very experienced using whatdotcolor or collision)
so ... i'll post my code right here, any help is greatly appreciated.

setscreen ("graphics:630;420, Title: Pong?")
var x, y, x1, y1, a, b, a1, b1,oy,ox,os: int
var chars : array char of boolean
var nx,ny:int:=1 % changes direction of ball and checks boundries
colorback (255)
x := 10
y := 10
x1 := 20
y1 := 100
a := 10
b := 10
a1 := 20
b1 := 100
oy:=200
ox:=170
os:=10
ox := Rand.Int (10, 100) %set the x quadrant for the 1st oval 
oy := Rand.Int (10, 100) %set the y quadrant for the 1st oval


loop
   
   
    /* omit if ox = maxy then %check to see if it goes off the bottom 
        ny := - 1 %chages the direction 
    end if 
    
        if ox  paddle.x and ball.y - ball.radius < paddle.y + paddle.height and ball.y + ball.radius > paddle.y then
    ball.vx *= -1  % Multiply the ball's horizontal velocity by -1 and reassign that value to itself
end if



-----------------------------------
wtd
Sat May 06, 2006 7:48 pm


-----------------------------------

if ball.x - ball.radius < paddle.x + paddle.width and ball.x + ball.radius > paddle.x and ball.y - ball.radius < paddle.y + paddle.height and ball.y + ball.radius > paddle.y then
    ball.vx *= -1  % Multiply the ball's horizontal velocity by -1 and reassign that value to itself
end if


That condition so very much needs to be factored out into a function.
