Qbasicnews.com
Wonky mouse control - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: Qbasic "like" compilers/interpreters (http://qbasicnews.com/newforum/forum-5.html)
+--- Forum: FB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-15.html)
+--- Thread: Wonky mouse control (/thread-9214.html)



Wonky mouse control - Zack - 04-25-2006

Is there something I'm missing here? This is supposed to operate so that you click somewhere, a dot is set there, and then you click somewhere else and a line is drawn between the two points. Sometimes the line is drawn, sometimes it isn't, and sometimes it's drawn in seemingly weird places.
Code:
screenres 320,200
setmouse 160,100
do until inkey$=chr$(27)
    getmouse mousex,mousey,,mb
    if mb then
        pset (mousex,mousey),2
        do
            getmouse mousex2,mousey2,,mb2
            if mb2 then exit do
        loop
        line (mousex,mousey)-(mousex2,mousey2),2
    end if
loop

[EDIT]Alright, there is something seriously wrong.
Code:
screenres 320,200,8,2,1
sleep
That code doesn't work. It initializes 320,200, but it ain't fullscreen. :o


Wonky mouse control - Antoni Gual - 04-26-2006

Zack:

Code:
dim mousex, mousey,mousex2,mousey2,mb,mb2,x,y
screenres 320,200
setmouse 160,100
do until inkey$=chr$(27)
    getmouse mousex,mousey,,mb
    if mb=1 then
        pset (mousex,mousey),2
        do:getmouse x,y,,mb:loop until mb=0

        do
            getmouse mousex2,mousey2,,mb2
            if mb2=1 then exit do
        loop
        line (mousex,mousey)-(mousex2,mousey2),2
        do:getmouse x,y,,mb:loop until mb=0
    end if
loop

-Mouse button presses last long, you have to wait for its release or they will propagate to your next reads.

-Freebasic sets mouse buttons to -1 if you click them out of the window. At that moment x and y are -1 too, so to avoid lines starting and ending at -1,-1, check for thhe real value of the left click, that's 1

-In FB for Windows 320 x 200 is a SVGA mode, most modern cards does'nt support resolutions that low in SVGA. Check SCREENLIST to see if it's supported.

BTW: Did you finished your trike?


Wonky mouse control - Zack - 04-26-2006

Thanks Antoni, I didn't know that. It works now.

And...um, trike? I wasn't building a trike...?


Wonky mouse control - KiZ - 04-26-2006

Quote:And...um, trike? I wasn't building a trike...?

http://forum.qbasicnews.com/viewtopic.php?p=84062#84062


*smacks* :P


Wonky mouse control - Antoni Gual - 04-26-2006

It did'nt go far, I see Big Grin


Wonky mouse control - Zack - 04-26-2006

Oh, that. I call it a go-kart, not a trike. Big Grin
I never ended up building it. Not enough cash. Sad