Пример #1
0
	/* compute time for a given angle G */
	double compute_time(double g, double t)
	{
		double d = sun_declination(julian_date + t);
		double z = compute_mid_day(t);
		double v = 1.0 / 15.0 * darccos((-dsin(g) - dsin(d) * dsin(latitude)) / (dcos(d) * dcos(latitude)));
		return z + (g > 90.0 ? - v :  v);
	}
Пример #2
0
static double meanphase(double sdate, double phase, double *usek)
{
    double k, t, t2, t3, nt1;

/*** The following was the original code:  It gave roundoff errors
  causing moonphase info to fail for Dec 1994.  ***/
/*    jyear(sdate, &yy, &mm, &dd);
      k = (yy + (mm/12.0) - 1900) * 12.368531; */

/*** The next line is the replacement ***/
    k = (sdate - 2415020.0) / synmonth;

    /* Time in Julian centuries from 1900 January 0.5 */
    t = (sdate - 2415020.0) / 36525.0;
    t2 = t * t;		   /* Square for frequent use */
    t3 = t2 * t;		   /* Cube for frequent use */

    *usek = k = floor(k) + phase;
    nt1 = 2415020.75933 + synmonth * k
	+ 0.0001178 * t2
	- 0.000000155 * t3
	+ 0.00033 * dsin(166.56 + 132.87 * t - 0.009173 * t2);

    return nt1;
}
Пример #3
0
	float Animator::_calculateValue(float k)
	{
		if (this->delay > 0.0f)
		{
			return (this->discreteStep != 0 ? (float)((int)(this->offset / this->discreteStep) * this->discreteStep) : this->offset);
		}
		float time = this->timer;
		if (this->isExpired())
		{
			if (this->reset)
			{
				return (this->discreteStep != 0 ? (float)((int)(this->offset / this->discreteStep) * this->discreteStep) : this->offset);
			}
			time = this->periods / habs(this->speed);
		}
		float result = 0.0f;
		switch (this->animationFunction)
		{
		case Object::Linear:
			result = time * this->speed * this->amplitude;
			break;
		case Object::Sine:
			result = (float)dsin(time * this->speed * 360) * this->amplitude;
			break;
		case Object::Square:
			result = (hmodf(time * this->speed, 1.0f) < 0.5f ? this->amplitude : -this->amplitude);
			break;
		case Object::Saw:
			result = (hmodf(time * this->speed + 0.5f, 1.0f) - 0.5f) * 2 * this->amplitude;
			break;
		case Object::Triangle:
			result = hmodf(time * this->speed, 1.0f);
			if (!is_in_range(result, 0.25f, 0.75f))
			{
				result = (hmodf(time * this->speed + 0.5f, 1.0f) - 0.5f) * 4 * this->amplitude;
			}
			else
			{
				result = -(hmodf(time * this->speed - 0.25f, 1.0f) - 0.25f) * 4 * this->amplitude;
			}
			break;
		case Object::Random:
			result = hrandf(-this->speed * this->amplitude, this->speed * this->amplitude);
			break;
		case Object::Hover:
			if ((this->amplitude >= 0.0f) == this->parent->isCursorInside())
			{
				result = hmin(this->value - this->offset + k * this->speed, (float)habs(this->amplitude));
			}
			else
			{
				result = hmax(this->value - this->offset - k * this->speed, -(float)habs(this->amplitude));
			}
			break;
		case Object::Custom:
			result = (this->customFunction != NULL ? this->customFunction(this, time) : this->value);
			break;
		}
		return (this->discreteStep != 0 ? (float)((int)((result + this->offset) / this->discreteStep) * this->discreteStep) : (result + this->offset));
	}
Пример #4
0
	/* compute declination angle of sun and equation of time */
	DoublePair sun_position(double jd)
	{
		double d = jd - 2451545.0;
		double g = fix_angle(357.529 + 0.98560028 * d);
		double q = fix_angle(280.459 + 0.98564736 * d);
		double l = fix_angle(q + 1.915 * dsin(g) + 0.020 * dsin(2 * g));

		// double r = 1.00014 - 0.01671 * dcos(g) - 0.00014 * dcos(2 * g);
		double e = 23.439 - 0.00000036 * d;

		double dd = darcsin(dsin(e) * dsin(l));
		double ra = darctan2(dcos(e) * dsin(l), dcos(l)) / 15.0;
		ra = fix_hour(ra);
		double eq_t = q / 15.0 - ra;

		return DoublePair(dd, eq_t);
	}
