This repository has been archived on 2022-10-27. You can view files and clone it, but cannot push or open issues or pull requests.
space-war/src/game/action.cpp

39 lines
873 B
C++
Raw Normal View History

#include "game/action.hpp"
void Shoot(SpaceshipWeaponCmpt& weapon, const Point& dir) {
2022-02-09 22:33:06 +08:00
if (weapon.IsCoolDowning()) {
return;
}
Point playerCenterPos = weapon.owner->Get<MoveCmpt>()->position;
Entity* bullet;
bullet = weapon.ShootBullet(dir);
Bullets.Add(bullet);
weapon.coolDown = weapon.shootDuration;
Sounds["shoot"]->Play();
}
2022-02-09 22:33:06 +08:00
void Shoot(SpaceshipWeaponCmpt& weapon, const Point& dir, Entity* target) {
if (weapon.IsCoolDowning()) {
return;
}
Point playerCenterPos = weapon.owner->Get<MoveCmpt>()->position;
Entity* bullet;
bullet = weapon.ShootMissile(dir, target);
// FIXME the rotation have some bugs
bullet->Use<BulletCmpt>()->rotation = Degrees(std::acos(-Normalize(dir).y));
Bullets.Add(bullet);
weapon.coolDown = weapon.shootDuration;
Sounds["shoot"]->Play();
}