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

Last change on this file since 154 was 154, checked in by Sam Hocevar, 19 years ago
  • libee/graphics.c: + Renamed ee_color() to ee_set_color(), wrote ee_get_color().
  • libee/line.c: + Implemented draw_polyline() and draw_thin_polyline().
  • libee/sprite.c: + Removed the f member of struct ee_sprite. + Implemented ee_get_sprite_{width|height|dx|dy}(). + Restore the color fater ee_draw_sprite() is called.
  • libee/box.c: + Fixed a bug causing improper box clipping at the right and the bottom.
  • data/foo_fighter: + Fixed bugs in the sprite.
  • src/intro.c: + Test effects for the future game's intro.
  • test/spritedit.c: + Added stuff to the sprite editor. We can now navigate through frames.
  • Property svn:keywords set to Id
File size: 2.1 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 154 2003-11-12 01:48:58Z 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(void)
32{
33    struct ee_sprite *foo_sprite = ee_load_sprite("data/foo_fighter");
34    struct ee_sprite *bar_sprite = ee_load_sprite("data/bar_fighter");
35    struct ee_sprite *baz_sprite = ee_load_sprite("data/baz_fighter");
36
37    int frame = 0;
38
39    while(ee_get_key() == 0)
40    {
41        int i, xo, yo, x[5], y[5];
42
43        frame++;
44
45        ee_clear();
46
47        xo = ee_get_width() / 2;
48        yo = ee_get_height() / 2;
49
50        ee_set_color(EE_RED);
51        ee_fill_ellipse(xo, yo, 16, 8, '#');
52        ee_set_color(EE_GREEN);
53        ee_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        ee_set_color(EE_BLACK);
64        ee_fill_triangle(x[0], y[0], x[1], y[1], x[2], y[2], '#');
65        ee_fill_triangle(x[0], y[0], x[3], y[3], x[2], y[2], '#');
66        ee_draw_line(x[0], y[0], x[2], y[2], '#');
67        ee_set_color(EE_GREEN);
68        ee_draw_thin_polyline(x, y, 4);
69
70        ee_draw_sprite(xo, yo, foo_sprite, frame % 5);
71
72        ee_refresh();
73
74        usleep(40000);
75    }
76}
77
Note: See TracBrowser for help on using the repository browser.