1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905
|
/*
* XBoing - An X11 blockout style computer game
*
* (c) Copyright 1993, 1994, 1995, Justin C. Kibell, All Rights Reserved
*
* The X Consortium, and any party obtaining a copy of these files from
* the X Consortium, directly or indirectly, is granted, free of charge, a
* full and unrestricted irrevocable, world-wide, paid up, royalty-free,
* nonexclusive right and license to deal in this software and
* documentation files (the "Software"), including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons who receive
* copies from any such party to do so. This license includes without
* limitation a license to do the foregoing actions under any patents of
* the party supplying this software to the X Consortium.
*
* In no event shall the author be liable to any party for direct, indirect,
* special, incidental, or consequential damages arising out of the use of
* this software and its documentation, even if the author has been advised
* of the possibility of such damage.
*
* The author specifically disclaims any warranties, including, but not limited
* to, the implied warranties of merchantability and fitness for a particular
* purpose. The software provided hereunder is on an "AS IS" basis, and the
* author has no obligation to provide maintenance, support, updates,
* enhancements, or modifications.
*/
/*
* =========================================================================
*
* $Id: bonus.c,v 1.1.1.1 1994/12/16 01:36:44 jck Exp $
* $Source: /usr5/legends/jck/xb/master/xboing/bonus.c,v $
* $Revision: 1.1.1.1 $
* $Date: 1994/12/16 01:36:44 $
*
* $Log: bonus.c,v $
* Revision 1.1.1.1 1994/12/16 01:36:44 jck
* The XBoing distribution requires configuration management. This is why the
* cvs utility is being used. This is the initial import of all source etc..
*
*
* =========================================================================
*/
/*
* Include file dependencies:
*/
#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xos.h>
#include <xpm.h>
#include "bitmaps/presents/titleSml.xpm"
#include "error.h"
#include "audio.h"
#include "highscore.h"
#include "misc.h"
#include "special.h"
#include "main.h"
#include "gun.h"
#include "init.h"
#include "file.h"
#include "dialogue.h"
#include "stage.h"
#include "blocks.h"
#include "sfx.h"
#include "ball.h"
#include "score.h"
#include "paddle.h"
#include "level.h"
#include "mess.h"
#include "intro.h"
#include "bonus.h"
/*
* Internal macro definitions:
*/
#define GAP 30
#define KEY_TYPE_VOL 50
#define LINE_DELAY 100
#define SAVE_LEVEL 5
#define BONUS_COIN_SCORE 3000
#define SUPER_BONUS_SCORE 50000
#define BULLET_SCORE 500
#define LEVEL_SCORE 100
#define TIME_BONUS 100
#define BORDER_LEFT 55
#define BORDER_RIGHT ((PLAY_WIDTH + MAIN_WIDTH) - 50)
#define BORDER_TOP 73
#define BORDER_BOTTOM ((PLAY_HEIGHT + MAIN_HEIGHT) - 85)
/*
* Internal type declarations:
*/
#if NeedFunctionPrototypes
static void DoBullets(Display *display, Window window);
static void DoTimeBonus(Display *display, Window window);
#else
static void DoTimeBonus();
static void DoBullets();
#endif
/*
* Internal variable declarations:
*/
static int numBonus;
enum BonusStates BonusState;
static Pixmap titlePixmap, titlePixmapM;
static int ypos;
static int waitingFrame;
enum BonusStates waitMode;
static char string[80];
static u_long bonusScore;
static int firstTime = True;
#if NeedFunctionPrototypes
void SetUpBonus(Display *display, Window window, Colormap colormap)
#else
void SetUpBonus(display, window, colormap)
Display *display;
Window window;
Colormap colormap;
#endif
{
XpmAttributes attributes;
int XpmErrorStatus;
attributes.valuemask = XpmColormap;
attributes.colormap = colormap;
/* Create the small title pixmap */
XpmErrorStatus = XpmCreatePixmapFromData(display, window, titleSmall_xpm,
&titlePixmap, &titlePixmapM, &attributes);
HandleXPMError(display, XpmErrorStatus, "InitialiseBonus()");
/* Free the xpm pixmap attributes */
XpmFreeAttributes(&attributes);
}
#if NeedFunctionPrototypes
void DecNumberBonus(void)
#else
void DecNumberBonus()
#endif
{
/* bump down the number of bonuses. sic */
numBonus--;
}
#if NeedFunctionPrototypes
void IncNumberBonus(void)
#else
void IncNumberBonus()
#endif
{
/* bump up the number of bonuses. sic */
numBonus++;
}
#if NeedFunctionPrototypes
int GetNumberBonus(void)
#else
int GetNumberBonus()
#endif
{
/* Umm - return the number of bonuses */
return numBonus;
}
#if NeedFunctionPrototypes
void ResetNumberBonus(void)
#else
void ResetNumberBonus()
#endif
{
/* No more bonuses thanks */
numBonus = 0;
}
#if NeedFunctionPrototypes
void DrawBallBorder(Display *display, Window window)
#else
void DrawBallBorder(display, window)
Display *display;
Window window;
#endif
{
int x, y;
static int slide = 0;
DEBUG("Drawing ball borders.")
/* Draw a row of balls along the top and bottom of screen */
for (x = BORDER_LEFT; x < BORDER_RIGHT; x += 22)
{
DrawTheBall(display, window, x, BORDER_TOP, slide);
DrawTheBall(display, window, x, BORDER_BOTTOM, slide);
/* Next frame of ball animation */
slide++;
/* Wrap around animation */
if (slide == BALL_SLIDES) slide = 0;
}
/* Draw a row of balls along both sides of the screen */
for (y = BORDER_TOP; y < BORDER_BOTTOM; y += 22)
{
DrawTheBall(display, window, BORDER_LEFT, y, slide);
DrawTheBall(display, window, BORDER_RIGHT, y, slide);
/* Next frame of ball animation */
slide++;
/* Wrap around animation */
if (slide == BALL_SLIDES) slide = 0;
}
}
#if NeedFunctionPrototypes
void DrawSmallIntroTitle(Display *display, Window window, int x, int y)
#else
void DrawSmallIntroTitle(display, window, x, y)
Display *display;
Window window;
int x;
int y;
#endif
{
DEBUG("Drawing small intro title.")
/* Draw the small title pixmap */
RenderShape(display, window, titlePixmap, titlePixmapM,
x - SMALL_TITLE_WC, y - SMALL_TITLE_HC,
SMALL_TITLE_WIDTH, SMALL_TITLE_HEIGHT, False);
}
#if NeedFunctionPrototypes
void SetupBonusScreen(Display *display, Window window)
#else
void SetupBonusScreen(display, window)
Display *display;
Window window;
#endif
{
/* Clear the background again */
ClearMainWindow(display, window);
/* Draw the rectangular border of balls */
DrawBallBorder(display, window);
/* Draw the main title pixmap */
DrawSmallIntroTitle(display, window, TOTAL_WIDTH / 2, 120);
/* The new state will be the text */
ResetBonus();
/* Remove the window to show bonus stuff */
while (WindowFadeEffect(display, playWindow, PLAY_WIDTH, PLAY_HEIGHT));
XUnmapWindow(display, playWindow);
XFlush(display);
}
#if NeedFunctionPrototypes
void DrawTitleText(Display *display, Window window)
#else
void DrawTitleText(display, window)
Display *display;
Window window;
#endif
{
SetCurrentMessage(display, messWindow, "- Bonus Tally -", True);
/* Indicate which level the bonus is for */
sprintf(string, "- Level %ld -", level);
DrawShadowCentredText(display, window, titleFont,
string, ypos, red, TOTAL_WIDTH);
ypos += (titleFont->ascent + GAP);
strcpy(string, "Press space for next level");
DrawShadowCentredText(display, window, textFont,
string, PLAY_HEIGHT - 12, tann, TOTAL_WIDTH);
/* Adjust the level so that the starting level is taken into account */
if ((((int) (level - (u_long) GetStartingLevel() + 1L)) % SAVE_LEVEL) == 0)
{
/* Toggle the saving of levels */
ToggleSaving(display, True);
DrawSpecials(display);
RenderShape(display, window,
floppy, floppyM, TOTAL_WIDTH - 100, PLAY_HEIGHT, 32, 32, False);
DEBUG("Saving activated.")
}
XFlush(display);
SetBonusWait(BONUS_SCORE, frame + 5);
SetGameSpeed(SLOW_SPEED);
DEBUG("set bonus mode to BONUS_SCORE.")
}
#if NeedFunctionPrototypes
static void DoScore(Display *display, Window window)
#else
static void DoScore(display, window)
Display *display;
Window window;
#endif
{
DEBUG("in function DoScore() in bonus.c")
SetGameSpeed(SLOW_SPEED);
/* Nice message rewarding you for your efforts */
strcpy(string, "Congratulations on finishing this level.");
DrawShadowCentredText(display, window, textFont,
string, ypos, white, TOTAL_WIDTH);
XFlush(display);
ypos += (35 + GAP);
SetBonusWait(BONUS_BONUS, frame + LINE_DELAY);
SetGameSpeed(SLOW_SPEED);
DEBUG("set bonus mode to BONUS_BONUS.")
}
#if NeedFunctionPrototypes
static void DoBonuses(Display *display, Window window)
#else
static void DoBonuses(display, window)
Display *display;
Window window;
#endif
{
int x, plen, secs;
static int maxLen;
/* Get the number of seconds left on the clock */
secs = GetLevelTimeBonus();
if (secs == 0)
{
/* Play the sound for the super bonus */
if (noSound == False) playSoundFile("Doh4", 80);
strcpy(string, "Bonus coins void - Timer ran out!");
DrawShadowCentredText(display, window, textFont,
string, ypos, blue, TOTAL_WIDTH);
SetGameSpeed(SLOW_SPEED);
/* Now skip to the next sequence */
SetBonusWait(BONUS_LEVEL, frame + LINE_DELAY);
firstTime = True;
ypos += (textFont->ascent + GAP * 2);
return;
}
if (firstTime)
{
/* Set up the bonus coin sequence */
firstTime = False;
if (numBonus == 0)
{
/* Play the sound for the super bonus */
if (noSound == False) playSoundFile("Doh1", 80);
/* No bonus coins - so tell user */
strcpy(string, "Sorry, no bonus coins collected.");
DrawShadowCentredText(display, window, textFont,
string, ypos, blue, TOTAL_WIDTH);
SetGameSpeed(SLOW_SPEED);
/* Now skip to the next sequence */
SetBonusWait(BONUS_LEVEL, frame + LINE_DELAY);
firstTime = True;
ypos += (textFont->ascent + GAP * 2);
return;
}
if (numBonus > MAX_BONUS)
{
/* Play the sound for the super bonus */
if (noSound == False) playSoundFile("supbons", 80);
/* More than 10 coins collected - super bonus reward */
sprintf(string, "Super Bonus - %ld",
ComputeScore(SUPER_BONUS_SCORE));
DrawShadowCentredText(display, window, titleFont,
string, ypos, blue, TOTAL_WIDTH);
/* Update the score with more points */
bonusScore += ComputeScore(SUPER_BONUS_SCORE);
DisplayScore(display, scoreWindow, bonusScore);
SetGameSpeed(SLOW_SPEED);
/* Now skip to the next sequence */
SetBonusWait(BONUS_LEVEL, frame + LINE_DELAY);
firstTime = True;
ypos += (textFont->ascent + GAP * 2);
return;
}
/* Calculate where to draw these coins centred */
maxLen = ((numBonus * 27) + (10 * numBonus) + 5);
}
/* Find out where the next bonus coin will go next */
plen = ((numBonus * 27) + (10 * numBonus));
x = (((PLAY_WIDTH + MAIN_WIDTH) / 2) + (maxLen / 2)) - plen;
/* Draw the bonus coin shape */
DrawTheBlock(display, window, x, ypos, BONUS_BLK, 0, 0, 0);
/* Play the sound for the bonus */
if (noSound == False)
playSoundFile("bonus", 50);
/* Increment the score by the value of the bonus */
bonusScore += ComputeScore(BONUS_COIN_SCORE);
DisplayScore(display, scoreWindow, bonusScore);
/* Reduce number of bonuses */
DecNumberBonus();
if (numBonus <= 0)
{
/* Set up bonus state for next sequence */
SetBonusWait(BONUS_LEVEL, frame + LINE_DELAY);
DEBUG("set bonus mode to BONUS_LEVEL.")
/* Make sure bonus is reset */
ResetNumberBonus();
ypos += (int) (textFont->ascent + GAP * 1.5);
firstTime = True;
SetGameSpeed(SLOW_SPEED);
}
}
#if NeedFunctionPrototypes
static void DoLevel(Display *display, Window window)
#else
static void DoLevel(display, window)
Display *display;
Window window;
#endif
{
int secs, theLevel;
SetGameSpeed(SLOW_SPEED);
/* Get the number of seconds left on the clock */
secs = GetLevelTimeBonus();
if (secs > 0)
{
/* Adjust the level so that the starting level is taken into account */
theLevel = (int) level - GetStartingLevel() + 1;
/* Draw level bonus text */
sprintf(string, "Level bonus - level %d x %ld = %ld points",
theLevel, ComputeScore(LEVEL_SCORE),
theLevel * ComputeScore(LEVEL_SCORE));
DrawShadowCentredText(display, window, textFont,
string, ypos, yellow, TOTAL_WIDTH);
/* Increment the score by the value of the level bonus */
bonusScore += ComputeScore((LEVEL_SCORE * theLevel));
DisplayScore(display, scoreWindow, bonusScore);
}
else
{
strcpy(string, "No level bonus - Timer ran out.");
DrawShadowCentredText(display, window, textFont,
string, ypos, yellow, TOTAL_WIDTH);
/* Play the sound for the super bonus */
if (noSound == False) playSoundFile("Doh2", 80);
}
/* Next section setup */
ypos += (int) (textFont->ascent + GAP * 1.5);
SetBonusWait(BONUS_BULLET, frame + LINE_DELAY);
DEBUG("set bonus mode to BONUS_BULLET.")
}
#if NeedFunctionPrototypes
static void DoBullets(Display *display, Window window)
#else
static void DoBullets(display, window)
Display *display;
Window window;
#endif
{
int x, plen;
static int maxLen;
if (firstTime)
{
/* For the first time setup the bullet bonus seq. */
firstTime = False;
SetUnlimitedBullets(False);
if (GetNumberBullets() == 0)
{
/* No bullets - say so */
strcpy(string, "You have used all your bullets. No bonus!");
DrawShadowCentredText(display, window, textFont,
string, ypos, blue, TOTAL_WIDTH);
/* Play the sound for the super bonus */
if (noSound == False) playSoundFile("Doh3", 80);
SetGameSpeed(SLOW_SPEED);
/* Get ready for the next sequence */
SetBonusWait(BONUS_TIME, frame + LINE_DELAY);
firstTime = True;
ypos += (textFont->ascent + GAP/2);
return;
}
/* Position where the first bullet will be drawn */
maxLen = ((GetNumberBullets() * 7) + (3 * GetNumberBullets()));
}
/* Find out where the next bonus bullet will go next */
plen = ((GetNumberBullets() * 7) + (3 * GetNumberBullets()));
x = (((PLAY_WIDTH + MAIN_WIDTH) / 2) + (maxLen / 2)) - plen;
DrawTheBullet(display, window, x, ypos);
/* Play the sound for the bullets */
if (noSound == False)
playSoundFile("key", 50);
/* Increment the score by the value of the bullet bonus */
bonusScore += ComputeScore(BULLET_SCORE);
DisplayScore(display, scoreWindow, bonusScore);
/* Ummm. Draw a bullet */
DeleteABullet(display);
if (GetNumberBullets() == 0)
{
/* Reset bullets and get ready for next sequence */
SetBonusWait(BONUS_TIME, frame + LINE_DELAY);
ypos += (textFont->ascent + GAP/2);
firstTime = True;
SetGameSpeed(SLOW_SPEED);
}
}
#if NeedFunctionPrototypes
static void DoTimeBonus(Display *display, Window window)
#else
static void DoTimeBonus(display, window)
Display *display;
Window window;
#endif
{
int secs = 0;
SetGameSpeed(SLOW_SPEED);
/* Get the number of seconds left on the clock */
secs = GetLevelTimeBonus();
if (secs > 0)
{
/* Draw time bonus text */
sprintf(string, "Time bonus - %d seconds x %ld = %ld points",
secs, ComputeScore(TIME_BONUS), secs * ComputeScore(TIME_BONUS));
DrawShadowCentredText(display, window, textFont,
string, ypos, yellow, TOTAL_WIDTH);
/* Increment the score by the value of the time bonus */
bonusScore += ComputeScore(TIME_BONUS * secs);
DisplayScore(display, scoreWindow, bonusScore);
}
else
{
/* Draw no time bonus text */
strcpy(string, "No time bonus - not quick enough!");
DrawShadowCentredText(display, window, textFont,
string, ypos, yellow, TOTAL_WIDTH);
/* Play the sound for the super bonus */
if (noSound == False) playSoundFile("Doh4", 80);
}
/* Next section setup */
ypos += (textFont->ascent + GAP/2);
SetBonusWait(BONUS_HSCORE, frame + LINE_DELAY);
}
#if NeedFunctionPrototypes
static void DoHighScore(Display *display, Window window)
#else
static void DoHighScore(display, window)
Display *display;
Window window;
#endif
{
int myrank = 0;
char str[5];
SetGameSpeed(SLOW_SPEED);
/* Obtain current ranking for this score */
myrank = GetHighScoreRanking(score);
if (myrank > 0)
{
/* Special case for first place */
if (myrank == 1)
sprintf(string, "You are ranked 1st. Well done!");
else
{
/* Add the correct grammer for the sentence */
switch (myrank)
{
case 1: strcpy(str, "st"); break;
case 2: strcpy(str, "nd"); break;
case 3: strcpy(str, "rd"); break;
case 4: case 5: case 6: case 7: case 8: case 9: case 10:
strcpy(str, "th");
break;
default: strcpy(str, ""); break;
}
/* Construct beautiful sentence */
sprintf(string, "You are currently ranked %d%s.",
myrank, str);
}
}
else
/* What a loser ;-) */
strcpy(string, "Keep on trying!");
/* Draw the text for the game ranking */
DrawShadowCentredText(display, window, textFont,
string, ypos, red, TOTAL_WIDTH);
ypos += (textFont->ascent + GAP/2);
SetBonusWait(BONUS_END_TEXT, frame + LINE_DELAY);
}
#if NeedFunctionPrototypes
static void DoEndText(Display *display, Window window)
#else
static void DoEndText(display, window)
Display *display;
Window window;
#endif
{
DEBUG("DoEndText in bonus screen.")
SetGameSpeed(SLOW_SPEED);
/* Finishing sentence - so you know what level to do */
sprintf(string, "Prepare for level %ld", level+1);
DrawShadowCentredText(display, window, textFont,
string, ypos, yellow, TOTAL_WIDTH);
XFlush(display);
if (noSound == False) playSoundFile("applause", 80);
SetBonusWait(BONUS_FINISH, frame + LINE_DELAY * 2);
}
#if NeedFunctionPrototypes
static void DoFinish(Display *display, Window window)
#else
static void DoFinish(display, window)
Display *display;
Window window;
#endif
{
DEBUG("DoFinish in bonus screen.")
/* Setup game window for the next level */
level++;
SetupStage(display, playWindow);
BonusState = BONUS_TEXT;
SetGameSpeed(FAST_SPEED);
mode = MODE_GAME;
XSetWindowBorder(display, playWindow, red);
XMapWindow(display, playWindow);
/* Only redraw if the server hasn't backing store on */
if (DoesBackingStore(XDefaultScreenOfDisplay(display)) != Always)
SelectiveRedraw(display);
}
#if NeedFunctionPrototypes
void SetBonusWait(enum BonusStates newMode, int waitFrame)
#else
void SetBonusWait(newMode, waitFrame)
enum BonusStates newMode;
int waitFrame;
#endif
{
waitingFrame = waitFrame;
waitMode = newMode;
BonusState = BONUS_WAIT;
}
#if NeedFunctionPrototypes
void DoBonusWait(void)
#else
void DoBonusWait()
#endif
{
/* Wait for the frame we want to come along - then change modes */
if (frame == waitingFrame)
BonusState = waitMode;
}
#if NeedFunctionPrototypes
void DoBonus(Display *display, Window window)
#else
void DoBonus(display, window)
Display *display;
Window window;
#endif
{
/* The states within the bonus mode */
switch (BonusState)
{
case BONUS_TEXT:
DEBUG("BONUS: DrawTitleText()")
DrawTitleText(display, window);
break;
case BONUS_SCORE:
DEBUG("BONUS: DoScore()")
DoScore(display, window);
break;
case BONUS_BONUS:
DEBUG("BONUS: DoBonuses()")
DoBonuses(display, window);
break;
case BONUS_LEVEL:
DEBUG("BONUS: DoLevel()")
DoLevel(display, window);
break;
case BONUS_BULLET:
DEBUG("BONUS: DoBullets()")
DoBullets(display, window);
break;
case BONUS_TIME:
DEBUG("BONUS: DoTimeBonus()")
DoTimeBonus(display, window);
break;
case BONUS_HSCORE:
DEBUG("BONUS: DoHighScore()")
DoHighScore(display, window);
break;
case BONUS_END_TEXT:
DEBUG("BONUS: DoEndText()")
DoEndText(display, window);
break;
case BONUS_FINISH:
DEBUG("BONUS: DoFinish()")
DoFinish(display, window);
break;
case BONUS_WAIT:
DoBonusWait();
break;
default:
break;
}
}
#if NeedFunctionPrototypes
void RedrawBonus(Display *display, Window window)
#else
void RedrawBonus(display, window)
Display *display;
Window window;
#endif
{
/* This will redraw the entire screen */
/* Took this out as some people were cheating!!! */
}
#if NeedFunctionPrototypes
void FreeBonus(Display *display)
#else
void FreeBonus(display)
Display *display;
#endif
{
/* Free all the hungry memory leaks */
if (titlePixmap) XFreePixmap(display, titlePixmap);
if (titlePixmapM) XFreePixmap(display, titlePixmapM);
}
#if NeedFunctionPrototypes
void ComputeAndAddBonusScore(void)
#else
void ComputeAndAddBonusScore()
#endif
{
/* This function will pre compute the bonus score and add it to the
* score. The bonus screen will only change the score by updating the
* score display and not the score value. This means the user can hit
* space and go to the next screen without delay. Cool.
*/
int secs = 0;
int theLevel = 0;
DEBUG("computing and adding bonus score.")
secs = GetLevelTimeBonus();
if (secs > 0)
{
/* Compute bonus coin bonus */
if (numBonus > MAX_BONUS)
{
/* More than MAX_BONUS bonus so give super bonus */
AddToScore((u_long) SUPER_BONUS_SCORE);
}
else
{
/* Less than MAX_BONUS so work out bonus score */
AddToScore((u_long) (numBonus * BONUS_COIN_SCORE));
}
/* Adjust the level so that the starting level is taken into account */
theLevel = (int) level - GetStartingLevel() + 1;
/* Increment the score by the value of the level bonus */
AddToScore((u_long) (LEVEL_SCORE * theLevel));
}
/* Increment the score by the value of the bullet bonus */
if (GetNumberBullets() != 0)
AddToScore((u_long) (GetNumberBullets() * BULLET_SCORE));
/* Get the number of seconds left on the clock */
secs = GetLevelTimeBonus();
if (secs > 0)
{
/* Increment the score by the value of the time bonus */
AddToScore((u_long) (TIME_BONUS * secs));
}
DEBUG("finished computing and adding bonus score.")
}
#if NeedFunctionPrototypes
void ResetBonus(void)
#else
void ResetBonus()
#endif
{
DEBUG("Reseting bonus screen.")
/* Setup for bonus screen from start */
BonusState = BONUS_TEXT;
firstTime = True;
bonusScore = score;
ComputeAndAddBonusScore();
ypos = 180;
SetGameSpeed(FAST_SPEED);
}
|