You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

126 lines
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 i, j, frame;
  38. ee_color(EE_YELLOW);
  39. /* Draw the thin horizontal line */
  40. if(b->frame < 8)
  41. {
  42. for(i = b->x - b->w * b->frame / 16 ;
  43. i < b->x + b->w * b->frame / 16 ;
  44. i++)
  45. {
  46. ee_goto(i, b->y);
  47. ee_putchar('X');
  48. }
  49. return;
  50. }
  51. /* Draw the frame */
  52. frame = b->frame < 12 ? b->frame : 12;
  53. for(i = b->x - b->w / 2 ;
  54. i < b->x + b->w / 2 ;
  55. i++)
  56. {
  57. ee_goto(i, b->y - b->h * (frame - 8) / 8);
  58. ee_putchar('X');
  59. ee_goto(i, b->y + b->h * (frame - 8) / 8);
  60. ee_putchar('X');
  61. }
  62. for(j = b->y - b->h * (frame - 8) / 8 ;
  63. j < b->y + b->h * (frame - 8) / 8 ;
  64. j++)
  65. {
  66. ee_goto(b->x - b->w / 2, j);
  67. ee_putchar('X');
  68. ee_goto(b->x + b->w / 2 - 1, j);
  69. ee_putchar('X');
  70. }
  71. ee_color(EE_BLACK);
  72. for(j = b->y - b->h * (frame - 8) / 8 + 1 ;
  73. j < b->y + b->h * (frame - 8) / 8 ;
  74. j++)
  75. {
  76. for(i = b->x - b->w / 2 + 1 ;
  77. i < b->x + b->w / 2 - 1 ;
  78. i++)
  79. {
  80. ee_goto(i, j);
  81. ee_putchar('X');
  82. }
  83. }
  84. if(b->frame < 12)
  85. {
  86. return;
  87. }
  88. /* Draw the text inside the frame */
  89. ee_color(EE_YELLOW);
  90. /* FIXME: use a font */
  91. ee_goto(b->x - b->w / 2 + 12, b->y - b->h / 2 + 2);
  92. ee_putstr("XXXX. .XXXX X X .XXXX .XXXX XXXX.");
  93. ee_goto(b->x - b->w / 2 + 12, b->y - b->h / 2 + 3);
  94. ee_putstr("X `X X' X X X X' X' X `X");
  95. ee_goto(b->x - b->w / 2 + 12, b->y - b->h / 2 + 4);
  96. ee_putstr("XXXX' XXXXX X X `XXX XXXX X X");
  97. ee_goto(b->x - b->w / 2 + 12, b->y - b->h / 2 + 5);
  98. ee_putstr("X' X' `X X. ,X `X X' X ,X");
  99. ee_goto(b->x - b->w / 2 + 12, b->y - b->h / 2 + 6);
  100. ee_putstr("X X X `XXXX XXXX' `XXXX XXXX'");
  101. }
  102. void free_box(box *b)
  103. {
  104. free(b);
  105. }