Example #1
0
//	--------------------------------------------------------------------
//	敵のショットの移動関数
//	--------------------------------------------------------------------
void ControllEnemyShot()
{
    //	弾が無いかプレイヤーにヒットしているなら移動処理はせずに終了
    if (EnemyShot.state != STATE_LIVE) return;

    //	弾の移動
    EnemyShot.y += ENEMY_SHOT_SPEED;

    //	弾はプレイヤーにヒットしている?
    if (IsHit(EnemyShot, Player) == TRUE)
    {
        //	弾を消す
        EnemyShot.state = STATE_NONE;
        //	プレイヤーを死亡状態にする
        Player.state = STATE_HIT;
        return;
    }

    //	弾は画面外に消えた?
    if (EnemyShot.y > SCREEN_HEIGHT)
    {
        EnemyShot.state = STATE_NONE;
    }

    return;
}
Example #2
0
		BOOL StdImpact059_T::HitThisTarget(Obj_Character& rMe, Obj_Character& rTar, SkillID_t nSkillID) const
		{
			__ENTER_FUNCTION
			//SkillInfo_T& rSkillInfo = rMe.GetSkillInfo();
			TargetingAndDepletingParams_T& rParams = rMe.GetTargetingAndDepletingParams();
			Scene* pScene = rMe.getScene();
			if(TRUE==rMe.IsFriend(&rTar))
			{
				//给友方使用的技能100%命中
				return TRUE;
			}
			//Hit Or Miss
			//根据命中率判断是否击中
			//注意:此时对技能释放而言,目标已验证为合法,因此只受技能本身的命中率影响
			//如果没有命中
			if(FALSE == IsHit(rMe, rTar, m_iAccuracy))
			{
				if(NULL!=pScene)
				{
					//直接向全局event对象注册没有命中的事件
					pScene->GetEventCore().RegisterSkillMissEvent(rTar.GetID(), rMe.GetID(), nSkillID, 0);
				}
				return FALSE;
			}
			//如果最终命中,向全局event对象注册技能命中目标事件
			if(NULL!=pScene)
			{
				pScene->GetEventCore().RegisterSkillHitEvent(rTar.GetID(), rMe.GetID(), nSkillID, 0);
			}
			return TRUE;
			__LEAVE_FUNCTION
				return FALSE;
		}
Example #3
0
//	--------------------------------------------------------------------
//	プレイヤーのショットの移動関数
//	--------------------------------------------------------------------
void ControllPlayerShot()
{
    //	弾が無いか敵にヒットしているなら移動処理はせずに終了
    if (PlayerShot.state != STATE_LIVE) return;

    //	弾の移動
    PlayerShot.y -= PLAYER_SHOT_SPEED;

    //	弾は敵にヒットしている?
    if (IsHit(PlayerShot, Enemy) == TRUE)
    {
        //	弾を消す
        PlayerShot.state = STATE_NONE;
        //	敵をまた出す
        InitEnemy();
        return;
    }

    //	弾は画面外に消えた?
    if (PlayerShot.y < 0)
    {
        PlayerShot.state = STATE_NONE;
    }

    return;
}
Example #4
0
void CREARecord::CREASound::IsHit(bool value)
    {
    if(value)
        CSDT.value = eHit;
    else if(IsHit())
        CSDT.value = eLeftFoot;
    }
bool CClientMarkerCommon::IsHit ( CClientEntity* pEntity ) const
{
    // Grab the given entity's position
    CVector vecPosition;
    pEntity->GetPosition ( vecPosition );

    // Return whether that point hits or not
    return IsHit ( vecPosition );
}
Example #6
0
// Returns true if there is any (even partial) hit
// Returns false if there is no hit whatsoever
bool Widget::HitTest(Vector2n ParentPosition, std::list<Widget *> * Hits) const
{
	auto Hit = IsHit(ParentPosition);

	if (Hit && nullptr != Hits)
	{
		Hits->push_back(const_cast<Widget *>(this));
	}

	return Hit;
}
Example #7
0
void Enemy::Update()
{ 
	if(!m_isAlive)
	{ return; }

	m_xpos += (m_moveSpeed * Time::GetDeltaTime()) * m_moveDir; 
	m_graphics->SetPosition((int)m_xpos, (int)m_ypos);

	for(unsigned int i = 0; i < m_listOfMissiles.size(); i++)
	{ m_listOfMissiles[i]->Update(); }

	if(IsHit())
	{ Destroy(); }
}
Example #8
0
void Widget::HitTest2(Vector2n ParentPosition, PointerMapping & Mapping) const
{
	auto Hit = IsHit(ParentPosition);

	if (Hit)
	{
		for (auto GestureType : m_GestureTypes)
		{
			;
		}
	}

	// TODO: Finish
	throw 0;
}
Example #9
0
void
Collision (ball * ballz)
{
  ball *head = ballz;

  head = head->next;

  while (head)
    {
      if (IsHit (ballz, head))
	{

	  float dx, dy, w, h;
	  float n_x, n_y;
	  float hcx, hcy, bcx, bcy;
	  float hdx, hdy, bdx, bdy;

	  float impact_x, impact_y, impulse_x, impulse_y, impactSpeed;
//Formula:

// 1. Impact= balla-ballb         'vector subtaction
// 2. impulse = Normalize(p1,p2)  'see normalize sub
// 3. impactspeed = Dot!(impact,impulse)
// 4. newimpulse=impulse*impactspeed*mass1*mass2
// 5. newa=balla+newimpulse/mass1
// 6. newb=ballb-newimpulse/mass2
// PS the divide by 2 is for the frictionless model. ;*)


	  impact_x = head->delta_x - ballz->delta_x + 1;
	  impact_y = head->delta_y - ballz->delta_y + 1;

	  NormalizeVector (&impulse_x, &impulse_y,
			   ballz->x, ballz->y, head->x, head->y);

	  impactSpeed =
	    DotVector (impact_x, impact_y, impulse_x, impulse_y) + 10;

	  printf ("impact %f %f impulse %f %f %f \n", impact_x, impact_y,
		  impulse_x, impulse_y, impactSpeed);

	  impulse_x = impulse_x * impactSpeed * ballz->mass * head->mass / 2;

	  impulse_y = impulse_y * impactSpeed * ballz->mass * head->mass / 2;

	  printf ("impact %f %f impulse %f %f %f \n", impact_x, impact_y,
		  impulse_x, impulse_y, impactSpeed);

	  bdx = ballz->delta_x + impulse_x / ballz->mass;
	  bdy = ballz->delta_y + impulse_y / ballz->mass;

	  hdx = head->delta_x - impulse_x / head->mass;
	  hdy = head->delta_y - impulse_y / head->mass;

	  head->delta_x = bdx;
	  head->delta_y = bdy;

	  ballz->delta_x = hdx;
	  ballz->delta_y = hdy;

	  head->x += 2;
	  head->y += 2;

	  printf ("Impulse %f %f Impact %f %f head %d %d ballz %d %d  - \n\n",
		  impulse_x, impulse_y, impact_x, impact_y, head->delta_x,
		  head->delta_y, ballz->delta_x, ballz->delta_y);
//fflush(stdout);
	  head->lasthit = ballz;
	  ballz->lasthit = head;
	}
      else
	{
	  if (ballz->lasthit == head->lasthit)
	    {
	      ballz->lasthit = NULL;
	      head->lasthit = NULL;
	    }
	}
      Collision (head);
      head = head->next;
    }
}
Example #10
0
//--------------------------------------------------------------
//  Check if the mouse is in the area
//--------------------------------------------------------------
ECursorResult C_Knob::MouseMoved (int x, int y)
{ // Check that the position is within click area bounds
  if (!mgg) return CURSOR_NOT_CHANGED; 
  if (IsHit (x, y)) return  globals->cum->SetCursor(cTag);
  return CURSOR_NOT_CHANGED;
}