当前位置: 首页>>代码示例>>C++>>正文


C++ FixedMul函数代码示例

本文整理汇总了C++中FixedMul函数的典型用法代码示例。如果您正苦于以下问题:C++ FixedMul函数的具体用法?C++ FixedMul怎么用?C++ FixedMul使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了FixedMul函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: A_Tracer2

void A_Tracer2 (AActor *self)
{
	AActor *dest;
	angle_t exact;
	fixed_t dist;
	fixed_t slope;

	dest = self->tracer;

	if (dest == NULL || dest->health <= 0 || self->Speed == 0)
		return;

	// change angle
	exact = R_PointToAngle2 (self->x, self->y, dest->x, dest->y);

	if (exact != self->angle)
	{
		if (exact - self->angle > 0x80000000)
		{
			self->angle -= TRACEANGLE;
			if (exact - self->angle < 0x80000000)
				self->angle = exact;
		}
		else
		{
			self->angle += TRACEANGLE;
			if (exact - self->angle > 0x80000000)
				self->angle = exact;
		}
	}

	exact = self->angle >> ANGLETOFINESHIFT;
	self->momx = FixedMul (self->Speed, finecosine[exact]);
	self->momy = FixedMul (self->Speed, finesine[exact]);

	// change slope
	dist = P_AproxDistance (dest->x - self->x, dest->y - self->y);
	dist /= self->Speed;

	if (dist < 1)
	{
		dist = 1;
	}
	if (dest->height >= 56*FRACUNIT)
	{
		slope = (dest->z+40*FRACUNIT - self->z) / dist;
	}
	else
	{
		slope = (dest->z + self->height*2/3 - self->z) / dist;
	}
	if (slope < self->momz)
	{
		self->momz -= FRACUNIT/8;
	}
	else
	{
		self->momz += FRACUNIT/8;
	}
}
开发者ID:ddraigcymraeg,项目名称:gzscoredoom,代码行数:60,代码来源:a_spectral.cpp

示例2: TPS

