|
- /*
- * ttyvaders Textmode shoot'em up
- * Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
- * All Rights Reserved
- *
- * $Id$
- *
- * This program is free software. It comes without any warranty, to
- * the extent permitted by applicable law. You can redistribute it
- * and/or modify it under the terms of the Do What The Fuck You Want
- * To Public License, Version 2, as published by Sam Hocevar. See
- * http://sam.zoy.org/wtfpl/COPYING for more details.
- */
-
- #include "config.h"
-
- #include <stdlib.h>
- #include <math.h>
- #include <unistd.h>
-
- #include "common.h"
-
- void intro(game *g)
- {
- caca_event_t ev;
- caca_canvas_t *foo_sprite;
- caca_canvas_t *bar_sprite;
- caca_canvas_t *baz_sprite;
- caca_buffer_t *b;
- int frame = 0;
-
- b = caca_load_file("data/foofight.caca");
- foo_sprite = caca_import_canvas(b, "");
- caca_free_buffer(b);
-
- b = caca_load_file("data/barfight.caca");
- bar_sprite = caca_import_canvas(b, "");
- caca_free_buffer(b);
-
- b = caca_load_file("data/bazfight.caca");
- baz_sprite = caca_import_canvas(b, "");
- caca_free_buffer(b);
-
- while(caca_get_event(g->dp, CACA_EVENT_KEY_PRESS, &ev, 0) == 0)
- {
- int i, xo, yo, x[5], y[5];
-
- frame++;
-
- caca_clear_canvas(g->cv);
-
- xo = caca_get_canvas_width(g->cv) / 2;
- yo = caca_get_canvas_height(g->cv) / 2;
-
- caca_set_color(g->cv, CACA_COLOR_RED, CACA_COLOR_BLACK);
- caca_fill_ellipse(g->cv, xo, yo, 16, 8, "#");
- caca_set_color(g->cv, CACA_COLOR_GREEN, CACA_COLOR_BLACK);
- caca_draw_thin_ellipse(g->cv, xo, yo, 16, 8);
-
- for(i = 0; i < 4; i ++)
- {
- x[i] = xo + 0.5 + 12 * cos(0.05 * frame + i * M_PI / 2);
- y[i] = yo + 0.5 + 6 * sin(0.05 * frame + i * M_PI / 2);
- }
- x[4] = x[0];
- y[4] = y[0];
-
- caca_set_color(g->cv, CACA_COLOR_BLACK, CACA_COLOR_BLACK);
- caca_fill_triangle(g->cv, x[0], y[0], x[1], y[1], x[2], y[2], " ");
- caca_fill_triangle(g->cv, x[0], y[0], x[3], y[3], x[2], y[2], " ");
- caca_draw_line(g->cv, x[0], y[0], x[2], y[2], " ");
- caca_set_color(g->cv, CACA_COLOR_GREEN, CACA_COLOR_BLACK);
- caca_draw_thin_polyline(g->cv, x, y, 4);
-
- caca_set_canvas_frame(foo_sprite, frame % 5);
- caca_blit(g->cv, xo, yo, foo_sprite, NULL);
-
- caca_refresh_display(g->dp);
-
- usleep(40000);
- }
- }
|