Computer Science Canada

In Need Of Help With Pong.

Author:  magicman [ Mon Apr 05, 2004 9:22 am ]
Post subject:  In Need Of Help With Pong.

I need help with my pong program. When i move the first player the second player moves what is the problem? here's the code.
code:


View.Set ("graphics")
var x : int := 15
var y : int := 160
var x1 : int := 630
var y1 : int := 160


var chars : array char of boolean

var chars1 : array char of boolean

loop
    View.Set ("offscreenonly")
    View.Update
    cls
    Draw.ThickLine (x, y, 15, y + 100, 3, 17)
    delay (15)

    Draw.ThickLine (x1, y1, 630, y + 100, 3, 17)
    Input.KeyDown (chars)
    Input.KeyDown (chars1)
    %Player 1
    if chars ('w') then
        y := y + 10
    end if
    if chars ('s') then
        y := y - 10
    end if
    %Player 2
    if chars1 (KEY_UP_ARROW) then
        y1 := y1 + 10
    end if
    if chars1 (KEY_DOWN_ARROW) then
        y1 := y1 - 10
    end if
end loop

HELP

Dan Edit: fixed your code tags there, make it look nice Wink

Author:  Tony [ Mon Apr 05, 2004 1:21 pm ]
Post subject: 

yiekes Confused You don't take Input.KeyDown twice... just once, and use the same array to analyze input


: