• Please review our updated Terms and Rules here

Mouse Training Game... for my 4 year old...

JDT

Veteran Member
Joined
Feb 17, 2007
Messages
564
Location
Cicero, NY
I am currently writing a small "game" that in its current stage exhibits a graphical issue in the that when I call a clear screen, any artifacts behind the mouse cursor do not get wiped... ideas? Final version will include timed games, different sized targets, different colored targets for using different mouse buttons.. etc.. just something Im writing in my rare down time. Any help / advice apreciated.

Code below, using quick basic 4.5
*********** begin code ****************


DECLARE FUNCTION MouseInit% ()
DECLARE SUB MouseStatus (LB%, RB%, xMouse%, yMouse%)
DECLARE SUB MouseRange (X1%, Y1%, x2%, Y2%)
DECLARE SUB MousePut (X%, Y%)
DECLARE SUB MouseHide ()
DECLARE SUB MouseDriver (ax%, bx%, cx%, dx%)
DECLARE SUB MouseShow ()
DEFINT A-Z: DEF SEG = &HA000:
DIM SHARED mouse$: mouse$ = SPACE$(57)
RANDOMIZE TIMER
CLS
SCREEN 12
FOR I% = 1 TO 57: READ A$: H$ = CHR$(VAL("&H" + A$))
MID$(mouse$, I%, 1) = H$: NEXT I%
DATA 55,89,E5,8B,5E,0C,8B,07,50,8B,5E,0A,8B,07,50,8B
DATA 5E,08,8B,0F,8B,5E,06,8B,17,5B,58,1E,07,CD,33,53
DATA 8B,5E,0C,89,07,58,8B,5E,0A,89,07,8B,5E,08,89,0F
DATA 8B,5E,06,89,17,5D,CA,08,00
RESTORE
ms% = MouseInit%
IF NOT ms% THEN
PRINT "Mouse not found"
END
END IF


LOCATE 2, 30
PRINT "Mouse Control Game"
MouseShow
MouseRange 0, 0, 635, 475
C = 0
SCORE = 0
CR = 25
A = 9000

R:
LR = 0
CIRCLE (XC, YC), CR, LR
CIRCLE (XC, YC), CR - (CR / 4), LR
CIRCLE (XC, YC), (CR / 2), LR
LINE (XC - 10, YC)-(XC + 10, YC), LR
LINE (XC, YC - 10)-(XC, YC + 10), LR

CLS
CCLB = 0
CCRB = 0
LR = INT(RND * 2) + 1
IF LR = 1 THEN COLOR 2
IF LR = 2 THEN COLOR 4
XC = INT(RND * 600) + 1
YC = INT(RND * 440) + 1
CIRCLE (XC, YC), CR, LR
CIRCLE (XC, YC), CR - (CR / 4), LR
CIRCLE (XC, YC), (CR / 2), LR
LINE (XC - 10, YC)-(XC + 10, YC), LR
LINE (XC, YC - 10)-(XC, YC + 10), LR





MISSED:
DO
MouseStatus LB, RB, X, Y
SELECT CASE LB%
CASE -1: REM SOUND 700, .1
GOTO CCLB:
END SELECT
SELECT CASE RB%
CASE -1: REM SOUND 500, .1
GOTO CCLB
END SELECT
REM LOCATE 1, 1: PRINT LB, RB, X, Y
LOCATE 1, 1: PRINT "SCORE:"; SCORE
LOOP
CCLB:
IF X > (XC + 10) OR X < (XC - 10) THEN GOTO MISS:
IF Y > (YC + 10) OR Y < (YC - 10) THEN GOTO MISS:
SOUND 900, .1
SOUND 900, .1
SOUND 1500, .3
SCORE = SCORE + 1
GOTO R:
MISS:
SOUND 200, .1
GOTO MISSED


REM MOUSE SUBS BELOW

DEFLNG A-Z
SUB MouseDriver (ax%, bx%, cx%, dx%)
DEF SEG = VARSEG(mouse$)
mouse% = SADD(mouse$)
CALL Absolute(ax%, bx%, cx%, dx%, mouse%)
END SUB

