Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 
 
 
 

116 Zeilen
2.9 KiB

  1. /*
  2. * spritedit sprite editor using libee
  3. * Copyright (c) 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 <stdio.h>
  24. #include "ee.h"
  25. int main(int argc, char **argv)
  26. {
  27. int quit = 0;
  28. struct ee_sprite *sprite;
  29. int frame = 0;
  30. if(argc < 2)
  31. {
  32. fprintf(stderr, "%s: missing argument (filename).\n", argv[0]);
  33. return 1;
  34. }
  35. if(ee_init())
  36. return 1;
  37. sprite = ee_load_sprite(argv[1]);
  38. if(!sprite)
  39. {
  40. ee_end();
  41. fprintf(stderr, "%s: could not open `%s'.\n", argv[0], argv[1]);
  42. return 1;
  43. }
  44. /* Go ! */
  45. while(!quit)
  46. {
  47. int xa, ya, xb, yb;
  48. char buf[BUFSIZ];
  49. switch(ee_get_key())
  50. {
  51. case 0:
  52. break;
  53. case 'q':
  54. quit = 1;
  55. break;
  56. case '-':
  57. if(frame > 0)
  58. frame--;
  59. break;
  60. case '+':
  61. if(frame < ee_get_sprite_frames(sprite) - 1)
  62. frame++;
  63. break;
  64. }
  65. ee_clear();
  66. ee_set_color(EE_WHITE);
  67. ee_draw_thin_box(0, 0, ee_get_width() - 1, ee_get_height() - 1);
  68. ee_putstr(3, 0, "[ Sprite editor for libee ]");
  69. sprintf(buf, "sprite `%s'", argv[1]);
  70. ee_putstr(3, 2, buf);
  71. sprintf(buf, "frame %i/%i", frame, ee_get_sprite_frames(sprite) - 1);
  72. ee_putstr(3, 3, buf);
  73. /* Crosshair */
  74. ee_draw_thin_line(57, 2, 57, 18);
  75. ee_draw_thin_line(37, 10, 77, 10);
  76. ee_putchar(57, 10, '+');
  77. /* Boxed sprite */
  78. xa = -1 - ee_get_sprite_dx(sprite, frame);
  79. ya = -1 - ee_get_sprite_dy(sprite, frame);
  80. xb = xa + 1 + ee_get_sprite_width(sprite, frame);
  81. yb = ya + 1 + ee_get_sprite_height(sprite, frame);
  82. ee_set_color(EE_BLACK);
  83. ee_fill_box(57 + xa, 10 + ya, 57 + xb, 10 + yb, ' ');
  84. ee_set_color(EE_WHITE);
  85. ee_draw_thin_box(57 + xa, 10 + ya, 57 + xb, 10 + yb);
  86. ee_draw_sprite(57, 10, sprite, frame);
  87. /* Free sprite */
  88. ee_draw_sprite(20, 10, sprite, frame);
  89. ee_refresh();
  90. }
  91. /* Clean up */
  92. ee_end();
  93. return 0;
  94. }