1 Star 0 Fork 0

pendulum445/AircraftWar-Cpp

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
ShootStrategy.cpp 1.09 KB
一键复制 编辑 原始数据 按行查看 历史
//
// Created by liaoyunjie on 24-5-15.
//
#include "ShootStrategy.h"
#include "ImageManager.h"
#include "aircraft.h"
#include "defs.h"
auto BaseShootStrategy::shoot(const BaseAircraft* aircraft)
-> std::list<std::shared_ptr<Bullet>> {
return {};
}
auto DirectShootStrategy::shoot(const BaseAircraft* aircraft)
-> std::list<std::shared_ptr<Bullet>> {
std::list<std::shared_ptr<Bullet>> bullets;
int width, height, direction = aircraft->direction();
FlyingObjectType type;
if (direction == -1) {
width = ImageManager::HERO_BULLET_IMAGE.width();
height = ImageManager::HERO_BULLET_IMAGE.height();
type = HERO_BULLET;
} else {
width = ImageManager::ENEMY_BULLET_IMAGE.width();
height = ImageManager::ENEMY_BULLET_IMAGE.height();
type = ENEMY_BULLET;
}
for (int i = 0; i < aircraft->shoot_num(); i++) {
bullets.push_back(std::make_shared<Bullet>(
type, aircraft->location_x() + 10 * (2 * i - aircraft->shoot_num() + 1),
aircraft->location_y(), 0, BULLET_SPEED * direction, width, height,
aircraft->bullet_power()));
}
return bullets;
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yunjie445/aircraft-war-cpp.git
git@gitee.com:yunjie445/aircraft-war-cpp.git
yunjie445
aircraft-war-cpp
AircraftWar-Cpp
main

搜索帮助