Wolf3D-Mac/InterMis.c

1 line
9.8 KiB
C
Raw Permalink Normal View History

#include "WolfDef.h" #include <string.h> #include <stdlib.h> extern Word NumberIndex; /* Hack for drawing numbers */ static LongWord BJTime; /* Time to draw BJ? */ static Word WhichBJ; /* Which BJ to show */ static LongWord Indexs[3]; /* Offsets to BJ's true shapes */ static Byte *BJPtr; /* Pointer to BJ's shapes */ static Word ParTime; /* Par time for level */ static LongWord BonusScore; /* Additional points */ #define BONUSX 353 #define BONUSY 103 #define TIMEX 353 #define TIMEWIDTH 36 #define TIMEY 140 #define TIMEY2 180 #define SCOREX 353 #define SCOREY 332 #define RATIOX 353 #define RATIOY 217 #define RATIOY2 253 #define RATIOY3 291 /********************************** Draw BJ if needed **********************************/ static Rect BJRect = {48,73,48+142,73+131}; /* Rect for BJ's picture */ static void ShowBJ(void) { if ((ReadTick()-BJTime) >= 20) { /* Time to draw a BJ? */ BJTime = ReadTick(); /* Set the new time */ if (WhichBJ!=2) { /* Thumbs up? */ WhichBJ ^= 1; /* Nope, toggle breathing */ } DrawShape(73,48,&BJPtr[Indexs[WhichBJ]]); /* Draw BJ */ BlastScreen2(&BJRect); /* Update video */ } } /********************************** Have BJ Breath for a while **********************************/ static void BJBreath(Word Delay) { do { ShowBJ(); if (WaitTicksEvent(1)) { break; } } while (--Delay); } /********************************** Draw the score **********************************/ static Rect ScoreRect = {SCOREY,SCOREX,SCOREY+22,SCOREX+(12*7)}; static void DrawIScore(void) { SetNumber(gamestate.score,SCOREX,SCOREY,7); /* Draw the game score */ BlastScreen2(&ScoreRect); } /********************************** Draw the earned bonus **********************************/ static Rect BonusRect = {BONUSY,BONUSX,BONUSY+22,BONUSX+(12*7)}; static void DrawIBonus(void) { SetNumber(BonusScore,BONUSX,BONUSY,7); BlastScreen2(&BonusRect); } /********************************** Draw a time value at the given coords **********************************/ static void DrawTime(Word x,Word y,Word time) { Word minutes,seconds; Rect TimeRect; TimeRect.left = x; TimeRect.right = x+((12*4)+TIMEWIDTH); TimeRect.top = y; TimeRect.bottom = y+22; minutes = time/60; seconds = time%60; SetNumber(minutes,x,y,2); x+=TIMEWIDTH; SetNumber(seconds,x,y,2); BlastScreen2(&TimeRect); } /********************************** Draws a ratio value at the given coords. **********************************/ static void DrawRatio(Word x,Word y,Word theRatio) { Rect RatioRect; RatioRect.top = y; RatioRect.left = x; RatioRect.bottom = y+22; RatioRect.right = x+(3*12); SetNumber(theRatio,x,y,3); BlastScreen2(&RatioRect); } /********************************** RollScore Do a Bill-Budgey roll of the old score to the new score, not bothering with the lower digit, as you never get less than ten for anything. **********************************/ static void RollScore(void) { Word i; do { if (BonusScore>1000) { i = 1000; } else { i = BonusScore; } BonusScore-=i; GivePoints(i); ShowBJ(); DrawIScore(); DrawIBonus(); PlaySound(SND_MGUN|0x8000); if (WaitTicksEvent(6)) { GivePoints(BonusScore); /* Add the final bonus */ BonusScore=0; DrawIScore(); DrawIBonus(); break; } } while (BonusScore); } /********************************** RollRatio Do a Bill-Budgey roll of the ratio. **********************************/ static void RollRatio(Word x,Word y,Word ratio) { Word i; Word NoDelay; i = 0; NoDelay = 0; while (i<ratio) { DrawRatio(x,y,i); PlaySound(SND_MGUN|0x8000); ShowBJ(); if (WaitTicksEvent(6)) { NoDelay = 1; break; } i+=10; } DrawRatio(x,y,ratio); /* make ding sound */ if (ratio==100) { if (!NoDelay) { PlaySound(SND_EXTRA); WaitTicks(30); } BonusScore += 10000; DrawIBonus(); if (!NoDelay) { BJBreath(60); /* Breath a little */ } } } /********************************** Let's show 'em how they did! **********************************/ void LevelCompleted (voi