home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-06-12 | 2.3 KB | 104 lines | [TEXT/KAHL] |
- ///--------------------------------------------------------------------------------------
- // GameUtils.c
- //
- // Created: 9/19/90
- // By: Tony Myles
- //
- // Copyright: © 1990-93 Tony Myles, All rights reserved worldwide
- //
- // Description: some utility functions for games
- ///--------------------------------------------------------------------------------------
-
-
- #ifndef __QUICKDRAW__
- #include <QuickDraw.h>
- #endif
-
- #ifndef __GAMEUTILS__
- #include "GameUtils.h"
- #endif
-
-
- ///--------------------------------------------------------------------------------------
- // GetRandom
- //
- // generate a random number between min and max inclusive
- ///--------------------------------------------------------------------------------------
-
- unsigned short GetRandom(
- unsigned short min,
- unsigned short max)
- {
- unsigned short random;
- long range, temp;
-
- random = Random();
- range = (max - min) + 1;
- temp = (random * range) / 65536;
- random = temp + min;
-
- return random;
- }
-
-
- /*
- // globals for the menubar showing/hiding stuff
- */
- RgnHandle gOldVisRgn = NULL;
-
-
- ///--------------------------------------------------------------------------------------
- // HideMenuBar
- ///--------------------------------------------------------------------------------------
-
- void HideMenuBar(
- GrafPtr grafPort)
- {
- RgnHandle newVisRgn, junkRgn;
- GrafPtr savePort;
-
- GetPort(&savePort);
- SetPort(grafPort);
-
- // save off vis region
- gOldVisRgn = NewRgn();
- CopyRgn(grafPort->visRgn, gOldVisRgn);
-
- // expand the vis region to the port rect
- newVisRgn = NewRgn();
- RectRgn(newVisRgn, &grafPort->portRect);
- CopyRgn(newVisRgn, grafPort->visRgn);
-
- SetPort(savePort);
- }
-
-
- ///--------------------------------------------------------------------------------------
- // ShowMenuBar
- ///--------------------------------------------------------------------------------------
-
- void ShowMenuBar(
- GrafPtr grafPort)
- {
- RgnHandle junkRgn;
- GrafPtr savePort;
-
- GetPort(&savePort);
- SetPort(grafPort);
-
- // fill the rounded corners of the screen with black again
- junkRgn = NewRgn();
- CopyRgn(gOldVisRgn, junkRgn);
- DiffRgn(grafPort->visRgn, junkRgn, junkRgn);
- FillRgn(junkRgn, qd.black);
- DisposeRgn(junkRgn);
-
- // restore the old vis region
- CopyRgn(gOldVisRgn, grafPort->visRgn);
- DisposeRgn(gOldVisRgn);
- gOldVisRgn = NULL;
-
- DrawMenuBar();
- }
-
-