本文整理汇总了C++中Weapon::name方法的典型用法代码示例。如果您正苦于以下问题:C++ Weapon::name方法的具体用法?C++ Weapon::name怎么用?C++ Weapon::name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Weapon
的用法示例。
在下文中一共展示了Weapon::name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
gk::SceneObject WeaponFactory::create(Weapon &weaponInfos, float x, float y, gk::GameKey key, gk::SceneObject &owner) {
if(weaponInfos.name() == "swordL1") {
return SwordFactory::create(x, y, key, owner, weaponInfos);
}
else if(weaponInfos.name() == "strengthL1") {
gk::SceneObject object{"strengthL1", "weapon"};
object.set<LifetimeComponent>();
object.set<WeaponComponent>(owner, weaponInfos, key, "Grab");
return object;
}
else {
return gk::SceneObject{"", "weapon"};
}
}
示例2: displayWeapon
void displayWeapon(Weapon weapon)
{
cout<<"\tName :"<<weapon.name()<<endl
<<"\tRange :"<<weapon.range()<<endl
<<"\tAmmo :"<<weapon.ammo()<<endl
<<"\tDelay :"<<weapon.delay()<<endl
<<"\tDamage :"<<weapon.damage()<<endl
<<"\tVSplashD:"<<weapon.verticalSplashDamage()<<endl
<<"\tHSplashD:"<<weapon.horizontalSplashDamage()<<endl
<<"\tHSplashR:"<<weapon.horizontalSplashRadius()<<endl;
}
示例3: main
int main(int argc, char** argv){
int num_objects = 10;
int num_moving = 5;
string name;
int x, y;
char command;
int t=1;
Player player("player");
Player player2("player2");
//If at least one command-line argument was provided, use it as the number of objects to create.
if (argc > 1) {
num_objects = atoi(argv[1]);
}
if (argc > 2) {
num_moving = atoi(argv[2]);
}
//Create all the non-moving objects
for (int i = 0; i < num_objects - num_moving; i++) {
x = random() % 11;
y = random() % 11;
name = "random object";
if (i < 7) {
name = names[i];
}
collection.push_back(new Object(name, x, y));
}
for (int i = 0; i < num_moving; i++) {
x = random() % 11;
y = random() % 11;
name = "random moving object";
if (i < 5) {
name = moving_names[i];
}
collection.push_back(new Monster(name,x,y));
}
//Create weapons.
for (int i = 0; i < 3; i++) {
x = random() % 11;
y = random() % 11;
name = "weapon";
if (i < 3) {
name = weapon_names[i];
}
collection.push_back(new Weapon(name,x,y));
}
//Create armor.
for (int i = 0; i < 3; i++) {
x = random() % 11;
y = random() % 11;
name = "armor";
if (i < 3) {
name = armor_names[i];
}
collection.push_back(new Armor(name,x,y));
}
do{
while(t==1){
cout << "__________________________________________________"<<endl;
cout << "Player 1" << endl;
cout << "[" << player.x() << ", " << player.y() << "]" << endl;
cout << "Your score is: " << player.score() << endl;
cout << "________________________________________"<<endl;
cout << "Enter a command:" << endl;
cout << " 'i' to move up." << endl;
cout << " 'm' to move down." << endl;
cout << " 'j' to move left." << endl;
cout << " 'k' to move right." << endl;
cout << " 't' to take an item from this room." << endl;
cout << " 'a' to attack a monster in this room." << endl;
cout << " 'q' to quit." << endl;
cout << "__________________________________________________"<<endl;
//Process command and move player.
cin >> command;
switch (command) {
case 'i':
player.move_up();
break;
case 'm':
player.move_down();
//.........这里部分代码省略.........