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

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




PostPosted: Fri Jan 09, 2004 11:16 am   Post subject: getch help

ok, im making tetris for a school project, and i dont know how to do a getch to turn the pieces. i have all the positions redrawn and stuff, i just dont know how to do a getch thing. any help would be swell.
Sponsor
Sponsor
Sponsor
sponsor
DanShadow




PostPosted: Fri Jan 09, 2004 2:39 pm   Post subject: (No subject)

It's easy..just tell me if th e pieces are picture (bmp) files, or just regular drawbox/drawlines?
code:

var key :string(1):=""
var pos:string:=""
loop
if hasch then
getch(key)
end if
if key =(KEY_RIGHT_ARROW) then
pos:="rotate right"
elsif key=(KEY_LEFT_ARROW) then
pos:="rotate left"
end if
end loop

The if hasch then means that if the computer senses that a key has been pressed on the keyboard, it will getch the key and place it inside the key variable. (Which can contain a max of 1 char in it. I hop this helps.
Tony




PostPosted: Fri Jan 09, 2004 4:55 pm   Post subject: (No subject)

actually hasch just returns true if there's an unprocessed character in the input buffer. if you were to loop hasch without using getch to clear the buffer, it will run indefinatly from a single key stroke
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  [ 3 Posts ]
Jump to:   


Style:  
Search: