Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: DrewPee on August 28, 2006

Title: Inkey$
Post by: DrewPee on August 28, 2006
Hello guys,
Just a small one here . . . ive written some code that uses the code that MrP did - the Inline ASM bit!
I have used it to draw a graphic on the screen and i want to be able to move it left and right using Z for left and X for right . . .
Ive tried using inkey$ but it only seems to pick up one key! Don't know if im making myself clear, i will attach the code.
basically i want to move my graphic left and right using keys and it dont work at the mo . . .
Please help

Regards
DrewPee
Title: Re: Inkey$
Post by: Clyde on August 28, 2006
Here you go mate this is kind of how I do things with key input except I use Chr(num). This should be easier enough to follow, and hope it's of some use to you matey.


Dim Key As String
Dim Running=0

While Running<>1
   
    for y = 0 to 7
        for x = 0 to 15
            if cannon(tot)=1 then col=255 else col=0
            put_pixel(acx+x, 466+y, rgb(0, col,0))
            tot=tot+1
            locate 2,2:print key
       
        next x
    next y

    tot=0
    screensync
    flip
   
    if key="Z" or Key="z" then acx=acx-3
    if key="X" or Key="x" then acx=acx+3
    if key="Q" or Key="q" then Running=1
   
    Key=Inkey() 'Flush / Empty keybuffer
   
Wend

end


Cheers,
Clyde.
Title: Re: Inkey$
Post by: DrewPee on August 28, 2006
Thanks for that Clyde, very much appreciated - works like a dream.

Regards
DrewPee
Title: Re: Inkey$
Post by: Clyde on August 28, 2006
No probs dude :)

All the best with your creations bud,
Clyde.