Teleport code added in Wizard. Needs more debugging.

This commit is contained in:
2023-07-05 04:31:31 -05:00
parent ba6bc74f1f
commit 888d2a91a6
6 changed files with 58 additions and 17 deletions
+15 -1
View File
@@ -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,