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 3423 2009-04-28 16:55:01Z sam $ |
---|
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 | |
---|
15 | #include "config.h" |
---|
16 | |
---|
17 | #include <stdlib.h> |
---|
18 | #include <math.h> |
---|
19 | #ifndef M_PI
|
---|
20 | # define M_PI 3.14159265358979323846
|
---|
21 | #endif |
---|
22 | //#include <unistd.h> |
---|
23 | |
---|
24 | #include "common.h" |
---|
25 | |
---|
26 | void intro(game *g) |
---|
27 | { |
---|
28 | caca_event_t ev; |
---|
29 | caca_canvas_t *foo_sprite; |
---|
30 | caca_canvas_t *bar_sprite; |
---|
31 | caca_canvas_t *baz_sprite; |
---|
32 | int frame = 0; |
---|
33 | |
---|
34 | foo_sprite = caca_create_canvas(0, 0); |
---|
35 | caca_import_file(foo_sprite, "data/foofight.txt", "utf8"); |
---|
36 | |
---|
37 | bar_sprite = caca_create_canvas(0, 0); |
---|
38 | caca_import_file(bar_sprite, "data/barfight.txt", "utf8"); |
---|
39 | |
---|
40 | baz_sprite = caca_create_canvas(0, 0); |
---|
41 | caca_import_file(baz_sprite, "data/bazfight.txt", "utf8"); |
---|
42 | |
---|
43 | while(caca_get_event(g->dp, CACA_EVENT_KEY_PRESS, &ev, 0) == 0) |
---|
44 | { |
---|
45 | int i, xo, yo, x[5], y[5]; |
---|
46 | |
---|
47 | frame++; |
---|
48 | |
---|
49 | caca_clear_canvas(g->cv); |
---|
50 | |
---|
51 | xo = caca_get_canvas_width(g->cv) / 2; |
---|
52 | yo = caca_get_canvas_height(g->cv) / 2; |
---|
53 | |
---|
54 | caca_set_color_ansi(g->cv, CACA_RED, CACA_BLACK); |
---|
55 | caca_fill_ellipse(g->cv, xo, yo, 16, 8, '#'); |
---|
56 | caca_set_color_ansi(g->cv, CACA_GREEN, CACA_BLACK); |
---|
57 | caca_draw_thin_ellipse(g->cv, xo, yo, 16, 8); |
---|
58 | |
---|
59 | for(i = 0; i < 4; i ++) |
---|
60 | { |
---|
61 | x[i] = xo + 0.5 + 12 * cos(0.05 * frame + i * M_PI / 2); |
---|
62 | y[i] = yo + 0.5 + 6 * sin(0.05 * frame + i * M_PI / 2); |
---|
63 | } |
---|
64 | x[4] = x[0]; |
---|
65 | y[4] = y[0]; |
---|
66 | |
---|
67 | caca_set_color_ansi(g->cv, CACA_BLACK, CACA_BLACK); |
---|
68 | caca_fill_triangle(g->cv, x[0], y[0], x[1], y[1], x[2], y[2], ' '); |
---|
69 | caca_fill_triangle(g->cv, x[0], y[0], x[3], y[3], x[2], y[2], ' '); |
---|
70 | caca_draw_line(g->cv, x[0], y[0], x[2], y[2], ' '); |
---|
71 | caca_set_color_ansi(g->cv, CACA_GREEN, CACA_BLACK); |
---|
72 | caca_draw_thin_polyline(g->cv, x, y, 4); |
---|
73 | |
---|
74 | caca_set_frame(foo_sprite, frame % 5); |
---|
75 | caca_blit(g->cv, xo, yo, foo_sprite, NULL); |
---|
76 | |
---|
77 | caca_refresh_display(g->dp); |
---|
78 | |
---|
79 | //usleep(40000); |
---|
80 | } |
---|
81 | } |
---|
82 | |
---|