本文整理汇总了C++中Weapon::setBulletImage方法的典型用法代码示例。如果您正苦于以下问题:C++ Weapon::setBulletImage方法的具体用法?C++ Weapon::setBulletImage怎么用?C++ Weapon::setBulletImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Weapon
的用法示例。
在下文中一共展示了Weapon::setBulletImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: weaponPath
WeaponManager::WeaponManager(FileUtility* fileUtility, SoundManager* sndManager) {
std::cout << "Loading weapons..." << std::endl;
m_fileUtility = fileUtility;
m_sndManager = sndManager;
boost::filesystem::path weaponsPath =
m_fileUtility->getFullPath(FileUtility::weapon, "");
std::vector<std::string> weapons = m_fileUtility->getSubDirsFromDir(
weaponsPath);
std::cout << "Total weapons found: " << weapons.size() << std::endl;
if (weapons.size() == 0) {
std::cout << "Couldn't load weapons, the program won't run!"
<< std::endl;
exit(6);
}
for (int i = 0; i < (int) weapons.size(); i++) {
if (weapons.at(i) == "PM") {
weapons.at(i) = weapons.back();
weapons.back() = "PM";
std::cout << "EDIT: Putting PM to the end of list!" << std::endl;
break;
}
}
for (unsigned int j = 0; j < weapons.size(); j++) {
boost::filesystem::path weaponPath(weaponsPath);
weaponPath /= weapons[j];
Texture* wImage = new Texture(ImageUtility::loadImage(
boost::filesystem::path(weaponPath) /= "image.png"),
GL_TEXTURE_2D, GL_LINEAR, true);
Texture* pImage = new Texture(ImageUtility::loadImage(
boost::filesystem::path(weaponPath) /= "player.png"),
GL_TEXTURE_2D, GL_LINEAR, true);
Weapon *weapon = new Weapon(wImage, pImage,
sndManager->create(boost::filesystem::path(weaponPath) /= "shot.ogg"),
sndManager->create(boost::filesystem::path(weaponPath) /= "reload.ogg"));
weapon->Name = weapons[j];
boost::filesystem::ifstream in;
in.open(boost::filesystem::path(weaponPath) /= "stats");
if (!in) {
std::cerr << "Couldn't load stats of weapon " << weapons[j] << '.'
<< std::endl;
exit(4);
}
std::string shellName;
std::string strbuf;
getline(in, strbuf, ' ');
weapon->Type = (BulletType) strtol(strbuf.c_str(), NULL, 10);
if (weapon->Type == BULLET_FLAME)
weapon->setBulletImage(new Texture(ImageUtility::loadImage(
boost::filesystem::path(weaponPath) /= "bullet.png"),
GL_TEXTURE_2D, GL_LINEAR, true));
getline(in, shellName, ' ');
in >> weapon->AmmoClipSize;
weapon->Ammo = weapon->AmmoClipSize;
in >> weapon->Damage;
in >> weapon->FireDelayTime;
in >> weapon->ReloadTime;
in >> weapon->FireRange;
in >> weapon->BulletSpeed;
in >> weapon->ReturnForce;
in >> weapon->BulletsAtOnce;
in >> weapon->XDiff;
in >> weapon->YDiff;
in.close();
if (shellName != "no")
loadShellSprite(weapon, shellName);
Weapons.push_back(weapon);
}
std::cout << "Loading of weapons is completed." << std::endl;
}