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

Username:   Password: 
 RegisterRegister   
 soccer game shoot-out
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
kamil_360




PostPosted: Fri Dec 15, 2006 11:03 am   Post subject: soccer game shoot-out

i am having a problem incorperating the space bar into my program, i dont know the code for it. i am trying to make the space bar be the shoot botton. Can anyone give me a few pointers on how to incorperate the space bar.

code:
loop
    setscreen ("graphics:640;400")
    View.Set ("offscreenonly")
    var side : string
    var x : int := 310
    var y : int := 100
    var key: array char of boolean
   
    drawline (0, 61, maxx, 61, red)     %draws black entry space and instructions
    drawfillbox (0, 0, maxx, 60, black)
    locate (23, 1)
    put "Where Will You like to shoot!"
    locate (24, 1)
    put "Top right 'e' Top Middle 'w' Top Left 'q'"
    drawfillbox (0, 62, maxx, 260, green)     % this is setting up the field and sky
    drawfillbox (0, 260, maxx, 620, blue)
    drawline (160, 363, 480, 363, white)     %this creates the crossbar
    drawfillbox (160, 360, 480, 363, white)
    drawline (483, 240, 483, 363, white)     %this creates the posts
    drawline (157, 240, 157, 363, white)
    drawfillbox (157, 240, 160, 363, white)
    drawfillbox (483, 240, 480, 363, white)     % this builds the frame of the net
    drawline (160, 240, 480, 240, white)
    drawfillbox (160, 241, 480, 240, white)
    drawarc (320, 240, 160, 120, 180, 360, white)     %this is the arc around the net
    drawline (160, 239, 480, 239, red)
    drawline (160, 240, 180, 260, white)
    drawline (480, 240, 460, 260, white)
    drawline (180, 260, 460, 260, white)
    drawline (180, 260, 160, 360, white)
    drawline (460, 260, 480, 360, white)
    Draw.FillOval (x, y, 10, 10, white)
    Input.KeyDown (key)
    if key ('s') then
        y := 260
        Draw.FillOval (x, y, 10, 10, 90)
        locate(1,1)
        put " Aiming straight!"
        delay (5)
    end if
    Input.KeyDown (key)
    if key ('w') then
        y := 345
        Draw.FillOval (x, y, 10, 10, 90)
        locate(1,1)
        put" Aiming for the top of the net! "
        delay (5)
    end if
    Input.KeyDown (key)
    if key('q') then
        y := 345
        x := 175
        Draw.FillOval (x, y, 10, 10, 90)
        locate(1,1)
        put " Aiming for the top left corner of the net! "
        delay (5)
    end if
    Input.KeyDown (key)
    if key ('a') then
        y := 260
        x := 170
        Draw.FillOval (x, y, 10, 10, 90)
        locate(1,1)
        put " Aiming for the bottom left corner of the net! "
        delay (5)   
    end if
    Input.KeyDown (key)
    if key ('e') then
        y := 345
        x := 462
        Draw.FillOval (x, y, 10, 10, 90)
        locate(1,1)
        put " Aiming for the top right corner of the net! "
        delay (5)
        end if 
    Input.KeyDown (key)
    if key ('d') then
        y := 260
        x := 462
        Draw.FillOval (x, y, 10, 10, 90)
        locate(1,1)
        put " Aiming for the bottom right corner of the net! "
        delay (5)
    end if   
    View.Update
end loop
Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Fri Dec 15, 2006 1:38 pm   Post subject: (No subject)

your Input.KeyDown check needs to check for a space character (' ') in the if.
Prince Pwn




PostPosted: Fri Dec 15, 2006 8:04 pm   Post subject: (No subject)

You only need 1 "Input.KeyDown" in your program.
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: