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.
 
 
 
 
 

83 lines
2.3 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. It comes without any warranty, to
  9. * the extent permitted by applicable law. You can redistribute it
  10. * and/or modify it under the terms of the Do What The Fuck You Want
  11. * To Public License, Version 2, as published by Sam Hocevar. See
  12. * http://sam.zoy.org/wtfpl/COPYING for more details.
  13. */
  14. #include "config.h"
  15. #include <stdlib.h>
  16. #include <math.h>
  17. #ifndef M_PI
  18. # define M_PI 3.14159265358979323846
  19. #endif
  20. //#include <unistd.h>
  21. #include "common.h"
  22. void intro(game *g)
  23. {
  24. caca_event_t ev;
  25. caca_canvas_t *foo_sprite;
  26. caca_canvas_t *bar_sprite;
  27. caca_canvas_t *baz_sprite;
  28. int frame = 0;
  29. foo_sprite = caca_create_canvas(0, 0);
  30. caca_import_file(foo_sprite, "data/foofight.txt", "utf8");
  31. bar_sprite = caca_create_canvas(0, 0);
  32. caca_import_file(bar_sprite, "data/barfight.txt", "utf8");
  33. baz_sprite = caca_create_canvas(0, 0);
  34. caca_import_file(baz_sprite, "data/bazfight.txt", "utf8");
  35. while(caca_get_event(g->dp, CACA_EVENT_KEY_PRESS, &ev, 0) == 0)
  36. {
  37. int i, xo, yo, x[5], y[5];
  38. frame++;
  39. caca_clear_canvas(g->cv);
  40. xo = caca_get_canvas_width(g->cv) / 2;
  41. yo = caca_get_canvas_height(g->cv) / 2;
  42. caca_set_color_ansi(g->cv, CACA_RED, CACA_BLACK);
  43. caca_fill_ellipse(g->cv, xo, yo, 16, 8, '#');
  44. caca_set_color_ansi(g->cv, CACA_GREEN, CACA_BLACK);
  45. caca_draw_thin_ellipse(g->cv, xo, yo, 16, 8);
  46. for(i = 0; i < 4; i ++)
  47. {
  48. x[i] = xo + 0.5 + 12 * cos(0.05 * frame + i * M_PI / 2);
  49. y[i] = yo + 0.5 + 6 * sin(0.05 * frame + i * M_PI / 2);
  50. }
  51. x[4] = x[0];
  52. y[4] = y[0];
  53. caca_set_color_ansi(g->cv, CACA_BLACK, CACA_BLACK);
  54. caca_fill_triangle(g->cv, x[0], y[0], x[1], y[1], x[2], y[2], ' ');
  55. caca_fill_triangle(g->cv, x[0], y[0], x[3], y[3], x[2], y[2], ' ');
  56. caca_draw_line(g->cv, x[0], y[0], x[2], y[2], ' ');
  57. caca_set_color_ansi(g->cv, CACA_GREEN, CACA_BLACK);
  58. caca_draw_thin_polyline(g->cv, x, y, 4);
  59. caca_set_frame(foo_sprite, frame % 5);
  60. caca_blit(g->cv, xo, yo, foo_sprite, NULL);
  61. caca_refresh_display(g->dp);
  62. //usleep(40000);
  63. }
  64. }