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 365 2004-02-17 13:53:14Z 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 | |
---|
31 | void intro(void) |
---|
32 | { |
---|
33 | struct caca_sprite *foo_sprite = caca_load_sprite("data/foofight.txt"); |
---|
34 | struct caca_sprite *bar_sprite = caca_load_sprite("data/barfight.txt"); |
---|
35 | struct caca_sprite *baz_sprite = caca_load_sprite("data/bazfight.txt"); |
---|
36 | |
---|
37 | int frame = 0; |
---|
38 | |
---|
39 | while(caca_get_event(CACA_EVENT_KEY_PRESS) == 0) |
---|
40 | { |
---|
41 | int i, xo, yo, x[5], y[5]; |
---|
42 | |
---|
43 | frame++; |
---|
44 | |
---|
45 | caca_clear(); |
---|
46 | |
---|
47 | xo = caca_get_width() / 2; |
---|
48 | yo = caca_get_height() / 2; |
---|
49 | |
---|
50 | caca_set_color(CACA_COLOR_RED, CACA_COLOR_BLACK); |
---|
51 | caca_fill_ellipse(xo, yo, 16, 8, '#'); |
---|
52 | caca_set_color(CACA_COLOR_GREEN, CACA_COLOR_BLACK); |
---|
53 | caca_draw_thin_ellipse(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 | caca_set_color(CACA_COLOR_BLACK, CACA_COLOR_BLACK); |
---|
64 | caca_fill_triangle(x[0], y[0], x[1], y[1], x[2], y[2], ' '); |
---|
65 | caca_fill_triangle(x[0], y[0], x[3], y[3], x[2], y[2], ' '); |
---|
66 | caca_draw_line(x[0], y[0], x[2], y[2], ' '); |
---|
67 | caca_set_color(CACA_COLOR_GREEN, CACA_COLOR_BLACK); |
---|
68 | caca_draw_thin_polyline(x, y, 4); |
---|
69 | |
---|
70 | caca_draw_sprite(xo, yo, foo_sprite, frame % 5); |
---|
71 | |
---|
72 | caca_refresh(); |
---|
73 | |
---|
74 | usleep(40000); |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|