Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Another Mouse Issue?
#1
I'm working on a game, see, and I don't want the player to be able to hold down the fire-button indefinitely (that's cheating!). So I tried setting up a timer that kills the left mouse button after a second and a half. All is cool if the mouse is stationary, but the minute you move the mouse the button resets itself - without the user letting the button up - not cool. Is this a Mac mouse issue, a QB64PE mouse issue or a dumb NakedApe issue?
Is there a better way to do this?     Huh  

Thanks in advance for any insights, Ted

DIM AS _BYTE leftClick, started
DIM startTime AS LONG
SCREEN _NEWIMAGE(800, 600, 32)

DO
    WHILE _MOUSEINPUT
        leftClick = _MOUSEBUTTON(1) '
        mouseX = _MOUSEX
        mouseY = _MOUSEY
    WEND

    IF leftClick THEN

        IF NOT started THEN startTime = TIMER: started = -1

        IF TIMER - startTime > 1.5 THEN '    no holding the button down forever!
            leftClick = 0 '                              kill left click
            started = 0 '                                reset timer
            SOUND 1000, .7 '                         pip
        END IF

        _PRINTSTRING (380, 280), "Button Down"
        _PRINTSTRING (380, 320), STR$(TIMER - startTime)
    END IF

    IF NOT leftClick THEN '                            if buttonUP then reset timer and erase
        CLS
        started = 0
    END IF

LOOP UNTIL _KEYDOWN(27)
SYSTEM
Reply


Messages In This Thread
Another Mouse Issue? - by NakedApe - 04-25-2024, 12:54 AM
RE: Another Mouse Issue? - by SMcNeill - 04-25-2024, 01:06 AM
RE: Another Mouse Issue? - by TerryRitchie - 04-25-2024, 01:40 AM
RE: Another Mouse Issue? - by NakedApe - 05-01-2024, 11:42 PM
RE: Another Mouse Issue? - by SMcNeill - 05-02-2024, 12:23 AM
RE: Another Mouse Issue? - by Pete - 04-25-2024, 01:27 AM
RE: Another Mouse Issue? - by bplus - 04-25-2024, 01:42 AM
RE: Another Mouse Issue? - by TerryRitchie - 04-25-2024, 02:08 AM
RE: Another Mouse Issue? - by NakedApe - 04-25-2024, 02:16 AM
RE: Another Mouse Issue? - by TerryRitchie - 04-25-2024, 05:33 AM
RE: Another Mouse Issue? - by a740g - 04-26-2024, 02:23 AM
RE: Another Mouse Issue? - by bplus - 04-25-2024, 11:50 AM
RE: Another Mouse Issue? - by NakedApe - 04-25-2024, 04:11 PM
RE: Another Mouse Issue? - by TerryRitchie - 04-25-2024, 05:43 PM
RE: Another Mouse Issue? - by NakedApe - 04-26-2024, 06:19 AM
RE: Another Mouse Issue? - by TerryRitchie - 05-02-2024, 12:31 AM
RE: Another Mouse Issue? - by SMcNeill - 05-02-2024, 12:31 AM
RE: Another Mouse Issue? - by NakedApe - 05-02-2024, 03:16 AM



Users browsing this thread: 2 Guest(s)