Example #1
0
/// <summary>
/// Processes the bullet
/// </summary>
void Bullet::process()
{

	// Checks if its deleted
	if (!getDeleted())
	{

		// If degrees is set (not -1), do rotational movement
		if (deg != -1) // Rotational movement
		{
			double move_x = timeStep.asSeconds() * speedX * cos(deg) - sin(deg);
			double move_y = timeStep.asSeconds() *  speedY * sin(deg) + cos(deg);
			this->sprite->move(move_x, move_y);
		}
		else // Linear movement.
		{
			this->sprite->setPosition(
				sprite->getPosition().x + (timeStep.asSeconds() * speedX),
				sprite->getPosition().y + (timeStep.asSeconds() * speedY));

		}

		// If the bullet is out of bounds, we set delete flag
		if (isOutOfBounds())
		{
			setDeleted(true);
		}
	}
}
Example #2
0
/// <summary>
/// Processes the powerup
/// </summary>
void Powerup::process()
{

	// Check if the powerup is deleted or not, if it is, we do not want to move it.
	if (!getDeleted())
	{
		this->sprite->setPosition(
			sprite->getPosition().x + (timeStep.asSeconds() * speedX),
			sprite->getPosition().y + (timeStep.asSeconds() * speedY));

	}

	// Check if the powerup is out of bounds
	if (isOutOfBounds())
	{
		setDeleted(true);
	}
}