本文整理汇总了C++中Laser::getAngle方法的典型用法代码示例。如果您正苦于以下问题:C++ Laser::getAngle方法的具体用法?C++ Laser::getAngle怎么用?C++ Laser::getAngle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Laser
的用法示例。
在下文中一共展示了Laser::getAngle方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addBeams
void LaserSystem::addBeams(Laser& laser, TilePosition& tilePos)
{
// Setup everything
currentPosition = ng::vec::cast<int>(tilePos.pos);
currentDirection = laser.direction;
// Current layer is the starting layer of the beam
currentLayer = (tilePos.layer && !getLayer());
// Simulate the laser until it hits something
laser.beamCount = 0;
sf::Vector2f startPoint = tileMap.getCenterPoint<float>(tilePos.pos);
PointInfo endPoint;
do
{
// Find next point that collides
endPoint = findPoint();
Laser::Beam* beam;
if (laser.beamCount < laser.beams.size())
{
// Use an existing sprite
beam = &(laser.beams[laser.beamCount]);
}
else
{
// Setup a new sprite with the beam texture
laser.beams.emplace_back();
beam = &laser.beams.back();
ng::SpriteLoader::load(beam->sprite, textureFilename, true);
}
++laser.beamCount;
beam->sprite.setOrigin(beamWidth / 2, 0);
// Calculate and set the beam length
float beamLength = ng::vec::distance(startPoint, endPoint.position);
beam->sprite.setScale(1, beamLength);
// Set the beam's position and rotation
beam->sprite.setPosition(startPoint);
beam->sprite.setRotation(ng::vec::rotateAngle(laser.getAngle(currentDirection), 180.0));
// Set the beam's layer
beam->layer = currentLayer;
if (endPoint.state == PointInfo::State::Redirect)
{
// Change the direction based on the angle of the mirror
bool mirrorState = tileMapData(endPoint.tileId).state;
changeDirection(mirrorState, currentDirection);
}
else if (endPoint.state == PointInfo::State::Activate)
{
// Enable the laser sensor
es::Events::send(SwitchEvent{endPoint.tileId, SwitchEvent::On});
laserSensorsToDisable.erase(endPoint.tileId);
}
startPoint = endPoint.position;
}
while (endPoint.state == PointInfo::State::Redirect);
}