Controls in QBasic

I want to know how do you get an object such as a | to move in a QBasic program.

Comments

  • : I want to know how do you get an object such as a | to move in a QBasic program.
    :

    Where should it move and how do you want to move it ? (mouse, keys)
  • : : I want to know how do you get an object such as a | to move in a QBasic program.
    : :
    :
    : Where should it move and how do you want to move it ? (mouse, keys)
    :
    i want to move it up and down with the arrow keys
  • Think of the screen as a grid of text. The grid is different sizes in different screen modes. I'll use screen 0 in this message - It's something like 80 across and 23 or so down.

    If you think about the limits of where you could put any text, the farthest to the left is column (columns run up and down) 1 of each row. The furthest down you can place text is the last row. For the heck of it, we'll only go up to 20 for now. So, we'll make 20 the "bottom" limit. Text can be placed, and move around, anywhere between those limits.

    So, therefore, we want a program that does this:

    wait for some input from the keyboard
    make sure the user isn't trying to move outside the limits
    move the text (change some variables)
    draw the text
    loop

    we'll use inkey$ to get the keyboard input. when a key is hit, it's automatically recorded. you can look at the last key inputted by looking at the value of the variable inkey$. For example, if you hit X, inkey then cotains X. If you hit 3, inkey then contains 3. Special keys don't work quite the same because they have special codes: when you hit an arrow key, for example, inkey$ will contain: ascii character 0 + a letter.

    here's the "codes" to the arrow keys, writting QB style:
    up - chr$(0) + "H"
    down - chr$(0) + "P"
    left - chr$(0) + "K"
    right - chr$(0) + "M"

    so, that's how the input will work. as for showing the text, it's only a matter of LOCATE, PRINT, and storing stuff in variables.

    I'll post code later; maybe this helped a little though.


    : : : I want to know how do you get an object such as a | to move in a QBasic program.
    : : :
    : :
    : : Where should it move and how do you want to move it ? (mouse, keys)
    : :
    : i want to move it up and down with the arrow keys
    :

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