source: ttyvaders/trunk/src/intro.c @ 544

Last change on this file since 544 was 544, checked in by Sam Hocevar, 15 years ago
  • Ported to new libcaca/libcucul API.
  • Property svn:keywords set to Id
File size: 2.5 KB
Line 
1/*
2 *   ttyvaders     Textmode shoot'em up
3 *   Copyright (c) 2002 Sam Hocevar <sam@zoy.org>
4 *                 All Rights Reserved
5 *
6 *   $Id: intro.c 544 2006-03-07 14:25:20Z sam $
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
23#include "config.h"
24
25#include <stdlib.h>
26#include <math.h>
27#include <unistd.h>
28
29#include "common.h"
30
31void intro(game *g)
32{
33    struct cucul_sprite *foo_sprite = cucul_load_sprite(g->qq, "data/foofight.txt");
34    struct cucul_sprite *bar_sprite = cucul_load_sprite(g->qq, "data/barfight.txt");
35    struct cucul_sprite *baz_sprite = cucul_load_sprite(g->qq, "data/bazfight.txt");
36
37    int frame = 0;
38
39    while(caca_get_event(g->kk, CACA_EVENT_KEY_PRESS) == 0)
40    {
41        int i, xo, yo, x[5], y[5];
42
43        frame++;
44
45        cucul_clear(g->qq);
46
47        xo = cucul_get_width(g->qq) / 2;
48        yo = cucul_get_height(g->qq) / 2;
49
50        cucul_set_color(g->qq, CUCUL_COLOR_RED, CUCUL_COLOR_BLACK);
51        cucul_fill_ellipse(g->qq, xo, yo, 16, 8, '#');
52        cucul_set_color(g->qq, CUCUL_COLOR_GREEN, CUCUL_COLOR_BLACK);
53        cucul_draw_thin_ellipse(g->qq, xo, yo, 16, 8);
54
55        for(i = 0; i < 4; i ++)
56        {
57            x[i] = xo + 0.5 + 12 * cos(0.05 * frame + i * M_PI / 2);
58            y[i] = yo + 0.5 + 6 * sin(0.05 * frame + i * M_PI / 2);
59        }
60        x[4] = x[0];
61        y[4] = y[0];
62
63        cucul_set_color(g->qq, CUCUL_COLOR_BLACK, CUCUL_COLOR_BLACK);
64        cucul_fill_triangle(g->qq, x[0], y[0], x[1], y[1], x[2], y[2], ' ');
65        cucul_fill_triangle(g->qq, x[0], y[0], x[3], y[3], x[2], y[2], ' ');
66        cucul_draw_line(g->qq, x[0], y[0], x[2], y[2], ' ');
67        cucul_set_color(g->qq, CUCUL_COLOR_GREEN, CUCUL_COLOR_BLACK);
68        cucul_draw_thin_polyline(g->qq, x, y, 4);
69
70        cucul_draw_sprite(g->qq, xo, yo, foo_sprite, frame % 5);
71
72        caca_display(g->kk);
73
74        usleep(40000);
75    }
76}
77
Note: See TracBrowser for help on using the repository browser.