您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 
 

124 行
3.3 KiB

  1. /*
  2. * ttyvaders Textmode shoot'em up
  3. * Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * $Id: bonus.c,v 1.3 2002/12/22 18:44:12 sam Exp $
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation; either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  21. */
  22. #include <stdlib.h>
  23. #include "common.h"
  24. void init_bonus( game *g, bonus *bo )
  25. {
  26. int i;
  27. for( i = 0; i < BONUS; i++ )
  28. {
  29. bo->type[i] = BONUS_NONE;
  30. }
  31. }
  32. void draw_bonus( game *g, bonus *bo )
  33. {
  34. int i;
  35. for( i = 0; i < BONUS; i++ )
  36. {
  37. switch( bo->type[i] )
  38. {
  39. case BONUS_GREEN:
  40. gfx_color( (bo->n[i]/2 % 3) ? GREEN : WHITE );
  41. gfx_goto( bo->x[i]+1, bo->y[i]-1 );
  42. gfx_putchar( '_' );
  43. gfx_goto( bo->x[i], bo->y[i] );
  44. gfx_putstr( "/ \\" );
  45. gfx_goto( bo->x[i], bo->y[i]+1 );
  46. gfx_putstr( "\\_/" );
  47. gfx_color( WHITE );
  48. gfx_goto( bo->x[i]+1, bo->y[i] );
  49. gfx_putchar( 'g' );
  50. break;
  51. case BONUS_LIFE:
  52. gfx_color( (bo->n[i] % 3) ? RED : WHITE );
  53. gfx_goto( bo->x[i]+1, bo->y[i]-1 );
  54. gfx_putchar( '_' );
  55. gfx_goto( bo->x[i]+3, bo->y[i]-1 );
  56. gfx_putchar( '_' );
  57. gfx_goto( bo->x[i], bo->y[i] );
  58. gfx_putstr( "( ' )" );
  59. gfx_goto( bo->x[i]+1, bo->y[i]+1 );
  60. gfx_putstr( "`v'" );
  61. gfx_color( WHITE );
  62. gfx_goto( bo->x[i]+3, bo->y[i] );
  63. gfx_putchar( '^' );
  64. break;
  65. case BONUS_NONE:
  66. break;
  67. }
  68. }
  69. }
  70. void update_bonus( game *g, bonus *bo )
  71. {
  72. int i;
  73. for( i = 0; i < BONUS; i++ )
  74. {
  75. switch( bo->type[i] )
  76. {
  77. case BONUS_GREEN:
  78. bo->n[i]++;
  79. bo->y[i]++;
  80. if( bo->y[i] > g->h )
  81. {
  82. bo->type[i] = BONUS_NONE;
  83. }
  84. break;
  85. case BONUS_LIFE:
  86. bo->n[i]++;
  87. bo->y[i]++;
  88. if( bo->y[i] > g->h )
  89. {
  90. bo->type[i] = BONUS_NONE;
  91. }
  92. break;
  93. case BONUS_NONE:
  94. break;
  95. }
  96. }
  97. }
  98. void add_bonus( game *g, bonus *bo, int x, int y, int type )
  99. {
  100. int i;
  101. for( i = 0; i < BONUS; i++ )
  102. {
  103. if( bo->type[i] == BONUS_NONE )
  104. {
  105. bo->type[i] = type;
  106. bo->x[i] = x;
  107. bo->y[i] = y;
  108. bo->n[i] = 0;
  109. break;
  110. }
  111. }
  112. }