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

Username:   Password: 
 RegisterRegister   
 Pong on Turing
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Salman




PostPosted: Thu Jan 03, 2013 9:55 pm   Post subject: 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
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Thu Jan 03, 2013 10:01 pm   Post subject: 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




PostPosted: Fri Jan 04, 2013 5:24 am   Post subject: RE:Pong on Turing

And here's a full list of key codes.
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  [ 3 Posts ]
Jump to:   


Style:  
Search: