Example #1
0
void Ball::Update(float dt) {
  //d = v*t
  //v = a*t;
  //d = v*t*t+c
  //dp = v*dt
  //pos = pos + a

  XMVECTOR force_vec = XMVectorAdd(force,impulse);
  XMVECTOR mass_vec = XMVectorReplicate(mass);
  XMVECTOR time_vec = XMVectorReplicate(dt*0.001f);
  
  impulse = XMVectorZero();

  acceleration = XMVectorDivide(force_vec,mass_vec);
  velocity = XMVectorMultiplyAdd(acceleration,time_vec,velocity);
  position = XMVectorMultiplyAdd(velocity,time_vec,position);

 // auto coll = IntersectCircleAxisAlignedBox(this,&system->table);

  //if (coll == 0) {
    //velocity = XMVectorNegate(velocity);
  //}

  object_time += dt;
}
Example #2
0
//-----------------------------------------------------------------------------------------------------------------------------------
void GameMouse::Draw(SpriteBatch* spriteBatch, SpriteFont* spriteFont)
{
	if (IsVisible())
	{
		spriteBatch->Draw(
			GetTexture()->GetTexture(), 
			GetWorldPosition(), 
			nullptr, 
			GetColour() * GetOpacity(),
			GetWorldRotation(), 
			Vector2::Zero, 
			XMVectorDivide(GetSize(), GetTexture()->GetDimensions()));
	}
}