view varydamage.c @ 3:5a977ccbc7a9 default tip

Empty changelog
author darius
date Sat, 06 Dec 1997 05:41:29 +0000
parents
children
line wrap: on
line source

/* $Id: varydamage.c,v 1.1.1.1 1997/12/06 05:41:31 darius Exp $ */

/*
 * redraw.c
 */
#include "copyright.h"

#include <stdio.h>
#include <signal.h>
#include <math.h>
#include "Wlib.h"
#include "defs.h"
#include "struct.h"
#include "data.h"
#include "packets.h"
#include "proto.h"
#include "gameconf.h"

void
doShields(dx, dy, ship_bits, j)
    int     dx, dy;
    struct ship_shape *ship_bits;
    struct player *j;
{
    if (showShields && (j->p_flags & PFSHIELD)) {
	/*-----------Colored shields by shield damage--------*/

	int     color = playerColor(j);
	if (show_shield_dam && j == me) {
	    float   ft;

	    ft = (float) j->p_shield / (float) j->p_ship->s_maxshield;
	    if (ft > 0.66)
		color = gColor;
	    else if (ft > 0.33)
		color = yColor;
	    else if (j->p_shield > 5)
		color = rColor;
	    else
		color = unColor;
	}
#if 0				/* shields the alert color, ick */
	switch (me->p_flags & (PFGREEN | PFYELLOW | PFRED)) {
	case PFGREEN:
	    color = gColor;
	    break;
	case PFYELLOW:
	    color = yColor;
	    break;
	    /* red shield tough to see */
	case PFRED:
	    color = playerColor(j);
	    break;
	}
#endif
	W_WriteBitmap(dx - (ship_bits->width / 2),
		      dy - (ship_bits->height / 2),
		      ship_bits->shield, color);
    }
}

#ifdef VARY_HULL
void
doHull(dx, dy, ship_bits, j)
    int     dx, dy;
    struct ship_shape *ship_bits;
    struct player *j;
{
    if (j == me && vary_hull) {
	int     hull_left = (100 * (me->p_ship->s_maxdamage -
		     me->p_damage)) / me->p_ship->s_maxdamage, hull_num = 7;
	int     hull_color;

	if (hull_left <= 16) {
	    hull_num = 0;
	    hull_color = W_Red;
	} else if (hull_left <= 28) {
	    hull_num = 1;
	    hull_color = W_Red;
	} else if (hull_left <= 40) {
	    hull_num = 2;
	    hull_color = W_Red;
	} else if (hull_left <= 52) {
	    hull_num = 3;
	    hull_color = W_Yellow;
	} else if (hull_left <= 64) {
	    hull_num = 4;
	    hull_color = W_Yellow;
	} else if (hull_left <= 76) {
	    hull_num = 5;
	    hull_color = W_Yellow;
	} else if (hull_left <= 88) {
	    hull_num = 6;
	    hull_color = W_Green;
	} else
	    hull_color = W_Green /* playerColor (j) */ ;

	W_WriteBitmap(dx - (ship_bits->width / 2 + 1),
		      dy - (ship_bits->height / 2 + 1),
		      hull[hull_num], hull_color);
    }
}
#endif				/* VARY_HULL */