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.
 
 
 
 
 

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