Click here to LOGIN
Information
Tutorials & Articles
Programs
Feedback
 


Forum
Add a Post
Username:   (You must log on to use your member username)Hint: Use [code] and [/code] around text to highlight it as QB code.


Subject:
Message:
Forums -> Q & A -> keyboard mouse support
Qbasicfreak
keyboard mouse support
Posted Mar 04 2009
I'm trying to make a mouse that functiones like the mouse in qbasic except it is controlled using the keyboard. I originally used a character but I had to refresh the screen everytime the mouse moved. Is there anyway to make the mouse be a spot of different color, so when the mouse is over something it only chages the color of the object instead of completely replacing it with a different character...

thanks
qbasicfreak
burger2227
HUH? I'm confused
Posted Mar 04 2009
So let's say you just move an object(Character) using arrow keys or WASD. What is the object? Is something already on the background?

The arrow or other keys can use graphical coordinates to move any shape around. Such as the center of a circle. If you have a background, you can GET the area of the next move, and move the circle. When moved again, replace old position using PUT, GET next and repeat. This would also work without a background so that it constantly erases the old circle when done correctly. NO CLS or redoing the entire BG.

That is exactly what a mouse arrow does invisibly. In fact, if you print over the arrow, a part will disappear from the BG. The arrow is color attribute 15 so you can change the RGB values for other arrow colors.


Qbasicfreak
Here is the code I'm using now...
Posted Mar 05 2009


 = chr$(24)


CLS
b = 1 'DOWN
c = 1'OVER
LOCATE b, c: PRINT ""

DO
  a$ = INKEY$
  SELECT CASE RIGHT$(a$, 1)
    CASE "H" 'up
      IF b = 1 THEN
      ELSE
        CLS
        b = b - 1
        LOCATE b, c: PRINT ""
      END IF
    CASE "P" 'down
      IF b = 23 THEN
      ELSE
        CLS
        b = b + 1
        LOCATE b, c: PRINT ""
      END IF
    CASE "K" 'left
      IF c = 1 THEN
      ELSE
        CLS
        c = c - 1
        LOCATE b, c: PRINT ""
      END IF
    CASE "M" 'right
      IF c = 80 THEN
      ELSE
        CLS
        c = c + 1
        LOCATE b, c: PRINT ""
      END IF
    CASE CHR$(13)
      IF b = 3 AND c = 3 THEN
      END
      ELSE
      END IF

  END SELECT

LOOP

'left = k
'right = m


burger2227
Try using True IF statements
Posted Mar 05 2009
CASE "H": IF row > 1 THEN row = row - 1
CASE "P": IF row < 25 THEN row = row + 1

To take care of the rolling rows 24 and 25:
PRINT ""; 'semicolon ends cursor move to next line.

Instead of CLS, save the previous row and column positions and print a space there.

Prow = row: Pcol = col

You could also use a multikey routine for diagonal moves.
Qbasicfreak
tried...
Posted Mar 11 2009
I've been trying to find out how to use

get

and

put

to get the character from specific co-ordinates and then put them back when the "mouse" moves...

How do I do this???

Thanks
Qbasicfreak
burger2227
Read my tutorial demo in Member files
Posted Mar 12 2009
Q-Basics.zip download. Unzip to your QB folder.

Run Q-basics.BAT and look in Chapter 13.

burger2227
PS: since I cannot EDIT ....................JACK!
Posted Mar 12 2009
SCREEN 0 (default) cannot use GET and PUT. However, text characters without a background really does not need those functions.
SCREEN 12 characters are 8 X 16 and SCREEN 13 are 8 X 8
Qbasicfreak
Posted Mar 12 2009
Is there anyway to use screen 0 or use a command that is similar?

This is for QMunication. I just uploaded the code for the mouse. In the actual program there is a background....

Qbasicfreak
Posted Apr 01 2009
Is there a way to keep the same text size in screen 12 as there is in screen 0???

thanks
qbasicfreak
burger2227
Close but not exact
Posted Apr 02 2009
Using WIDTH columns, rows

SCREEN 0 (text only):
columns = 40 or 80
rows = 25, 43, or 50
Text block sizes = 8 X 8, 8 X 14, 9 X 14, 9 X 16

SCREEN 12 (text and graphics):
columns = 80
rows = 30 or 60
Text block sizes = 8 X 16 or 8 X 8

WIDTH does not affect graphics in SCREEN 12!

Ted
Qbasicfreak
Posted Apr 03 2009
thanks burger!!!

The QBasic Station, (C) Copyright 1997-2010