Computer Science Canada

Pong in Turing

Author:  Salman [ Mon Jan 07, 2013 1:28 pm ]
Post subject:  Pong in Turing

Im making pong for Turing. I have been trying to activate the up and down arrow keys for each player, this is my code so far, and answer my question as soon as possible:

Turing:

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


Mod Edit:

Please wrap you code in either of the following in order to preserve whitespace (indentation) and to highlight the syntax.
code:

[syntax="turing"] ... code ... [/syntax]

[code] ... code ... [/code ]

Author:  Tony [ Mon Jan 07, 2013 1:41 pm ]
Post subject:  Re: Pong in Turing

Salman @ Mon Jan 07, 2013 1:28 pm wrote:
and answer my question as soon as possible:

That's kind of... demanding. Also, you forgot to actually ask a question. Are you having problems with something?

Author:  Salman [ Wed Jan 09, 2013 2:13 pm ]
Post subject:  RE:Pong in Turing

I was asking about how to move the paddles, with arrow keys? I already figured it out.


: