Teleport code added in Wizard. Needs more debugging.
This commit is contained in:
+15
-1
@@ -300,7 +300,21 @@ bool Wizard::Ability3(){
|
||||
}
|
||||
|
||||
bool Wizard::RightClickAbility(){
|
||||
return true;
|
||||
ACCESS_PLAYER
|
||||
float pointMouseDirection=atan2(game->GetWorldMousePos().y-p.GetPos().y,game->GetWorldMousePos().x-p.GetPos().x);
|
||||
vf2d pointTowardsMouse={cos(pointMouseDirection),sin(pointMouseDirection)};
|
||||
float dist=std::clamp(geom2d::line<float>{p.GetPos(),game->GetWorldMousePos()}.length(),0.f,650.f);
|
||||
vf2d teleportPoint=p.GetPos()+pointTowardsMouse*dist;
|
||||
while(dist>0&&game->HasTileCollision(game->GetCurrentLevel(),teleportPoint)){
|
||||
dist--;
|
||||
teleportPoint=p.GetPos()+pointTowardsMouse*dist;
|
||||
}
|
||||
if(dist>0){
|
||||
p.SetPos(teleportPoint);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Witch::Witch(std::string name,Class cl,Ability rightClickAbility,Ability ability1,Ability ability2,Ability ability3,
|
||||
|
||||
Reference in New Issue
Block a user