本文整理汇总了C++中Armor::name方法的典型用法代码示例。如果您正苦于以下问题:C++ Armor::name方法的具体用法?C++ Armor::name怎么用?C++ Armor::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Armor
的用法示例。
在下文中一共展示了Armor::name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
//.........这里部分代码省略.........