/* * ttyvaders Textmode shoot'em up * Copyright (c) 2002 Sam Hocevar * All Rights Reserved * * $Id: intro.c 1057 2006-09-18 16:54:08Z sam $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "config.h" #include #include #include #include "common.h" void intro(game *g) { caca_event_t ev; cucul_canvas_t *foo_sprite; cucul_canvas_t *bar_sprite; cucul_canvas_t *baz_sprite; cucul_buffer_t *b; int frame = 0; b = cucul_load_file("data/foofight.caca"); foo_sprite = cucul_import_canvas(b, ""); cucul_free_buffer(b); b = cucul_load_file("data/barfight.caca"); bar_sprite = cucul_import_canvas(b, ""); cucul_free_buffer(b); b = cucul_load_file("data/bazfight.caca"); baz_sprite = cucul_import_canvas(b, ""); cucul_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++; cucul_clear_canvas(g->cv); xo = cucul_get_canvas_width(g->cv) / 2; yo = cucul_get_canvas_height(g->cv) / 2; cucul_set_color(g->cv, CUCUL_COLOR_RED, CUCUL_COLOR_BLACK); cucul_fill_ellipse(g->cv, xo, yo, 16, 8, "#"); cucul_set_color(g->cv, CUCUL_COLOR_GREEN, CUCUL_COLOR_BLACK); cucul_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]; cucul_set_color(g->cv, CUCUL_COLOR_BLACK, CUCUL_COLOR_BLACK); cucul_fill_triangle(g->cv, x[0], y[0], x[1], y[1], x[2], y[2], " "); cucul_fill_triangle(g->cv, x[0], y[0], x[3], y[3], x[2], y[2], " "); cucul_draw_line(g->cv, x[0], y[0], x[2], y[2], " "); cucul_set_color(g->cv, CUCUL_COLOR_GREEN, CUCUL_COLOR_BLACK); cucul_draw_thin_polyline(g->cv, x, y, 4); cucul_set_canvas_frame(foo_sprite, frame % 5); cucul_blit(g->cv, xo, yo, foo_sprite, NULL); caca_refresh_display(g->dp); usleep(40000); } }