seperate controls

Hello world
I'm making a game in QBasic with two bats (rectangles), it's for two players. When one person is holding a key it stops the other person from moving, is there any way round this?
I've used SELECT CASE and an INKEY statments if that's any help.
Ta

Comments

  • : Hello world
    : I'm making a game in QBasic with two bats (rectangles), it's for two players. When one person is holding a key it stops the other person from moving, is there any way round this?
    : I've used SELECT CASE and an INKEY statments if that's any help.
    : Ta
    :


  • : : Hello world
    : : I'm making a game in QBasic with two bats (rectangles), it's for two players. When one person is holding a key it stops the other person from moving, is there any way round this?
    : : I've used SELECT CASE and an INKEY statments if that's any help.
    : : Ta
    : :
    :
    :
    Can u expand on that?
    I don't know how to use ON KEY statments.

  • ...it can solve certain problems.
    First, you have to tell QB (well, I use QB) that you want to use ON KEY:

    KEY(0) on 'this activates the function keys
    Then you put:
    ON KEY(1) GOSUB FOOBAR 'for example - this is the F1 key.
    'KEY(2) is F2, etc.
    Now you have to write a GOSUB called FOOBAR (well, you don't actually HAVE to call it that) - you have to use GOSUB rather than a SUB or (heaven forbid) GOTO.

    FOOBAR: '<-here's the GOSUB
    put whatever code you want here
    RETURN 'don't forget the return

    You have to handle other keys individually - this is the nuisance part I mentioned. It's in HELP. There's no easier way than fiddling with it until you get how to do it.
    You can set up any key you want as a "user-defined" key, including multiple-keypresses (this is what will help most with your specific problem).
    The nice thing about ON KEY is that (unlike $INKEY), it acts like an interrupt, rather than having to poll the keyboard (that's what makes action jerky, etc., as the program has to wait till it encounters $INKEY statement - ON KEY will jump right out from anywhere).

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories