Author Topic: get mouse x, y at START of mouse movement  (Read 2137 times)

0 Members and 1 Guest are viewing this topic.

Offline NOVARSEG

  • Forum Resident
  • Posts: 509
    • View Profile
get mouse x, y at START of mouse movement
« on: January 10, 2021, 12:23:00 am »


 It would be nice if mouse x, y was returned  at the start of mouse movement - not after the mouse stops moving.

some example code which clears the mouse buffer but wastes time in doing so.
****
DO WHILE _MOUSEINPUT: LOOP ' Clear mouse buffer.
 
    DO
 
        x0 = _MOUSEX
        y0 = _MOUSEY

loop
« Last Edit: January 10, 2021, 12:26:55 am by NOVARSEG »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: get mouse x, y at START of mouse movement
« Reply #1 on: January 10, 2021, 12:29:56 am »
Are you looking for something like this, with the drag feature?  https://www.qb64.org/forum/index.php?topic=3380.0
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Pete

  • Forum Resident
  • Posts: 2361
  • Cuz I sez so, varmint!
    • View Profile
Re: get mouse x, y at START of mouse movement
« Reply #2 on: January 10, 2021, 08:59:05 am »
To echo what Steve said, are you needing any help with using the existing mouse statements?

Example of button and drag. Code allows a click to be registered (high pitch sound) and not performed again until the button is released (lower pitched sound). When the button is held down and the mouse is moved (drag), it will draw asterisk characters across the screen until the movement is stopped or the button is released.

Code: QB64: [Select]
  1. LOCATE , , 1, 7, 30
  2.     IF INKEY$ = CHR$(27) THEN SYSTEM
  3.     mx% = _MOUSEX
  4.     my% = _MOUSEY
  5.     mb.l% = _MOUSEBUTTON(1)
  6.     IF mb.l% THEN
  7.         IF NOT lbuttondown% THEN
  8.             lbuttondown% = -1
  9.             SOUND 1000, .1
  10.         END IF
  11.     ELSE
  12.         IF lbuttondown% THEN
  13.             lbuttondown% = 0
  14.             SOUND 500, .1
  15.         END IF
  16.     END IF
  17.     IF lbuttondown% THEN
  18.         IF oldmx% AND oldmx% <> mx% OR oldmy% AND oldmy% <> my% THEN
  19.             PRINT "*";: LOCATE , POS(0) - 1
  20.         END IF
  21.     END IF
  22.     IF my% THEN LOCATE my%, mx%: oldmx% = mx%: oldmy% = my%
  23.  

Pete
Want to learn how to write code on cave walls? https://www.tapatalk.com/groups/qbasic/qbasic-f1/