Howdy, Stranger!

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

Categories

Controls in QBasic

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

Comments

  • PrzemekG_PrzemekG_ Member Posts: 595
    : 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)
  • stupidgeekstupidgeek Member Posts: 9
    : : 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
  • billywm664billywm664 Member Posts: 176
    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
    :

  • Andre YoungAndre Young USAMember Posts: 0

    _____ // http://forcoder.org // free ebooks and video tutorials about ( Swift, Go, C, Assembly, Ruby, Visual Basic, MATLAB, PL/SQL, Visual Basic .NET, R, JavaScript, PHP, C#, Java, C++, Perl, Python, Objective-C, Scratch, Delphi FoxPro, Ada, D, Alice, Prolog, Transact-SQL, F#, Kotlin, SAS, Rust, Clojure, Julia, Dart, COBOL, Scheme, Apex, Erlang, Hack, Lua, Logo, Scala, Awk, ML, Crystal, LabVIEW, Bash, ABAP, VBScript, Lisp, Fortran ) _____

Sign In or Register to comment.