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

Username:   Password: 
 RegisterRegister   
 Can u turn off Input.KeyDown?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
bgmrk




PostPosted: Fri Jan 27, 2006 1:16 am   Post subject: Can u turn off Input.KeyDown?

I have a problem with a prgram i;m making... i have a part where the person picks the colour of there cirlce...i gave up suing buttons cause it just wasn't working out... so now i;m using Key Down... however both the player keydown is interfering with each other.. i have them in diff loops but it still dosen;t show up properly. help plz here's the code
code:
var charwindow : int := Window.Open ("graphics:350;300,position:center;center,nobuttonbar")
var chars :array char of boolean
var col1, col2 : int :=1
colourback (green)
cls
%%%character choice
%player 1
locate (1, 18)
put "PLAYER 1"
locate (3, 1)
put "Please type the letter that represents the colour you want"
locate (6, 1)
put "green - g"
put "red - r"
put "yellow - y"
put "blue - b"
put "black - l"
put "pink - p"
put "press enter when done."
Font.Draw ("Example", 250, 200, defFontID, black)
loop
    Input.KeyDown (chars)
    if chars ('g') then
        col1 := 2
    elsif chars ('r') then
        col1 := 40
    elsif chars ('y') then
        col1 := 14
    elsif chars ('b') then
        col1 := 9
    elsif chars ('l') then
        col1 := 7
    elsif chars ('p') then
        col1 := 8
    end if
    exit when chars (KEY_ENTER)
    Draw.FillOval (275, 160, 30, 30, col1)
end loop
%player 2
View.Update
cls
locate (1, 18)
put "PLAYER 2"
locate (3, 1)
put "Please type the letter that represents the colour you want"
locate (6, 1)
put "green - g"
put "red - r"
put "yellow - y"
put "blue - b"
put "black - l"
put "pink - p"
put "press shift when done."
Font.Draw ("Example", 250, 200, defFontID, black)
loop
    Input.KeyDown (chars)
    if chars ('g') then
        col2 := 2
    elsif chars ('r') then
        col2 := 40
    elsif chars ('y') then
        col2 := 14
    elsif chars ('b') then
        col2 := 9
    elsif chars ('l') then
        col2 := 7
    elsif chars ('p') then
        col2 := 8
    elsif chars (KEY_ENTER) then
        cls
    end if
    exit when chars (KEY_SHIFT)
    Draw.FillOval (275, 160, 30, 30, col2)
end loop
%Window.Close (charwindow)
Sponsor
Sponsor
Sponsor
sponsor
Cervantes




PostPosted: Fri Jan 27, 2006 8:59 am   Post subject: (No subject)

I haven't run the code, but I've got a hunch that it's getting to the second loop and exitting it while enter is still pressed down (when you exit the first loop). You might want to add a delay in between the loops (after you display the instructions.)
bgmrk




PostPosted: Fri Jan 27, 2006 10:12 am   Post subject: (No subject)

thanx that helped... but now i ran into another prob....c my other post for help...whatdotcolour
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: