
-----------------------------------
MeTaLPyTHoN
Tue Jan 06, 2004 8:52 pm

2 getch lines at once
-----------------------------------
Hey... Im a pretty novice programmer but rather intrested in it and advancing my skills, but for the moment i dont know if what im asking about is possible in turing, or how to do it, so i figured this would be the place to come... im trying to make a pong game for computer science, and cant figure out how to get the computer to accept 2 key press values at once, right now im using a process for each paddle, and they work, but only one at a time, like only one paddle will move at one time bcuz it wont read 2 getch statements at one time... is there an easier statement for this or are processes the wrong way to go (forking was my only guess at getting 2 things to ahppen at once).. anyway, heres the code, if anyone has suggestions, they would be much appreciated:)
setscreen ("graphics:700;500")
var screen, paddle1y, paddle2y, paddlepic : int
drawfillbox (0, 0, 10, 50, 10)
paddlepic := Pic.New (0, 0, 10, 50)
cls
screen := Pic.New (0, 0, 10, 10)
paddle1y := 0
paddle2y := 0

proc drawBackGround ()
    Draw.FillBox (0, 0, maxx, maxy, 7)
    Draw.Line (70, 0, 70, maxy, 10)
    Draw.Line (maxx - 70, 0, maxx - 70, maxy, 10)
    Draw.Oval (round (maxx / 2), round (maxy / 2), 75, 75, 10)
    Draw.Line (round (maxx / 2), maxy, round (maxx / 2), maxy - 100, 10)
    Draw.Line (round (maxx / 2), maxy - 200, round (maxx / 2), maxy - 300, 10)
    Draw.Line (round (maxx / 2), maxy - 400, round (maxx / 2), 0, 10)
end drawBackGround
proc saveScreen (var screen : int)
    screen := Pic.New (0, 0, maxx, maxy)
end saveScreen
proc drawSaved (screen : int)
    Pic.Draw (screen, 0, 0, picCopy)
end drawSaved
proc drawpaddle (x, y : int)
    Pic.Draw (paddlepic, x, y, picCopy)
end drawpaddle

process movepaddle1 ()
    var select : string (1)
    setscreen ("offscreenonly")
    loop
        loop
            getch (select)
            if select = "a" then
                paddle1y += 5

                if paddle1y >= maxy - 50 then
                    paddle1y := maxy - 50
                end if
                exit
            elsif select = "z" then
                paddle1y -= 5
                if paddle1y = maxy - 50 then
                    paddle2y := maxy - 50
                end if
                exit
            elsif select = "m" then
                paddle2y -= 5
                if paddle2y   i kept the processes and used the input.keydown

setscreen ("graphics:700;500")
var screen, paddle1y, paddle2y, paddlepic : int
drawfillbox (0, 0, 10, 50, 10)
paddlepic := Pic.New (0, 0, 10, 50)
cls
screen := Pic.New (0, 0, 10, 10)
paddle1y := 0
paddle2y := 0

proc drawBackGround ()
    Draw.FillBox (0, 0, maxx, maxy, 7)
    Draw.Line (70, 0, 70, maxy, 10)
    Draw.Line (maxx - 70, 0, maxx - 70, maxy, 10)
    Draw.Oval (round (maxx / 2), round (maxy / 2), 75, 75, 10)
    Draw.Line (round (maxx / 2), maxy, round (maxx / 2), maxy - 100, 10)
    Draw.Line (round (maxx / 2), maxy - 200, round (maxx / 2), maxy - 300, 10)
    Draw.Line (round (maxx / 2), maxy - 400, round (maxx / 2), 0, 10)
end drawBackGround
proc saveScreen (var screen : int)
    screen := Pic.New (0, 0, maxx, maxy)
end saveScreen
proc drawSaved (screen : int)
    Pic.Draw (screen, 0, 0, picCopy)
end drawSaved
proc drawpaddle (x, y : int)
    Pic.Draw (paddlepic, x, y, picCopy)
end drawpaddle

process movepaddle1 ()
    var select : array char of boolean
    setscreen ("offscreenonly")
    loop
        loop
            Input.KeyDown(select)
            if select ( 'a') then
                paddle1y += 5

                if paddle1y >= maxy - 50 then
                    paddle1y := maxy - 50
                end if
                exit
            elsif select  ('z') then
                paddle1y -= 5
                if paddle1y = maxy - 50 then
                    paddle2y := maxy - 50
                end if
                exit
            elsif select  ('m') then
                paddle2y -= 5
                if paddle2y 