SUB MouseHide
ax% = 2
MouseDriver ax%, 0, 0, 0
END SUB

FUNCTION MouseInit%
ax% = 0
MouseDriver ax%, 0, 0, 0
MouseInit% = ax%
END FUNCTION

SUB MousePut (X%, Y%)
ax% = 4
cx% = X%
dx% = Y%
MouseDriver ax%, 0, cx%, dx%
END SUB

SUB MouseRange (X1%, Y1%, x2%, Y2%)
ax% = 7
cx% = X1%
dx% = x2%
MouseDriver ax%, 0, cx%, dx%
ax% = 8
cx% = Y1%
dx% = Y2%
MouseDriver ax%, 0, cx%, dx%
END SUB

SUB MouseShow
ax% = 1
MouseDriver ax%, 0, 0, 0
END SUB

SUB MouseStatus (LB%, RB%, xMouse%, yMouse%)
ax% = 3
MouseDriver ax%, bx%, cx%, dx%
LB% = ((bx% AND 1) <> 0)
RB% = ((bx% AND 2) <> 0)
xMouse% = cx%
yMouse% = dx%
END SUB



*********** end code ****************
 
Hm.. very interesting. Probably more advanced code than I ever got into in QB but my best guess is making using GET/PUT to grab the graphic behind the mouse, clear the screen then put it back. I don't recall how robust it is though and somewhat recall it only supporting square a,b,c,d for the border to grab. Can't remember if it could ignore a color which I kinda doubt. It may work if you know the dimensions of the graphic, OR if you have them stored as a data set or bmp or file, etc you could maybe know what graphic it is by some measurement of the pixels or a color or something and then know to put it back where the mouse was after clearing the screen.

Those are my best guesses for now :eek:) Let us know how it goes.

- John
 
I never got into the mouse/graphics side of programming so I'm not much help. However, I did use Quickbasic. It takes me back seeing those old DECLARE SUBs again!
 
I am currently writing a small "game" that in its current stage exhibits a graphical issue in the that when I call a clear screen, any artifacts behind the mouse cursor do not get wiped...

That is because you must hide the mouse cursor before wiping, then unhide it afterwards. Otherwise the mouse driver will restore what was behind the mouse cursor as soon as the cursor moves. I see you have MouseHide defined below, but you are not actually calling it.
 
That is because you must hide the mouse cursor before wiping, then unhide it afterwards. Otherwise the mouse driver will restore what was behind the mouse cursor as soon as the cursor moves. I see you have MouseHide defined below, but you are not actually calling it.

o...m....g.... /smacks_head

thank you....
 
Nice. Eh..3 hours of sleep each day I completely read that wrong although I couldn't think of why you would clear the screen and keep an object that the mouse was hovering over anyway lol.

Funny bug to hit though. I never did that much graphics programming in QB. The stuff I did either drew itself more live (screen saver where computer just randomly doodles) or used menus and ascii (hex editor, memory editor stuff). Never got into mouse functions so that's cool I'll have to mess with it again sometime. I think I just did some joystick programming while finding the polling of inkey to be too unreliable for gaming and the assembly code to do an interrupt when a key is pressed to be too disruptive for gaming (instead of the computer running circles around you, you'd interrupt it and run circles around it lol).

I still remember my dad writing a happy birthday program on our Zenith when I was a kid and we were going through some treasure hunt game at the house with my friends. A 5.25" disk with a santaclause label on it was found with a clue to try it on the computer. Some animations and birthday music and the next clue were in the basic program which of course was automatically run from autoexec.bat or go.bat or something he always added on our game disks for us kids.

Ss little as it may seem, some of that stuff goes remembered for a long time to a kid. So good for you :eek:)
 
yup trixter is right. i found that out the hard way many many years ago when i first started messing with mouse driver calls in QB.

hide then unhide, and problem should be resolved.
 
Back
Top