Пример #5
0
dboolean G_CheckSpot(int playernum, mapthing_t* mthing) {
    fixed_t         x;
    fixed_t         y;
    subsector_t*    ss;
    angle_t         an;
    mobj_t*         mo;
    int             i;

    if(!players[playernum].mo) {
        // first spawn of level, before corpses
        for(i = 0; i < playernum; i++) {
            if((players[i].mo->x == INT2F(mthing->x)) && (players[i].mo->y == INT2F(mthing->y))) {
                return false;
            }
        }
        return true;
    }

    x = INT2F(mthing->x);
    y = INT2F(mthing->y);

    if(!P_CheckPosition(players[playernum].mo, x, y)) {
        return false;
    }

    // flush an old corpse if needed
    if(bodyqueslot >= BODYQUESIZE) {
        P_RemoveMobj(bodyque[bodyqueslot % BODYQUESIZE]);
    }

    bodyque[bodyqueslot%BODYQUESIZE] = players[playernum].mo;
    bodyqueslot++;

    // spawn a teleport fog
    ss = R_PointInSubsector(x, y);

    // 20120402 villsa - force angle_t typecast to avoid issues on 64-bit machines
    an = ANG45 * (angle_t)(mthing->angle / 45);

    mo = P_SpawnMobj(
             x + 20*dcos(an),
             y + 20*dsin(an),
             ss->sector->floorheight,
             MT_TELEPORTFOG
         );

    if(players[playernum].viewz != 1) {
        S_StartSound(mo, sfx_telept);    // don't start sound on first frame
    }

    return true;
}
Пример #6
0
static double
meanphase( double sdate, double phase, double *usek, int *cnt )
{
    long            yy, mm, dd;
    double          k, t, t2, t3, nt1;
    double          preK;
    static double   preNt1 = 0.0;

    jyear(sdate, &yy, &mm, &dd);

    preK = k = (yy + ((mm - 1L) * (1.0 / 12.0)) - 1900.0) * 12.3685;

    /* Time in Julian centuries from 1900 January 0.5 */
    t  = (sdate - 2415020.0) / 36525.64;
    t2 = t * t;                /* Square for frequent use */
    t3 = t2 * t;               /* Cube for frequent use */

    *usek = k = floor(k) + phase;
    nt1 = 2415020.75933 + synmonth * k
              + 0.0001178 * t2
              - 0.000000155 * t3
              + 0.00033 * dsin(166.56 + 132.87 * t - 0.009173 * t2);

    if ( *cnt >= 1 ) {
        /* printf( "nt1 = %f, preNt1 = %f\n", nt1, preNt1 ); */
        if ( nt1 - preNt1 > 45.0 ) {
            *usek = k = floor(preK) - 1.0;
            nt1 = 2415020.75933 + synmonth * k
                      + 0.0001178 * t2
                      - 0.000000155 * t3
                      + 0.00033 * dsin(166.56 + 132.87 * t - 0.009173 * t2);
        }
    }
    (*cnt)++;
    preNt1 = nt1;

    return nt1;
}
Пример #7
0
static CMD(SpawnThing) {
    int id = 0;
    player_t *player;
    mobj_t *thing;
    fixed_t x, y, z;

    if(gamestate != GS_LEVEL) {
        return;
    }

    if(!param[0]) {
        return;
    }

    if(netgame) {
        return;
    }

    id = datoi(param[0]);
    if(id >= NUMMOBJTYPES || id < 0) {
        return;
    }

    player = &players[consoleplayer];
    x = player->mo->x + FixedMul(INT2F(64) + mobjinfo[id].radius, dcos(player->mo->angle));
    y = player->mo->y + FixedMul(INT2F(64) + mobjinfo[id].radius, dsin(player->mo->angle));
    z = player->mo->z;

    thing = P_SpawnMobj(x, y, z, id);

    if(thing->info->spawnstate == S_000) {
        P_RemoveMobj(thing);
        return;
    }

    thing->angle = player->mo->angle;
}
Пример #8
0
FBCALL void fb_GfxDraw(void *target, FBSTRING *command)
{
	FB_GFXCTX *context;
	float x, y, dx, dy, ax, ay, x2, y2;
	int angle = 0, diagonal = FALSE;
	char *c;
	intptr_t value1, value2;
	int draw = TRUE, move = TRUE, length = 0, flags, rel;

	FB_GRAPHICS_LOCK( );

	if ((!__fb_gfx) || (!command) || (!command->data)) {
		if (command)
			fb_hStrDelTemp(command);
		FB_GRAPHICS_UNLOCK( );
		return;
	}

	context = fb_hGetContext( );
	fb_hPrepareTarget(context, target);
	fb_hSetPixelTransfer(context, MASK_A_32);

	x = context->last_x;
	y = context->last_y;

	DRIVER_LOCK();

	flags = context->flags;
	context->flags |= CTX_VIEW_SCREEN;

	for (c = command->data; *c;) {
		switch (toupper(*c)) {
			case 'B':
				c++;
				draw = FALSE;
				break;

			case 'N':
				c++;
				move = FALSE;
				break;

			case 'C':
				c++;
				if ((value1 = parse_number(&c)) == FB_NAN)
					goto error;
				context->fg_color = fb_hFixColor(context->target_bpp, value1);
				break;

			case 'S':
				c++;
				if ((value1 = parse_number(&c)) == FB_NAN)
					goto error;
				base_scale = (float)value1 / 4.0;
				break;

			case 'A':
				c++;
				if ((value1 = parse_number(&c)) == FB_NAN)
					goto error;
				base_angle = (value1 & 0x3) * 90;
				break;

			case 'T':
				c++;
				if (toupper(*c) != 'A')
					goto error;
				c++;
				if ((value1 = parse_number(&c)) == FB_NAN)
					goto error;
				base_angle = mod360( value1 );
				break;

			case 'X':
				c++;
				/* Here we could be more severe with checking, but it's unlikely our substring
				 * resides at location FB_NAN (0x80000000) */
				if ((value1 = parse_number(&c)) == FB_NAN)
					goto error;

				/* Store our current x/y for the recursive fb_GfxDraw() call */
				context->last_x = x;
				context->last_y = y;

				DRIVER_UNLOCK();
				fb_GfxDraw(target, (FBSTRING *)value1);
				DRIVER_LOCK();

				/* And update to x/y produced by the recursive fb_GfxDraw() call */
				x = context->last_x;
				y = context->last_y;

				break;

			case 'P':
				c++;
				if ((value1 = parse_number(&c)) == FB_NAN)
					goto error;
				value2 = value1;
				if (*c == ',') {
					c++;
					if ((value2 = parse_number(&c)) == FB_NAN)
						goto error;
				}
				DRIVER_UNLOCK();
				fb_GfxPaint(target, x, y, value1 & __fb_gfx->color_mask, value2 & __fb_gfx->color_mask, NULL, PAINT_TYPE_FILL, COORD_TYPE_A);
				DRIVER_LOCK();
				break;

			case 'M':
				c++;
				while ((*c == ' ') || (*c == '\t'))
					c++;
				rel = ((*c == '+') || (*c == '-'));
				if ((value1 = parse_number(&c)) == FB_NAN)
					goto error;
				if (*c++ != ',')
					goto error;
				if ((value2 = parse_number(&c)) == FB_NAN)
					goto error;
				x2 = (float)value1;
				y2 = (float)value2;
				if (rel) {
					ax = dcos(base_angle);
					ay = -dsin(base_angle);
					dx = x2;
					dy = y2;
					x2 = (((dx * ax) - (dy * ay)) * base_scale) + x;
					y2 = (((dy * ax) + (dx * ay)) * base_scale) + y;
				}
				if (draw) {
					DRIVER_UNLOCK();
					fb_GfxLine(target, (int)x, (int)y, (int)x2, (int)y2, 0, LINE_TYPE_LINE, 0xFFFF, COORD_TYPE_AA | DEFAULT_COLOR_1);
					DRIVER_LOCK();
				}
				if (move) {
					x = x2;
					y = y2;
				}
				move = draw = TRUE;
				break;

			case 'F': case 'D': angle += 90;
			case 'G': case 'L': angle += 90;
			case 'H': case 'U': angle += 90;
			case 'E': case 'R':
				diagonal = ((toupper(*c) >= 'E') && (toupper(*c) <= 'H'));
				c++;
				if ((value1 = parse_number(&c)) != FB_NAN)
					length = value1;
				else
					length = 1;

				angle = mod360( angle + base_angle );
				dx = (float)length * base_scale * dcos( angle );
				dy = (float)length * base_scale * -dsin( angle );

				if (diagonal) {
					x2 = x + (dx + dy);
					y2 = y + (dy - dx);
				}
				else {
					x2 = x + dx;
					y2 = y + dy;
				}
				if (draw) {
					fb_GfxDrawLine( context, CINT(x), CINT(y), CINT(x2), CINT(y2), context->fg_color, 0xffff );
				}
				if (move) {
					x = x2;
					y = y2;
				}

				angle = 0;
				move = draw = TRUE;
				break;

			default:
				c++;
				break;
		}
	}

	context->last_x = x;
	context->last_y = y;

error:
	context->flags = flags;

	DRIVER_UNLOCK();

	/* del if temp */
	fb_hStrDelTemp( command );

	FB_GRAPHICS_UNLOCK( );
}
Пример #9
0
static double
truephase( double k, double phase )
{
    double  t, t2, t3, pt, m, mprime, f;
    int     apcor = FALSE;

    k += phase;                /* Add phase to new moon time */
    t = k / 1236.85;           /* Time in Julian centuries from
                                  1900 January 0.5 */
    t2 = t * t;                /* Square for frequent use */
    t3 = t2 * t;               /* Cube for frequent use */
    pt = 2415020.75933         /* Mean time of phase */
             + synmonth * k
             + 0.0001178 * t2
             - 0.000000155 * t3
             + 0.00033 * dsin(166.56 + 132.87 * t - 0.009173 * t2);

    m = 359.2242               /* Sun's mean anomaly */
            + 29.10535608 * k
            - 0.0000333 * t2
            - 0.00000347 * t3;
    mprime = 306.0253          /* Moon's mean anomaly */
                 + 385.81691806 * k
                 + 0.0107306 * t2
                 + 0.00001236 * t3;
    f = 21.2964                /* Moon's argument of latitude */
            + 390.67050646 * k
            - 0.0016528 * t2
            - 0.00000239 * t3;
    if ((phase < 0.01) || (abs(phase - 0.5) < 0.01)) {
        /* Corrections for New and Full Moon */
        pt += (0.1734 - 0.000393 * t) * dsin(m)
                  + 0.0021 * dsin(2 * m)
                  - 0.4068 * dsin(mprime)
                  + 0.0161 * dsin(2 * mprime)
                  - 0.0004 * dsin(3 * mprime)
                  + 0.0104 * dsin(2 * f)
                  - 0.0051 * dsin(m + mprime)
                  - 0.0074 * dsin(m - mprime)
                  + 0.0004 * dsin(2 * f + m)
                  - 0.0004 * dsin(2 * f - m)
                  - 0.0006 * dsin(2 * f + mprime)
                  + 0.0010 * dsin(2 * f - mprime)
                  + 0.0005 * dsin(m + 2 * mprime);
        apcor = TRUE;
    }
    else if ((abs(phase - 0.25) < 0.01 || (abs(phase - 0.75) < 0.01))) {
        pt += (0.1721 - 0.0004 * t) * dsin(m)
                  + 0.0021 * dsin(2 * m)
                  - 0.6280 * dsin(mprime)
                  + 0.0089 * dsin(2 * mprime)
                  - 0.0004 * dsin(3 * mprime)
                  + 0.0079 * dsin(2 * f)
                  - 0.0119 * dsin(m + mprime)
                  - 0.0047 * dsin(m - mprime)
                  + 0.0003 * dsin(2 * f + m)
                  - 0.0004 * dsin(2 * f - m)
                  - 0.0006 * dsin(2 * f + mprime)
                  + 0.0021 * dsin(2 * f - mprime)
                  + 0.0003 * dsin(m + 2 * mprime)
                  + 0.0004 * dsin(m - 2 * mprime)
                  - 0.0003 * dsin(2 * m + mprime);
        if (phase < 0.5)
            /* First quarter correction */
            pt += 0.0028 - 0.0004 * dcos(m) + 0.0003 * dcos(mprime);
        else
            /* Last quarter correction */
            pt += -0.0028 + 0.0004 * dcos(m) - 0.0003 * dcos(mprime);
        apcor = TRUE;
    }
    if (!apcor) {
        fprintf(stderr, "TRUEPHASE called with invalid phase selector.\n");
        abort();
    }
    return pt;
}
Пример #10
0
void
d_scalar_scalar_1(void)
{
    // d(x,x)?

    if (equal(p1, p2)) {
        push(one);
        return;
    }

    // d(a,x)?

    if (!iscons(p1)) {
        push(zero);
        return;
    }

    if (isadd(p1)) {
        dsum();
        return;
    }

    if (car(p1) == symbol(MULTIPLY)) {
        dproduct();
        return;
    }

    if (car(p1) == symbol(POWER)) {
        dpower();
        return;
    }

    if (car(p1) == symbol(DERIVATIVE)) {
        dd();
        return;
    }

    if (car(p1) == symbol(LOG)) {
        dlog();
        return;
    }

    if (car(p1) == symbol(SIN)) {
        dsin();
        return;
    }

    if (car(p1) == symbol(COS)) {
        dcos();
        return;
    }

    if (car(p1) == symbol(TAN)) {
        dtan();
        return;
    }

    if (car(p1) == symbol(ARCSIN)) {
        darcsin();
        return;
    }

    if (car(p1) == symbol(ARCCOS)) {
        darccos();
        return;
    }

    if (car(p1) == symbol(ARCTAN)) {
        darctan();
        return;
    }

    if (car(p1) == symbol(SINH)) {
        dsinh();
        return;
    }

    if (car(p1) == symbol(COSH)) {
        dcosh();
        return;
    }

    if (car(p1) == symbol(TANH)) {
        dtanh();
        return;
    }

    if (car(p1) == symbol(ARCSINH)) {
        darcsinh();
        return;
    }

    if (car(p1) == symbol(ARCCOSH)) {
        darccosh();
        return;
    }

    if (car(p1) == symbol(ARCTANH)) {
        darctanh();
        return;
    }

    if (car(p1) == symbol(ABS)) {
        dabs();
        return;
    }

    if (car(p1) == symbol(SGN)) {
        dsgn();
        return;
    }

    if (car(p1) == symbol(HERMITE)) {
        dhermite();
        return;
    }

    if (car(p1) == symbol(ERF)) {
        derf();
        return;
    }

    if (car(p1) == symbol(ERFC)) {
        derfc();
        return;
    }

    /*if (car(p1) == symbol(BESSELJ)) {
    	if (iszero(caddr(p1)))
    		dbesselj0();
    	else
    		dbesseljn();
    	return;
    }*/

    /*if (car(p1) == symbol(BESSELY)) {
    	if (iszero(caddr(p1)))
    		dbessely0();
    	else
    		dbesselyn();
    	return;
    }*/

    if (car(p1) == symbol(INTEGRAL) && caddr(p1) == p2) {
        derivative_of_integral();
        return;
    }

    dfunction();
}
Пример #11
0
void A_FireLaser(player_t *player, pspdef_t *psp)
{
    angle_t         angleoffs;
    angle_t         spread;
    mobj_t          *mobj;
    int             lasercount;
    int             i;
    fixed_t         slope;
    fixed_t         x;
    fixed_t         y;
    fixed_t         z;
    byte            type;
    laser_t         *laser[3];
    laserthinker_t  *laserthinker[3];
    //fixed_t         laserfrac;
    
    mobj = player->mo;
    
    lasercount  = 0;
    spread      = 0;
    angleoffs   = 0;
    
    // the original used a lookup table with the values "0, 1, 1, 2, 1, 2, 2, 3"
    // this is an alternative to using that table
    type = (byte)(((player->artifacts & 3) != 0) +
        ((player->artifacts & 3) == 3) + ((player->artifacts & 4) != 0));
    
    // setup laser type
    switch(type)
    {
    case 1:		// Rapid fire / single shot
        psp->tics = 5;
        lasercount = 1;
        angleoffs = mobj->angle;
        break;
    case 2:		// Rapid fire / double shot
        psp->tics = 4;
        lasercount = 2;
        angleoffs = mobj->angle + 0xFF4A0000;
        spread = 0x16C0000;
        break;
    case 3:		// Spread shot
        psp->tics = 4;
        lasercount = 3;
        spread = 0x2220000 + (0x2220000 * (player->refire & 3));
        angleoffs = mobj->angle - spread;
        break;
    default:	// Normal shot
        lasercount = 1;
        angleoffs = mobj->angle;
        break;
    }
    
    if(lasercount <= 0)
        return;
    
    laserCells = lasercount;
    
    // setup laser beams
    for(i = 0; i < lasercount; i++)
    {
        int	hitdice = 0;
        int	damage = 0;

        slope = P_AimLineAttack(mobj, angleoffs, LASERAIMHEIGHT, LASERRANGE);
        
        player->ammo[weaponinfo[player->readyweapon].ammo]--;
        
        //
        // [kex] 1/2/12 the old code is just plain bad. the original behavior was
        // to simply call P_AimLineAttack and use the intercept fraction to
        // determine where the tail end of the laser will land. this is
        // optimal for consoles but leads to a lot of issues when working with
        // plane hit detection and auto aiming. P_LineAttack will be called normally
        // and instead of spawning puffs or blood, the xyz values are stored so the
        // tail end of the laser can be setup properly here
        //

        // (unused) adjust aim fraction which will be used to determine
        // the endpoint of the laser
        /*if(aimfrac)
            laserfrac = (aimfrac << (FRACBITS - 4)) - (4 << FRACBITS);
        else
            laserfrac = 0x800;*/
            
        hitdice = (P_Random() & 7);
        damage = (((hitdice << 2) + hitdice) << 1) + 10;

        P_LineAttack(mobj, angleoffs, LASERRANGE, slope, damage);
        
        // setup laser
        laser[i] = Z_Malloc(sizeof(*laser[i]), PU_LEVSPEC, 0);

        // setup laser head point
        laser[i]->x1 = mobj->x + FixedMul(LASERDISTANCE, dcos(mobj->angle));
        laser[i]->y1 = mobj->y + FixedMul(LASERDISTANCE, dsin(mobj->angle));
        laser[i]->z1 = (mobj->z + LASERAIMHEIGHT);

        // setup laser tail point
        /*
        laser[i]->x2 = (FixedMul(dcos(angleoffs), laserfrac) + mobj->x);
        laser[i]->y2 = (FixedMul(dsin(angleoffs), laserfrac) + mobj->y);
        laser[i]->z2 = (FixedMul(slope, laserfrac) + (mobj->z + LASERAIMHEIGHT));
        */
        laser[i]->x2 = laserhit_x;
        laser[i]->y2 = laserhit_y;
        laser[i]->z2 = laserhit_z;

        // setup movement slope
        laser[i]->slopex = (dcos(angleoffs) << 5);
        laser[i]->slopey = (dsin(angleoffs) << 5);
        laser[i]->slopez = slope ? (slope << 5) : 0;

        // setup distance info
        x = (laser[i]->x1 - laser[i]->x2) >> FRACBITS;
        y = (laser[i]->y1 - laser[i]->y2) >> FRACBITS;
        z = (laser[i]->z1 - laser[i]->z2) >> FRACBITS;

        laser[i]->dist = 0;
        laser[i]->distmax = (int)sqrt((x * x) + (y * y) + (z * z));

        laser[i]->next = NULL;
        laser[i]->marker = NULL;

        laser[i]->angle = angleoffs;

        x = laser[i]->x2;
        y = laser[i]->y2;
        z = laser[i]->z2;

        P_LaserCrossBSP(numnodes - 1, laser[i]);

        laserthinker[i] = Z_Malloc(sizeof(*laserthinker[i]), PU_LEVSPEC, 0);
        P_AddThinker(&laserthinker[i]->thinker);

        laserthinker[i]->thinker.function.acp1 = (actionf_p1)T_LaserThinker;
        laserthinker[i]->dest = P_SpawnMobj(x, y, z, MT_PROJ_LASER);
        laserthinker[i]->laser = laser[i];
        
        /*if(linetarget)
        {
            int	hitdice = 0;
            int	damage = 0;
            
            hitdice = (P_Random() & 7);
            damage = (((hitdice << 2) + hitdice) << 1) + 10;
            P_DamageMobj(linetarget, mobj, mobj, damage);
        }
        else
            angleoffs += spread;*/

        if(!linetarget)
            angleoffs += spread;
    }
    
    S_StartSound(player->mo, sfx_laser);
    P_SetMobjState(player->mo, S_007);
    P_SetPsprite(player, ps_flash, weaponinfo[player->readyweapon].flashstate);
}
Пример #12
0
// Determines the flight path of the projectile
void project(double theta,double beta,int tank)
{
	double projx,projz;
	phy=1;
	const double fg=1;
	struct vector {
		double i,j,m;
	};
	vector P;

	if (turn==1) {
		p1mode=1;
		P.m=s1;
	}
	if (turn==2) {
		p2mode=1;
		P.m=s2;
	}

	P.i=P.m*dcos(theta);
	P.j=P.m*dsin(theta);
	printf("%f\n",P.i);
	if (tank==1) {
		projx=tank1x;
		height=tank1y;
		projz=tank1z;
	}
	else {
		projx=tank2x;
		height=tank2y;
		projz=tank2z;
	}

	// Delete the previous LL
	linelist *prev,*now=listf;
	while (now!=NULL) {
		prev=now;
		now=now->next;
		delete prev;
	}
	listf=new linelist;
	liste=new linelist;
	listf=liste;
	listf->next=liste;
	liste->next=NULL;


	do {
		projx+=(P.m*dcos(theta)*dsin(beta))/500;
		projz+=(P.m*dcos(theta)*dcos(beta))/500;
		height+=P.j/500;
		P.j-=fg;
		
		linelist *mlist=new linelist;
		mlist->xl=projx;
		mlist->yl=height;
		mlist->zl=projz;
		liste->next=mlist;
		liste=mlist;

	} while (!IsCollision(projx,projz));
	liste->next=NULL;
	xe=liste->xl;
	ze=liste->zl;
	if (tank==1)
		if ((xe>(tank2x-5)) && (xe<(tank2x+5)) && (ze>(tank2z-5)) && (ze<(tank2z+5)))
			win=1;
	if (tank==2)
		if ((xe>(tank1x-5)) && (xe<(tank1x+5)) && (ze>(tank1z-5)) && (ze<(tank1z+5)))
			win=2;
}
Пример #13
0
/* compute location of GRS and Galilean moons.
 * if md == NULL, just to cml.
 * from "Astronomical Formulae for Calculators", 2nd ed, by Jean Meeus,
 *   Willmann-Bell, Richmond, Va., U.S.A. (c) 1982, chapters 35 and 36.
 */
