Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 In Need Of Help With Pong.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
magicman




PostPosted: 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
Sponsor
Sponsor
Sponsor
sponsor
Tony




PostPosted: Mon Apr 05, 2004 1:21 pm   Post subject: (No subject)

yiekes Confused You don't take Input.KeyDown twice... just once, and use the same array to analyze input
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 2 Posts ]
Jump to:   


Style:  
Search: