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

126 行
3.2 KiB

  1. /*
  2. * ttyvaders Textmode shoot'em up
  3. * Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  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 "config.h"
  23. #include <stdlib.h>
  24. #include "common.h"
  25. void init_bonus(game *g, bonus *bo)
  26. {
  27. int i;
  28. for(i = 0; i < BONUS; i++)
  29. {
  30. bo->type[i] = BONUS_NONE;
  31. }
  32. }
  33. void draw_bonus(game *g, bonus *bo)
  34. {
  35. int i;
  36. for(i = 0; i < BONUS; i++)
  37. {
  38. switch(bo->type[i])
  39. {
  40. case BONUS_GREEN:
  41. ee_color((bo->n[i]/2 % 3) ? EE_GREEN : EE_WHITE);
  42. ee_goto(bo->x[i]+1, bo->y[i]-1);
  43. ee_putchar('_');
  44. ee_goto(bo->x[i], bo->y[i]);
  45. ee_putstr("/ \\");
  46. ee_goto(bo->x[i], bo->y[i]+1);
  47. ee_putstr("\\_/");
  48. ee_color(EE_WHITE);
  49. ee_goto(bo->x[i]+1, bo->y[i]);
  50. ee_putchar('g');
  51. break;
  52. case BONUS_LIFE:
  53. ee_color((bo->n[i] % 3) ? EE_RED : EE_WHITE);
  54. ee_goto(bo->x[i]+1, bo->y[i]-1);
  55. ee_putchar('_');
  56. ee_goto(bo->x[i]+3, bo->y[i]-1);
  57. ee_putchar('_');
  58. ee_goto(bo->x[i], bo->y[i]);
  59. ee_putstr("( ' )");
  60. ee_goto(bo->x[i]+1, bo->y[i]+1);
  61. ee_putstr("`v'");
  62. ee_color(EE_WHITE);
  63. ee_goto(bo->x[i]+3, bo->y[i]);
  64. ee_putchar('^');
  65. break;
  66. case BONUS_NONE:
  67. break;
  68. }
  69. }
  70. }
  71. void update_bonus(game *g, bonus *bo)
  72. {
  73. int i;
  74. for(i = 0; i < BONUS; i++)
  75. {
  76. switch(bo->type[i])
  77. {
  78. case BONUS_GREEN:
  79. bo->n[i]++;
  80. bo->y[i]++;
  81. if(bo->y[i] > g->h)
  82. {
  83. bo->type[i] = BONUS_NONE;
  84. }
  85. break;
  86. case BONUS_LIFE:
  87. bo->n[i]++;
  88. bo->y[i]++;
  89. if(bo->y[i] > g->h)
  90. {
  91. bo->type[i] = BONUS_NONE;
  92. }
  93. break;
  94. case BONUS_NONE:
  95. break;
  96. }
  97. }
  98. }
  99. void add_bonus(game *g, bonus *bo, int x, int y, int type)
  100. {
  101. int i;
  102. for(i = 0; i < BONUS; i++)
  103. {
  104. if(bo->type[i] == BONUS_NONE)
  105. {
  106. bo->type[i] = type;
  107. bo->x[i] = x;
  108. bo->y[i] = y;
  109. bo->n[i] = 0;
  110. break;
  111. }
  112. }
  113. }