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

Last change on this file since 1460 was 1460, checked in by Sam Hocevar, 13 years ago
  • Bwarf, typo in the no warranty clause.
  • Property svn:keywords set to Id
File size: 2.4 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 1460 2006-12-12 01:49:48Z 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#include <unistd.h>
20
21#include "common.h"
22
23void intro(game *g)
24{
25    caca_event_t ev;
26    cucul_canvas_t *foo_sprite;
27    cucul_canvas_t *bar_sprite;
28    cucul_canvas_t *baz_sprite;
29    cucul_buffer_t *b;
30    int frame = 0;
31
32    b = cucul_load_file("data/foofight.caca");
33    foo_sprite = cucul_import_canvas(b, "");
34    cucul_free_buffer(b);
35
36    b = cucul_load_file("data/barfight.caca");
37    bar_sprite = cucul_import_canvas(b, "");
38    cucul_free_buffer(b);
39
40    b = cucul_load_file("data/bazfight.caca");
41    baz_sprite = cucul_import_canvas(b, "");
42    cucul_free_buffer(b);
43
44    while(caca_get_event(g->dp, CACA_EVENT_KEY_PRESS, &ev, 0) == 0)
45    {
46        int i, xo, yo, x[5], y[5];
47
48        frame++;
49
50        cucul_clear_canvas(g->cv);
51
52        xo = cucul_get_canvas_width(g->cv) / 2;
53        yo = cucul_get_canvas_height(g->cv) / 2;
54
55        cucul_set_color(g->cv, CUCUL_COLOR_RED, CUCUL_COLOR_BLACK);
56        cucul_fill_ellipse(g->cv, xo, yo, 16, 8, "#");
57        cucul_set_color(g->cv, CUCUL_COLOR_GREEN, CUCUL_COLOR_BLACK);
58        cucul_draw_thin_ellipse(g->cv, xo, yo, 16, 8);
59
60        for(i = 0; i < 4; i ++)
61        {
62            x[i] = xo + 0.5 + 12 * cos(0.05 * frame + i * M_PI / 2);
63            y[i] = yo + 0.5 + 6 * sin(0.05 * frame + i * M_PI / 2);
64        }
65        x[4] = x[0];
66        y[4] = y[0];
67
68        cucul_set_color(g->cv, CUCUL_COLOR_BLACK, CUCUL_COLOR_BLACK);
69        cucul_fill_triangle(g->cv, x[0], y[0], x[1], y[1], x[2], y[2], " ");
70        cucul_fill_triangle(g->cv, x[0], y[0], x[3], y[3], x[2], y[2], " ");
71        cucul_draw_line(g->cv, x[0], y[0], x[2], y[2], " ");
72        cucul_set_color(g->cv, CUCUL_COLOR_GREEN, CUCUL_COLOR_BLACK);
73        cucul_draw_thin_polyline(g->cv, x, y, 4);
74
75        cucul_set_canvas_frame(foo_sprite, frame % 5);
76        cucul_blit(g->cv, xo, yo, foo_sprite, NULL);
77
78        caca_refresh_display(g->dp);
79
80        usleep(40000);
81    }
82}
83
Note: See TracBrowser for help on using the repository browser.