home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Games / SpriteFight 2002 v2.0a1 / SpriteSecretCodes.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-26  |  2.5 KB  |  83 lines  |  [TEXT/SPM ]

  1. /*******************************************************
  2. *** SpriteSecretCodes.c
  3. *** By: Stefan C. Sinclair
  4. *** Copyright © 1996 All Rights Reserved Worldwide.
  5. *** Some controlling routines to handle input of the secret codes. Kool, man!
  6. *******************************************************/
  7.  
  8. #include "SpriteSecretCodes.h"
  9.  
  10. char gSecretGameKeys[5] = "????";
  11.  
  12. extern Boolean gIsRunning, gQT, gSoundOff, gSoundMax, gSoundMegaMax, gSpeech;
  13. extern Boolean gSecretCode[kNumSecretCodes];
  14. extern CWindowPtr    gWindowP;
  15.  
  16. char gSecretCodeKeys[kNumSecretCodes][5] = 
  17.         {kPongCodeKey, kDoubleDamageCodeKey, kNoRegenerationCodeKey,
  18.          kNoProjectileCodeKey, kNoFatalityCodeKey, kDoubleTimeCodeKey,
  19.          kHighJumpCodeKey, kSuperJACodeKey, kFastProjectileCodeKey,
  20.          kSlowProjectileCodeKey, kSF2KCodeKey, kBGAnimationCodeKey,
  21.          kFGAnimationCodeKey, kNoBGMusicCodeKey};
  22.  
  23. void MainLoopCodeCheck(char key)
  24. {
  25.     OSErr    myErr;
  26.     short    i;
  27.     
  28.     gSecretGameKeys[0] = gSecretGameKeys[1];
  29.     gSecretGameKeys[1] = gSecretGameKeys[2];
  30.     gSecretGameKeys[2] = gSecretGameKeys[3];
  31.     gSecretGameKeys[3] = key;
  32.     c2pstr(gSecretGameKeys);
  33.     for(i=0; i<kNumSecretCodes; i++)
  34.     {
  35.         c2pstr(gSecretCodeKeys[i]);
  36.         // if it's already set, don't bother checking it again
  37.         if(!gSecretCode[i])
  38.         {
  39.             gSecretCode[i] = EqualString((StringPtr)gSecretGameKeys, \
  40.                 (StringPtr)gSecretCodeKeys[i],FALSE,FALSE);
  41.             if(gSecretCode[i])
  42.             { // a correct code has been entered!
  43.                 Handle    codeSoundH;
  44.             
  45.                 codeSoundH = Get1Resource('snd ', kSecretCodeSndID);
  46.                 if(codeSoundH == NULL)
  47.                     CantFindResource();
  48.                 HLock(codeSoundH);
  49.                 myErr = SndPlay( nil, (SndListHandle)codeSoundH, FALSE);
  50.                 HUnlock(codeSoundH);
  51.                 ReleaseResource(codeSoundH);
  52.                 // reset the key storage to jibberish - notice I start at 1 because the keys are
  53.                 // in Pascal style at this point! Tricky!
  54.                 gSecretGameKeys[1] = '?';
  55.                 gSecretGameKeys[2] = '?';
  56.                 gSecretGameKeys[3] = '?';
  57.                 gSecretGameKeys[4] = '?';
  58.             }
  59.         }
  60.         p2cstr((StringPtr)gSecretCodeKeys[i]);
  61.     }
  62.     p2cstr((StringPtr)gSecretGameKeys);
  63.     
  64.     // check for codes that demand immediate attention!
  65.     if(gSecretCode[kPongCode])
  66.     {
  67.         Str255 oldWTitle = "\p";
  68.         if(gSpeech && !gSoundOff)
  69.         {
  70.             myErr = SpeakString("\pYou have found the hidden pong game!");
  71.             while(SpeechBusy())
  72.                 ;
  73.             myErr = SpeakString("\pHappy Easter!");
  74.             while(SpeechBusy())
  75.                 ;
  76.         }
  77.         GetWTitle((WindowPtr)gWindowP, oldWTitle);
  78.         HiddenPongGame((WindowPtr)gWindowP);
  79.         SetWTitle((WindowPtr)gWindowP, oldWTitle);
  80.         // reset the code to "FALSE"
  81.         gSecretCode[kPongCode] = FALSE;
  82.     }
  83. }