Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

105 строки
3.0 KiB

  1. /*
  2. * ttyvaders Textmode shoot'em up
  3. * Copyright (c) 2002-2003 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. box * create_box(game *g, int x, int y, int w, int h)
  26. {
  27. box *b = malloc(sizeof( box ));
  28. b->x = x;
  29. b->y = y;
  30. b->w = w;
  31. b->h = h;
  32. b->frame = 0;
  33. return b;
  34. }
  35. void draw_box(game *g, box *b)
  36. {
  37. int j, frame;
  38. ee_set_color(EE_YELLOW);
  39. /* Draw the thin horizontal line */
  40. if(b->frame < 8)
  41. {
  42. ee_draw_line(b->x - b->w * b->frame / 16, b->y,
  43. b->x + b->w * b->frame / 16 - 1, b->y, 'X');
  44. return;
  45. }
  46. /* Draw the frame */
  47. frame = b->frame < 12 ? b->frame : 12;
  48. ee_draw_line(b->x - b->w / 2, b->y - b->h * (frame - 8) / 8,
  49. b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8, 'X');
  50. ee_draw_line(b->x - b->w / 2, b->y + b->h * (frame - 8) / 8,
  51. b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8, 'X');
  52. ee_draw_line(b->x - b->w / 2, b->y - b->h * (frame - 8) / 8,
  53. b->x - b->w / 2, b->y + b->h * (frame - 8) / 8 - 1, 'X');
  54. ee_draw_line(b->x + b->w / 2 - 1, b->y - b->h * (frame - 8) / 8,
  55. b->x + b->w / 2 - 1, b->y + b->h * (frame - 8) / 8 - 1, 'X');
  56. ee_set_color(EE_BLACK);
  57. for(j = b->y - b->h * (frame - 8) / 8 + 1;
  58. j < b->y + b->h * (frame - 8) / 8;
  59. j++)
  60. {
  61. ee_draw_line(b->x - b->w / 2 + 1, j,
  62. b->x + b->w / 2 - 2, j, 'X');
  63. }
  64. if(b->frame < 12)
  65. {
  66. return;
  67. }
  68. /* Draw the text inside the frame */
  69. ee_set_color(EE_YELLOW);
  70. /* FIXME: use a font */
  71. ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 2,
  72. "XXXX. .XXXX X X .XXXX .XXXX XXXX.");
  73. ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 3,
  74. "X `X X' X X X X' X' X `X");
  75. ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 4,
  76. "XXXX' XXXXX X X `XXX XXXX X X");
  77. ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 5,
  78. "X' X' `X X. ,X `X X' X ,X");
  79. ee_putstr(b->x - b->w / 2 + 12, b->y - b->h / 2 + 6,
  80. "X X X `XXXX XXXX' `XXXX XXXX'");
  81. }
  82. void free_box(box *b)
  83. {
  84. free(b);
  85. }