Skip to content
Snippets Groups Projects
Commit 785b76f4 authored by alexis's avatar alexis
Browse files

knockback enemy

parent a9c76c59
Branches
No related tags found
No related merge requests found
{
"files.associations": {
"cmath": "cpp"
}
}
\ No newline at end of file
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -741,15 +741,19 @@ bool HSlash::use(){
void HSlash::applySkillEnemy(Enemy* enemy){
int degats;
enemy->setKnockback(true);
Vec2 reverseVelocity(enemy->getBody()->GetLinearVelocity());
vec2 reverseVelocity(enemy->getBody()->GetLinearVelocity());
float angleToRadian = (90*M_PI)/180.0f;
reverseVelocity.x = reverseVelocity.x * cos(angleToRadian) - sin(angleToRadian) * reverseVelocity.y;
reverseVelocity.y = reverseVelocity.y * sin(angleToRadian) - cos(angleToRadian) * reverseVelocity.x;
enemy->setKnockbackVelocity(reverseVelocity);
if(this->parent->getStrength()*2<=enemy->getArmor()){
degats=1;
}
else{
degats = this->parent->getStrength()-enemy->getArmor();
degats = this->parent->getStrength() * (this->parent->getStrength()/(this->parent->getStrength()-enemy->getArmor()));
}
enemy->setHp(enemy->getHp()-this->parent->getStrength()*(parent->getStrength()/parent->getStrength()+enemy->getArmor()));
enemy->setHp(enemy->getHp()-degats);
if(enemy->getHp()<=0){
this->parent->gainXp(enemy->getGiftXp());
int dropchance = (rand() % 100)+1;
......
......
......@@ -66,7 +66,7 @@ void MenuManager::menu(){
nk_spacer(ctx);
if (nk_button_label(ctx, "Nouvelle Partie")) {
game->setState(InLoadingScreen);
SoundManager::getInstance().PlayMusicBackground();
}
nk_spacer(ctx);
......
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment