project2D/Bullet.cpp
//--------------------------------------------------------------------------------------
// Update: A virtual function from entity to update objects.
//
// Param:
//		deltaTime: Pass in deltaTime. A number that updates per second.
//--------------------------------------------------------------------------------------
A virtual function from entity to update objects.
Param:
deltaTime: Pass in deltaTime. A number that updates per second.
A virtual function from entity to update objects . Param : deltaTime : Pass in deltaTime . A number that updates per second .
void Bullet::Update(float deltaTime)
{
	Matrix3 temp;
	temp.setPostionv(dir * speed * deltaTime);
	localTransform = localTransform * temp;
	updateGlobalTransform();
	CollisionManager* pCollision = CollisionManager::GetInstance();
	Entity* colliding = pCollision->TestSphereBoxCollision(this);
	if (colliding != nullptr && colliding->GetType() == WALL)
	{
		cout << "BULLET!" << endl;
 		dir = pCollision->Bounce(colliding, dir, GetPosition());
	}
}
void Bullet :: Update ( float deltaTime ) { Matrix3 temp ; temp . setPostionv ( dir * speed * deltaTime ) ; localTransform = localTransform * temp ; updateGlobalTransform ( ) ; CollisionManager * pCollision = CollisionManager :: GetInstance ( ) ; Entity * colliding = pCollision -> TestSphereBoxCollision ( this ) ; if ( colliding != nullptr && colliding -> GetType ( ) == WALL ) { cout << " " << endl ; dir = pCollision -> Bounce ( colliding , dir , GetPosition ( ) ) ; } }
Update: A virtual function from entity to update objects.
Update : A virtual function from entity to update objects .
// Set the position and update the local and global transform. // Test Collision // Check if the Bullet is colliding with a wall // Debug message for console // Bounce the bullet off the wall