
-----------------------------------
Salman
Thu Jan 03, 2013 9:55 pm

Pong on Turing
-----------------------------------
Hello, I'm working on a pong game on Turing. I would like to know how to code the the arrow keys, please reply as soon as possible, this is my code so far:

import GUI
var font : int
var option : string
var movement : int := 0
var keys : array char of boolean
const centerx := maxx div 2
const centery := maxy div 2
colorback (black)

for i : 1 .. 25 %Counted loop makes the background stay black
    for j : 1 .. 80
        put " " ..
    end for
end for
setscreen ("nocursor")
font := Font.New ("Arial Black:18")
Font.Draw ("Pong", 280, 320, font, red)
procedure startGame
    cls
    Draw.FillBox (0, 600, maxx, 360, brightred)
    Draw.FillBox (0, 00, maxx, 45, brightred)
    Draw.FillBox (0, 175, 10, 225, red)
    Draw.FillBox (630, 175 + movement, maxx, 225 + movement, red)
    Input.KeyDown (keys)
    if keys (KEY_UP_ARROW) then
        Draw.FillBox (630, 175 + movement, maxx, 225 + movement, black)
        movement := movement + 2
    end if
    for i : 1 .. 5
        drawfilloval (centerx, centery, i + 5, i + 5, brightblue)
    end for

end startGame
var startButton : int := GUI.CreateButton (maxx div 2 - 30, 60, 60,
    "Start Game", startGame)
procedure helpGame
    cls
    colorback (white)
    Font.Draw ("Refer to the instruction manual", 100, 320, font, red)
end helpGame
var helpButtom : int := GUI.CreateButton (maxx div 2 - 200, 60, 60, "Help", helpGame)

loop
    exit when GUI.ProcessEvent
end loop

-----------------------------------
Insectoid
Thu Jan 03, 2013 10:01 pm

RE:Pong on Turing
-----------------------------------
The arrow keys codes are KEY_UP_ARROW, KEY_LEFT_ARROW, etc. Any time you'd check for something like 'd', instead use one of those codes.

-----------------------------------
TerranceN
Fri Jan 04, 2013 5:24 am

RE:Pong on Turing
-----------------------------------
And [url=http://compsci.ca/holtsoft/doc/keyboardmodule.html]here's a full list of key codes.