//=============================================================================
static void HW3S_FillSourceParameters
                              (const mobj_t     *origin,
                               source3D_data_t  *data,
                               channel_type_t   c_type)
{
	fixed_t x = 0, y = 0, z = 0;

	data->max_distance = MAX_DISTANCE;
	data->min_distance = MIN_DISTANCE;

	if (origin && origin != players[displayplayer].mo)
	{
		data->head_relative = false;

		data->pos.momx = TPS(FIXED_TO_FLOAT(origin->momx));
		data->pos.momy = TPS(FIXED_TO_FLOAT(origin->momy));
		data->pos.momz = TPS(FIXED_TO_FLOAT(origin->momz));

		x = origin->x;
		y = origin->y;
		z = origin->z;

		if (c_type == CT_ATTACK)
		{
			const angle_t an = origin->angle >> ANGLETOFINESHIFT;
			x += FixedMul(16*FRACUNIT, FINECOSINE(an));
			y += FixedMul(16*FRACUNIT, FINESINE(an));
			z += origin->height >> 1;
		}

		else if (c_type == CT_SCREAM)
开发者ID:Pupswoof117,项目名称:SRB2-Public,代码行数:32,代码来源:hw3sound.c

示例3: DEFINE_ACTION_FUNCTION

DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump)
{
	fixed_t dist;
	fixed_t speed;
	angle_t an;

	if (self->target == NULL)
		return;

	S_Sound (self, CHAN_ITEM|CHAN_LOOP, "inquisitor/jump", 1, ATTN_NORM);
	self->AddZ(64*FRACUNIT);
	A_FaceTarget (self);
	an = self->angle >> ANGLETOFINESHIFT;
	speed = self->Speed * 2/3;
	self->velx += FixedMul (speed, finecosine[an]);
	self->vely += FixedMul (speed, finesine[an]);
	dist = self->AproxDistance (self->target);
	dist /= speed;
	if (dist < 1)
	{
		dist = 1;
	}
	self->velz = (self->target->Z() - self->Z()) / dist;
	self->reactiontime = 60;
	self->flags |= MF_NOGRAVITY;
}
开发者ID:loismustdie555,项目名称:GZDoom-GPL,代码行数:26,代码来源:a_inquisitor.cpp

示例4: P_GetZAt

//
// P_GetZAt
//
// Returns the height of the sloped plane at (x, y) as a fixed_t
//
fixed_t P_GetZAt(pslope_t *slope, fixed_t x, fixed_t y)
{
   fixed_t dist = FixedMul(x - slope->o.x, slope->d.x) +
                  FixedMul(y - slope->o.y, slope->d.y);

   return slope->o.z + FixedMul(dist, slope->zdelta);
}
开发者ID:Altazimuth,项目名称:eternity,代码行数:12,代码来源:p_slopes.cpp

示例5: PTR_chaseTraverse

//
// PTR_chaseTraverse
//
// go til you hit a wall
// set the chasecam target x and ys if you hit one
// originally based on the shooting traverse function in p_maputl.c
//
static bool PTR_chaseTraverse(intercept_t *in)
{
   fixed_t dist, frac;
   subsector_t *ss;
   int x, y;
   int z;
   sector_t *othersector;

   if(in->isaline)
   {
      line_t *li = in->d.line;
      
      dist = FixedMul(trace.attackrange, in->frac);
      frac = in->frac - FixedDiv(12*FRACUNIT, trace.attackrange);
      
      // hit line
      // position a bit closer
      
      x = trace.dl.x + FixedMul(trace.dl.dx, frac);
      y = trace.dl.y + FixedMul(trace.dl.dy, frac);

      // ioanch 20160225: portal lines are currently not crossed
      if(li->flags & ML_TWOSIDED && !(li->pflags & PS_PASSABLE))
      {  // crosses a two sided line

         // sf: find which side it hit
         
         ss = R_PointInSubsector (x, y);
         
         othersector = li->backsector;
         
         if(ss->sector==li->backsector)      // other side
            othersector = li->frontsector;

         // interpolate, find z at the point of intersection
         
         z = zi(dist, trace.attackrange, targetz, playermobj->z+28*FRACUNIT);
         
         // found which side, check for intersections
         if((li->flags & ML_BLOCKING) || 
            (othersector->floorheight>z) || (othersector->ceilingheight<z)
            || (othersector->ceilingheight-othersector->floorheight
                < 40*FRACUNIT));          // hit
         else
         {
            return true;    // continue
         }
      }

      targetx = x;        // point the new chasecam target at the intersection
      targety = y;
      targetz = zi(dist, trace.attackrange, targetz, playermobj->z+28*FRACUNIT);
      
      // don't go any farther
      
      return false;
   }
   
   return true;
}
开发者ID:Blastfrog,项目名称:eternity,代码行数:67,代码来源:p_chase.cpp

示例6: FV_Magnitude

fixed_t FV_Magnitude(const vector_t *a_normal)
{
	INT32 xs = FixedMul(a_normal->x,a_normal->x);
	INT32 ys = FixedMul(a_normal->y,a_normal->y);
	INT32 zs = FixedMul(a_normal->z,a_normal->z);
	return FixedSqrt(xs+ys+zs);
}
开发者ID:Pupswoof117,项目名称:SRB2-Public,代码行数:7,代码来源:m_fixed.c

示例7: FM_CreateObjectMatrix

//
// CreateObjectMatrix
//
// Creates a matrix that can be used for
// adjusting the position of an object
//
void FM_CreateObjectMatrix(matrix_t *matrix, fixed_t x, fixed_t y, fixed_t z, fixed_t anglex, fixed_t angley, fixed_t anglez, fixed_t upx, fixed_t upy, fixed_t upz, fixed_t radius)
{
	vector_t upcross;
	vector_t upvec;
	vector_t basevec;

	FV_Load(&upvec, upx, upy, upz);
	FV_Load(&basevec, anglex, angley, anglez);
	FV_Cross(&upvec, &basevec, &upcross);
	FV_Normalize(&upcross);

	FM_LoadIdentity(matrix);

	matrix->m[0] = upcross.x;
	matrix->m[1] = upcross.y;
	matrix->m[2] = upcross.z;
	matrix->m[3] = 0*FRACUNIT;

	matrix->m[4] = upx;
	matrix->m[5] = upy;
	matrix->m[6] = upz;
	matrix->m[7] = 0;

	matrix->m[8] = anglex;
	matrix->m[9] = angley;
	matrix->m[10] = anglez;
	matrix->m[11] = 0;

	matrix->m[12] = x - FixedMul(upx,radius);
	matrix->m[13] = y - FixedMul(upy,radius);
	matrix->m[14] = z - FixedMul(upz,radius);
	matrix->m[15] = FRACUNIT;
}
开发者ID:Pupswoof117,项目名称:SRB2-Public,代码行数:39,代码来源:m_fixed.c

示例8: FixedMul

vector_t *FV_MulEx(const vector_t *a_i, fixed_t a_c, vector_t *a_o)
{
	a_o->x = FixedMul(a_i->x, a_c);
	a_o->y = FixedMul(a_i->y, a_c);
	a_o->z = FixedMul(a_i->z, a_c);
	return a_o;
}
开发者ID:Pupswoof117,项目名称:SRB2-Public,代码行数:7,代码来源:m_fixed.c

示例9: FV_Distance

fixed_t FV_Distance(const vector_t *p1, const vector_t *p2)
{
	INT32 xs = FixedMul(p2->x-p1->x,p2->x-p1->x);
	INT32 ys = FixedMul(p2->y-p1->y,p2->y-p1->y);
	INT32 zs = FixedMul(p2->z-p1->z,p2->z-p1->z);
	return FixedSqrt(xs+ys+zs);
}
开发者ID:Pupswoof117,项目名称:SRB2-Public,代码行数:7,代码来源:m_fixed.c

示例10: FixedHypot

fixed_t FixedHypot(fixed_t x, fixed_t y)
{
#ifdef HAVE_HYPOT
	const float fx = FIXED_TO_FLOAT(x);
	const float fy = FIXED_TO_FLOAT(y);
	float fz;
#ifdef HAVE_HYPOTF
	fz = hypotf(fx, fy);
#else
	fz = (float)hypot(fx, fy);
#endif
	return FLOAT_TO_FIXED(fz);
#else // !HAVE_HYPOT
	fixed_t ax, yx, yx2, yx1;
	if (abs(y) > abs(x)) // |y|>|x|
	{
		ax = abs(y); // |y| => ax
		yx = FixedDiv(x, y); // (x/y)
	}
	else // |x|>|y|
	{
		ax = abs(x); // |x| => ax
		yx = FixedDiv(y, x); // (x/y)
	}
	yx2 = FixedMul(yx, yx); // (x/y)^2
	yx1 = FixedSqrt(1+FRACUNIT + yx2); // (1 + (x/y)^2)^1/2
	return FixedMul(ax, yx1); // |x|*((1 + (x/y)^2)^1/2)
#endif
}
开发者ID:Pupswoof117,项目名称:SRB2-Public,代码行数:29,代码来源:m_fixed.c

示例11: CTF_MoveFlags

//
//	[Toke - CTF] CTF_MoveFlag
//	Moves the flag that is linked to a player
//
void CTF_MoveFlags ()
{
	// denis - flag is now a boolean
	for(size_t i = 0; i < NUMFLAGS; i++)
	{
		if(CTFdata[i].flagger && CTFdata[i].actor)
		{
			player_t &player = idplayer(CTFdata[i].flagger);
			AActor *flag = CTFdata[i].actor;

			if(!player.mo)
			{
				flag->UnlinkFromWorld ();
				return;
			}

			extern fixed_t tmfloorz;
			extern fixed_t tmceilingz;

			unsigned an = player.mo->angle >> ANGLETOFINESHIFT;
			fixed_t x = (player.mo->x + FixedMul (-2*FRACUNIT, finecosine[an]));
			fixed_t y = (player.mo->y + FixedMul (-2*FRACUNIT, finesine[an]));

			P_CheckPosition (player.mo, player.mo->x, player.mo->y);
			flag->UnlinkFromWorld ();

			flag->x = x;
			flag->y = y;
			flag->z = player.mo->z;
			flag->floorz = tmfloorz;
			flag->ceilingz = tmceilingz;

			flag->LinkToWorld ();
		}
	}
开发者ID:JohnnyonFlame,项目名称:odamex,代码行数:39,代码来源:cl_ctf.cpp

示例12: A_VolcBallImpact

void A_VolcBallImpact (AActor *ball)
{
	int i;
	AActor *tiny;
	angle_t angle;

	if (ball->z <= ball->floorz)
	{
		ball->flags |= MF_NOGRAVITY;
		ball->gravity = FRACUNIT;
		ball->z += 28*FRACUNIT;
		//ball->momz = 3*FRACUNIT;
	}
	P_RadiusAttack (ball, ball->target, 25, 25, NAME_Fire, true);
	for (i = 0; i < 4; i++)
	{
		tiny = Spawn<AVolcanoTBlast> (ball->x, ball->y, ball->z, ALLOW_REPLACE);
		tiny->target = ball;
		angle = i*ANG90;
		tiny->angle = angle;
		angle >>= ANGLETOFINESHIFT;
		tiny->momx = FixedMul (FRACUNIT*7/10, finecosine[angle]);
		tiny->momy = FixedMul (FRACUNIT*7/10, finesine[angle]);
		tiny->momz = FRACUNIT + (pr_impact() << 9);
		P_CheckMissileSpawn (tiny);
	}
}
开发者ID:ddraigcymraeg,项目名称:gzscoredoom,代码行数:27,代码来源:a_hereticmisc.cpp

示例13: DEFINE_ACTION_FUNCTION

DEFINE_ACTION_FUNCTION(AActor, A_VolcBallImpact)
{
	unsigned int i;
	AActor *tiny;
	angle_t angle;

	if (self->z <= self->floorz)
	{
		self->flags |= MF_NOGRAVITY;
		self->gravity = FRACUNIT;
		self->z += 28*FRACUNIT;
		//self->velz = 3*FRACUNIT;
	}
	P_RadiusAttack (self, self->target, 25, 25, NAME_Fire, RADF_HURTSOURCE);
	for (i = 0; i < 4; i++)
	{
		tiny = Spawn("VolcanoTBlast", self->x, self->y, self->z, ALLOW_REPLACE);
		tiny->target = self;
		angle = i*ANG90;
		tiny->angle = angle;
		angle >>= ANGLETOFINESHIFT;
		tiny->velx = FixedMul (FRACUNIT*7/10, finecosine[angle]);
		tiny->vely = FixedMul (FRACUNIT*7/10, finesine[angle]);
		tiny->velz = FRACUNIT + (pr_volcimpact() << 9);
		P_CheckMissileSpawn (tiny, self->radius);
	}
}
开发者ID:DaZombieKiller,项目名称:lxDoom,代码行数:27,代码来源:a_hereticmisc.cpp

示例14: EV_BuildPillar

int EV_BuildPillar(line_t *line, byte *args, boolean crush)
{
	int secnum;
	sector_t *sec;
	pillar_t *pillar;
	int newHeight;
	int rtn;

	rtn = 0;
	secnum = -1;
	while((secnum = P_FindSectorFromTag(args[0], secnum)) >= 0)
	{
		sec = &sectors[secnum];
		if(sec->specialdata)
			continue; // already moving
		if(sec->floorheight == sec->ceilingheight)
		{ // pillar is already closed
			continue;
		}
		rtn = 1;
		if(!args[2])
		{
			newHeight = sec->floorheight+
				((sec->ceilingheight-sec->floorheight)/2);
		}
		else
		{
			newHeight = sec->floorheight+(args[2]<<FRACBITS);
		}

		pillar = Z_Malloc(sizeof(*pillar), PU_LEVSPEC, 0);
		sec->specialdata = pillar;
		P_AddThinker(&pillar->thinker);
		pillar->thinker.function = T_BuildPillar;
		pillar->sector = sec;
		if(!args[2])
		{
			pillar->ceilingSpeed = pillar->floorSpeed = args[1]*(FRACUNIT/8);
		}
		else if(newHeight-sec->floorheight > sec->ceilingheight-newHeight)
		{
			pillar->floorSpeed = args[1]*(FRACUNIT/8);
			pillar->ceilingSpeed = FixedMul(sec->ceilingheight-newHeight,
				FixedDiv(pillar->floorSpeed, newHeight-sec->floorheight));
		}
		else
		{
			pillar->ceilingSpeed = args[1]*(FRACUNIT/8);
			pillar->floorSpeed = FixedMul(newHeight-sec->floorheight,
				FixedDiv(pillar->ceilingSpeed, sec->ceilingheight-newHeight));
		}
		pillar->floordest = newHeight;
		pillar->ceilingdest = newHeight;
		pillar->direction = 1;
		pillar->crush = crush*args[3];
		SN_StartSequence((mobj_t *)&pillar->sector->soundorg, 
			SEQ_PLATFORM+pillar->sector->seqType);
	}
	return rtn;
}
开发者ID:shovelmachine,项目名称:hexentouch,代码行数:60,代码来源:p_floor.c

示例15: A_ImpMsAttack

void A_ImpMsAttack (AActor *self)
{
	AActor *dest;
	angle_t an;
	int dist;

	if (!self->target || pr_impmsatk() > 64)
	{
		self->SetState (self->SeeState);
		return;
	}
	dest = self->target;
	self->flags |= MF_SKULLFLY;
	S_SoundID (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM);
	A_FaceTarget (self);
	an = self->angle >> ANGLETOFINESHIFT;
	self->momx = FixedMul (12*FRACUNIT, finecosine[an]);
	self->momy = FixedMul (12*FRACUNIT, finesine[an]);
	dist = P_AproxDistance (dest->x - self->x, dest->y - self->y);
	dist = dist/(12*FRACUNIT);
	if (dist < 1)
	{
		dist = 1;
	}
	self->momz = (dest->z + (dest->height>>1) - self->z)/dist;
}
开发者ID:ddraigcymraeg,项目名称:scoredoomst,代码行数:26,代码来源:a_hereticimp.cpp


注:本文中的FixedMul函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。