
-----------------------------------
shoobyman
Mon Jan 16, 2006 9:22 am

Help me with my pong game
-----------------------------------
Hey, i need help with my program cuz this is my final exam!
I need to make the ball bounce of the both platforms but i cant pick the right code :/  .   PLS help! ty...


var x, y, b, t, r, x1, y1 : int
var chars : array char of boolean
var x3, y3, button : int
var objectVX, objectVY, x2, y2 : int
objectVY := 10
objectVX := 10
x2 := maxx div 2
y2 := maxy div 2
x := 100
y := 200
x1 := 300
y1 := 400
setscreen ("graphics:500;500")
colorback (green)
setscreen ("offscreenonly")
loop
    Input.KeyDown (chars)
    drawfillbox (x, 100, y, 120, black)
    if chars (KEY_RIGHT_ARROW) then
        y := y + 15
        x := x + 15
    end if
    if chars (KEY_LEFT_ARROW) then
        x := x - 15
        y := y - 15
    end if

    drawfillbox (x1, 400, y1, 380, black)
    if chars ('d') then
        y1 := y1 + 15
        x1 := x1 + 15
    end if
    if chars ('a') then
        x1 := x1 - 15
        y1 := y1 - 15
    end if


    drawline (150, 70, 150, 1, black)
    drawline (300, 70, 300, 1, black)
    drawline (300, 500, 300, 430, black)
    drawline (450, 500, 450, 430, black)



    const ballRad : int := 7
    mousewhere (x3, y3, button)
    drawfilloval (x2, y2, ballRad, ballRad, black)
    x2 += objectVX
    y2 += objectVY
    delay (15)
    if x2 > maxx - 5 then
        objectVX := -objectVX + 2
    elsif x2 < 5 then
        objectVX := -objectVX + 1
    elsif y2 > maxx - 5 then
        objectVY := -objectVY + 1
    elsif y2 < 5 then
        objectVY := -objectVY + 1
    elsif x2 maxx - 5 then
        objectVX := -objectVX
    elsif x2 < 5 then
        objectVX := -objectVX
    elsif y2 > maxx - 5 then
        objectVY := -objectVY
    elsif y2 < 5 then
        objectVY := -objectVY
    elsif x2 >= x and x2 = x1 and x2 