source: ttyvaders/trunk/src/overlay.c @ 160

Last change on this file since 160 was 160, checked in by Sam Hocevar, 16 years ago
  • libee/ee.h: + Added ee_color_names[] containing our 16 color names.
  • libee/ee.c: + Extended our color set to the full 16 instead of 10. + Precalculate ncurses attributes.
  • libee/graphics.c: + Clip color value in ee_set_color(). + Clip characters in ee_putchar(). + Partially clip characters in ee_putstr(), overflows aren't checked yet.
  • libee/ee_internals.h: + New file to share extern variables within libee.
  • test/demo.c: + Added a simple demo_color() to output all colors. + Replaced four ee_draw_line() with ee_draw_thin_box(). + Replaced x1, y1, x2 etc. with xa, ya, xb etc. because <math.h> already

defines y1.

+ Randomized colours from 0 to 15 instead of 1 to 10.

  • src/Makefiles.am: + Added -lm to the ttyvaders linking flags because of the intro.
  • README BUGS TODO: + Updated.
  • Property svn:keywords set to Id
File size: 2.0 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: overlay.c 160 2003-11-12 21:18:50Z 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
27#include "common.h"
28
29void draw_status(game *g)
30{
31    static char dots30[] = "------------------------------";
32    static char dashes30[] = "==============================";
33
34    /* Draw life jauge */
35    ee_set_color(EE_DARKGRAY);
36    ee_putstr(4, 1, dots30);
37
38    if(g->p->life > MAX_LIFE * 7 / 10)
39    {
40        ee_set_color(EE_GREEN);
41    }
42    else if(g->p->life > MAX_LIFE * 3 / 10)
43    {
44        ee_set_color(EE_YELLOW);
45    }
46    else
47    {
48        ee_set_color(EE_RED);
49    }
50
51    ee_putstr(4, 1, dashes30 + (MAX_LIFE - g->p->life) * 30 / MAX_LIFE);
52
53    ee_set_color(EE_WHITE);
54    ee_putstr(1, 1, "L |");
55    ee_putstr(34, 1, "|");
56
57    /* Draw weapon jauge */
58    ee_set_color(EE_DARKGRAY);
59    ee_putstr(42, 1, dots30 + 10);
60
61    if(g->p->special > MAX_SPECIAL * 9 / 10)
62    {
63        ee_set_color(EE_WHITE);
64    }
65    else if(g->p->special > MAX_SPECIAL * 3 / 10)
66    {
67        ee_set_color(EE_CYAN);
68    }
69    else
70    {
71        ee_set_color(EE_BLUE);
72    }
73
74    ee_putstr(42, 1, dashes30 + 10
75                       + (MAX_SPECIAL - g->p->special) * 20 / MAX_SPECIAL);
76
77    ee_set_color(EE_WHITE);
78    ee_putstr(39, 1, "S |");
79    ee_putstr(62, 1, "|");
80}
81
Note: See TracBrowser for help on using the repository browser.