Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

114 lignes
2.7 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. struct cucul_sprite *heart_sprite;
  26. struct cucul_sprite *gem_sprite;
  27. void init_bonus(game *g, bonus *bo)
  28. {
  29. int i;
  30. for(i = 0; i < BONUS; i++)
  31. {
  32. bo->type[i] = BONUS_NONE;
  33. }
  34. heart_sprite = cucul_load_sprite(g->qq, "data/bonheart.txt");
  35. gem_sprite = cucul_load_sprite(g->qq, "data/bongem.txt");
  36. }
  37. void draw_bonus(game *g, bonus *bo)
  38. {
  39. int i;
  40. for(i = 0; i < BONUS; i++)
  41. {
  42. switch(bo->type[i])
  43. {
  44. case BONUS_GREEN:
  45. cucul_draw_sprite(g->qq, bo->x[i], bo->y[i], gem_sprite,
  46. (bo->n[i]/2 % 3) ? 0 : 1);
  47. break;
  48. case BONUS_LIFE:
  49. cucul_draw_sprite(g->qq, bo->x[i], bo->y[i], heart_sprite,
  50. (bo->n[i] % 3) ? 0 : 1);
  51. break;
  52. case BONUS_NONE:
  53. break;
  54. }
  55. }
  56. }
  57. void update_bonus(game *g, bonus *bo)
  58. {
  59. int i;
  60. for(i = 0; i < BONUS; i++)
  61. {
  62. switch(bo->type[i])
  63. {
  64. case BONUS_GREEN:
  65. bo->n[i]++;
  66. bo->y[i]++;
  67. if(bo->y[i] > g->h)
  68. {
  69. bo->type[i] = BONUS_NONE;
  70. }
  71. break;
  72. case BONUS_LIFE:
  73. bo->n[i]++;
  74. bo->y[i]++;
  75. if(bo->y[i] > g->h)
  76. {
  77. bo->type[i] = BONUS_NONE;
  78. }
  79. break;
  80. case BONUS_NONE:
  81. break;
  82. }
  83. }
  84. }
  85. void add_bonus(game *g, bonus *bo, int x, int y, int type)
  86. {
  87. int i;
  88. for(i = 0; i < BONUS; i++)
  89. {
  90. if(bo->type[i] == BONUS_NONE)
  91. {
  92. bo->type[i] = type;
  93. bo->x[i] = x;
  94. bo->y[i] = y;
  95. bo->n[i] = 0;
  96. break;
  97. }
  98. }
  99. }