|
|
@ -56,7 +56,7 @@ void LightningBoltEmitter::DrawLightningBolt(){ |
|
|
|
const int MAX_ITERATIONS=100; |
|
|
|
const int MAX_ITERATIONS=100; |
|
|
|
geom2d::line<float>lineToTarget=geom2d::line<float>(startPos,endPos); |
|
|
|
geom2d::line<float>lineToTarget=geom2d::line<float>(startPos,endPos); |
|
|
|
float targetAngle=atan2(lineToTarget.vector().y,lineToTarget.vector().x); |
|
|
|
float targetAngle=atan2(lineToTarget.vector().y,lineToTarget.vector().x); |
|
|
|
float targetDist=lineToTarget.length()*util::random(0.5); |
|
|
|
float targetDist=lineToTarget.length()*util::random(0.5f); |
|
|
|
targetAngle+=util::random((PI/2))-PI/4; |
|
|
|
targetAngle+=util::random((PI/2))-PI/4; |
|
|
|
geom2d::line<float>lightningLine=geom2d::line<float>(currentPos,currentPos+vf2d{cos(targetAngle)*targetDist,sin(targetAngle)*targetDist}); |
|
|
|
geom2d::line<float>lightningLine=geom2d::line<float>(currentPos,currentPos+vf2d{cos(targetAngle)*targetDist,sin(targetAngle)*targetDist}); |
|
|
|
game->AddEffect(std::make_unique<Effect>(lightningLine.upoint(0),0,"chain_lightning.png",upperLevel,vf2d{lightningLine.length(),0.2f},0.2f,vf2d{},WHITE,targetAngle,0,true)); |
|
|
|
game->AddEffect(std::make_unique<Effect>(lightningLine.upoint(0),0,"chain_lightning.png",upperLevel,vf2d{lightningLine.length(),0.2f},0.2f,vf2d{},WHITE,targetAngle,0,true)); |
|
|
@ -65,7 +65,7 @@ void LightningBoltEmitter::DrawLightningBolt(){ |
|
|
|
while(iterations<MAX_ITERATIONS&&geom2d::line<float>(currentPos,endPos).length()>1){ |
|
|
|
while(iterations<MAX_ITERATIONS&&geom2d::line<float>(currentPos,endPos).length()>1){ |
|
|
|
geom2d::line<float>lineToTarget=geom2d::line<float>(currentPos,endPos); |
|
|
|
geom2d::line<float>lineToTarget=geom2d::line<float>(currentPos,endPos); |
|
|
|
float targetAngle=atan2(lineToTarget.vector().y,lineToTarget.vector().x); |
|
|
|
float targetAngle=atan2(lineToTarget.vector().y,lineToTarget.vector().x); |
|
|
|
float targetDist=lineToTarget.length()*util::random(0.5); |
|
|
|
float targetDist=lineToTarget.length()*util::random(0.5f); |
|
|
|
targetAngle+=util::random((PI/2))-PI/4; |
|
|
|
targetAngle+=util::random((PI/2))-PI/4; |
|
|
|
geom2d::line<float>lightningLine=geom2d::line<float>(currentPos,currentPos+vf2d{cos(targetAngle)*targetDist,sin(targetAngle)*targetDist}); |
|
|
|
geom2d::line<float>lightningLine=geom2d::line<float>(currentPos,currentPos+vf2d{cos(targetAngle)*targetDist,sin(targetAngle)*targetDist}); |
|
|
|
game->AddEffect(std::make_unique<Effect>(lightningLine.upoint(0),0,"chain_lightning.png",upperLevel,vf2d{lightningLine.length(),0.2f},0.2f,vf2d{},WHITE,targetAngle,0,true)); |
|
|
|
game->AddEffect(std::make_unique<Effect>(lightningLine.upoint(0),0,"chain_lightning.png",upperLevel,vf2d{lightningLine.length(),0.2f},0.2f,vf2d{},WHITE,targetAngle,0,true)); |
|
|
|