home *** CD-ROM | disk | FTP | other *** search
/ Dream 52 / Amiga_Dream_52.iso / Linux / Divers / xgalaga-2_0_tar.gz / xgalaga-2_0_tar / xgalaga-2.0 / score.c < prev    next >
C/C++ Source or Header  |  1998-04-30  |  2KB  |  79 lines

  1. /* $Id: score.c,v 1.2 1998/04/30 05:11:58 mrogre Exp $ */
  2. /* Copyright (c) 1998 Joe Rumsey (mrogre@mediaone.net) */
  3. #include "copyright.h"
  4.  
  5. #include <config.h>
  6. #include <stdio.h>
  7. #include "Wlib.h"
  8. #include "images.h"
  9. #include "data.h"
  10. #include "defs.h"
  11. #include "struct.h"
  12. #include "proto.h"
  13.  
  14. char scorestr[40] = "Score: 0000000", shipstr[4] ="";
  15. W_Image *miniship, *extraImage;
  16. int drawExtra = 0, extrax, extray;
  17.  
  18. void undo_score()
  19. {
  20.     int basex;
  21.  
  22.     basex = WINWIDTH/2 - ((strlen(scorestr)/2)*W_Textwidth);
  23.     W_ClearArea(baseWin, basex, 0, strlen(scorestr) * W_Textwidth + 1, W_Textheight + 1);
  24.     W_ClearArea(baseWin, 0, 0, (miniship->width+2)*6, miniship->height);
  25.     basex = 6*(miniship->width+2) + 2;
  26.     W_ClearArea(baseWin, basex, 0, strlen(shipstr) * W_Textwidth + 1, W_Textheight + 1);
  27.     if(drawExtra)
  28.     W_ClearArea(baseWin, extrax-(extraImage->width/2), extray-(extraImage->height/2), 
  29.             extraImage->width, extraImage->height);
  30. }
  31.  
  32. void do_score()
  33. {
  34.     int basex;
  35.     int i;
  36.     static int lastscore;
  37.  
  38.     sprintf(scorestr, "Score: %07d     Level: %02d", score, level);
  39.     basex = WINWIDTH/2 - ((strlen(scorestr)/2)*W_Textwidth);
  40.     W_MaskText(baseWin, basex, 1, W_Grey, scorestr, strlen(scorestr), W_RegularFont);
  41.     W_MaskText(baseWin, basex+1, 0, W_Yellow, scorestr, strlen(scorestr), W_RegularFont);
  42.  
  43.     for(i=0;i<((ships < 6) ? ships : 6);i++) {
  44.     W_DrawImage(baseWin, i*(miniship->width+2), 0, 0, miniship, W_White);
  45.     }
  46.     if(ships>6) {
  47.     sprintf(shipstr, "%d", ships);
  48.     basex = 6*(miniship->width+2) + 2;
  49.     W_MaskText(baseWin, basex, 1, W_Grey, shipstr, strlen(shipstr), W_RegularFont);
  50.     W_MaskText(baseWin, basex+1, 0, W_Yellow, shipstr, strlen(shipstr), W_RegularFont);
  51.     }
  52.     if(lastscore != score) {
  53.     if((score > 0) && (score >= nextBonus)) {
  54.         ships++;
  55.         extrax = 0 - extraImage->width/2;
  56.         extray = WINHEIGHT/2;
  57.         drawExtra = 1;
  58.         if(nextBonus < BONUSSHIPSCORE)
  59.         nextBonus = BONUSSHIPSCORE;
  60.         else
  61.         nextBonus += BONUSSHIPSCORE;
  62.     }
  63.     lastscore=score;
  64.     }
  65.     if(drawExtra) {
  66.     extrax += 10;
  67.     W_DrawImage(baseWin, extrax-(extraImage->width/2), extray-(extraImage->height/2), 0, extraImage, W_White);
  68.     if((extrax-(int)extraImage->width/2) > WINWIDTH)
  69.         drawExtra = 0;
  70.     }
  71. }
  72.  
  73. void init_score()
  74. {
  75.     miniship = getImage(I_MINISHIP);
  76.     extraImage = getImage(I_EXTRA);
  77. }
  78.  
  79.