void
meeus_jupiter(
double d,
double *cmlI, double *cmlII,	/* central meridian longitude, rads */
MoonData md[J_NMOONS])	/* fill in md[1..NM-1].x/y/z for each moon.
			 * N.B. md[0].ra/dec must already be set
			 */
{
#define	dsin(x)	sin(degrad(x))
#define	dcos(x)	cos(degrad(x))
	double A, B, Del, J, K, M, N, R, V;
	double cor_u1, cor_u2, cor_u3, cor_u4;
	double solc, tmp, G, H, psi, r, r1, r2, r3, r4;
	double u1, u2, u3, u4;
	double lam, Ds;
	double z1, z2, z3,  z4;
	double De, dsinDe;
	double theta, phi;
	double tvc, pvc;
	double salpha, calpha;
	int i;

	V = 134.63 + 0.00111587 * d;

	M = (358.47583 + 0.98560003*d);
	N = (225.32833 + 0.0830853*d) + 0.33 * dsin (V);

	J = 221.647 + 0.9025179*d - 0.33 * dsin(V);

	A = 1.916*dsin(M) + 0.02*dsin(2*M);
	B = 5.552*dsin(N) + 0.167*dsin(2*N);
	K = (J+A-B);
	R = 1.00014 - 0.01672 * dcos(M) - 0.00014 * dcos(2*M);
	r = 5.20867 - 0.25192 * dcos(N) - 0.00610 * dcos(2*N);
	Del = sqrt (R*R + r*r - 2*R*r*dcos(K));
	psi = raddeg (asin (R/Del*dsin(K)));

	*cmlI  = degrad(268.28 + 877.8169088*(d - Del/173) + psi - B);
	range (cmlI, 2*PI);
	*cmlII = degrad(290.28 + 870.1869088*(d - Del/173) + psi - B);
	range (cmlII, 2*PI);

	/* that's it if don't want moon info too */
	if (!md)
	    return;

	solc = (d - Del/173.);	/* speed of light correction */
	tmp = psi - B;

	u1 = 84.5506 + 203.4058630 * solc + tmp;
	u2 = 41.5015 + 101.2916323 * solc + tmp;
	u3 = 109.9770 + 50.2345169 * solc + tmp;
	u4 = 176.3586 + 21.4879802 * solc + tmp;

	G = 187.3 + 50.310674 * solc;
	H = 311.1 + 21.569229 * solc;
      
	cor_u1 =  0.472 * dsin (2*(u1-u2));
	cor_u2 =  1.073 * dsin (2*(u2-u3));
	cor_u3 =  0.174 * dsin (G);
	cor_u4 =  0.845 * dsin (H);
      
	r1 = 5.9061 - 0.0244 * dcos (2*(u1-u2));
	r2 = 9.3972 - 0.0889 * dcos (2*(u2-u3));
	r3 = 14.9894 - 0.0227 * dcos (G);
	r4 = 26.3649 - 0.1944 * dcos (H);

	md[1].x = -r1 * dsin (u1+cor_u1);
	md[2].x = -r2 * dsin (u2+cor_u2);
	md[3].x = -r3 * dsin (u3+cor_u3);
	md[4].x = -r4 * dsin (u4+cor_u4);

	lam = 238.05 + 0.083091*d + 0.33*dsin(V) + B;
	Ds = 3.07*dsin(lam + 44.5);
	De = Ds - 2.15*dsin(psi)*dcos(lam+24.)
		- 1.31*(r-Del)/Del*dsin(lam-99.4);
	dsinDe = dsin(De);

	z1 = r1 * dcos(u1+cor_u1);
	z2 = r2 * dcos(u2+cor_u2);
	z3 = r3 * dcos(u3+cor_u3);
	z4 = r4 * dcos(u4+cor_u4);

	md[1].y = z1*dsinDe;
	md[2].y = z2*dsinDe;
	md[3].y = z3*dsinDe;
	md[4].y = z4*dsinDe;

	/* compute sky transformation angle as triple vector product */
	tvc = PI/2.0 - md[0].dec;
	pvc = md[0].ra;
	theta = PI/2.0 - POLE_DEC;
	phi = POLE_RA;
	salpha = -sin(tvc)*sin(theta)*(cos(pvc)*sin(phi) - sin(pvc)*cos(phi));
	calpha = sqrt (1.0 - salpha*salpha);

	for (i = 0; i < J_NMOONS; i++) {
	    double tx =  md[i].x*calpha + md[i].y*salpha;
	    double ty = -md[i].x*salpha + md[i].y*calpha;
	    md[i].x = tx;
	    md[i].y = ty;
	}

	md[1].z = z1;
	md[2].z = z2;
	md[3].z = z3;
	md[4].z = z4;
}