本文整理汇总了C++中Grid::Add_Inv方法的典型用法代码示例。如果您正苦于以下问题:C++ Grid::Add_Inv方法的具体用法?C++ Grid::Add_Inv怎么用?C++ Grid::Add_Inv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grid
的用法示例。
在下文中一共展示了Grid::Add_Inv方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PopulateGrid
void PopulateGrid(Grid &newgrid)
{
for(int i = 0; i < 20; i++)
for(int j = 0; j < 20; j++)
{
if(newgrid.Get(i, j) == true)
{
int r = arc4random_uniform(5);
if(r == 0)
{
newgrid.Add_Inv(*new Entity("ammobox"), i, j);
}
else if(r == 1)
{
newgrid.Add_Inv(*new Entity("healthpack"), i, j);
}
else if(r == 2)
{
newgrid.Add_Inv(*new Entity("cat"), i, j);
}
else if(r == 3)
{
newgrid.Add_Inv(*new Entity("hamburger"), i, j);
}
}
}
}
示例2: Turn
void Turn(Player & player1, Grid & newgrid, Playerslist & list, ofstream &fout, int turn = -1, int p = 0)
{
if(player1.alive == false)
{
cout << player1.Getname() << " is dead." << endl;
return;
}
char player_type = player1.Get_type();
int AP = 5;
string verb, noun, s;
cout << endl << endl << player1.Getname();
switch (player_type)
{
case 's': cout << "(me)" << endl; break;
case 'f': cout << "(friend)" << endl; break;
case 'e': cout << "(enemy)" << endl; break;
default: cout << "invalid playertype" << endl; break;
}
cout << "Turn " << turn << endl << endl;
//player2
string Result;
ostringstream convert;
convert << turn;
Result = convert.str();
fstream f2in;
fstream f3in;
f2in.open("/Users/laria/Documents/c++/rpg/rpg/f" + Result + ".txt");
f3in.open("/Users/laria/Documents/c++/rpg/rpg/e" + Result + ".txt");
while(AP > 0)
{
player1.Set_x(player1.activeroom->Get_xcoord());
player1.Set_y(player1.activeroom->Get_ycoord());
if(newgrid.Search_Inv(player1.Getname(), player1.Get_x(), player1.Get_y()) == false)
{
newgrid.Add_Inv(player1, player1.Get_x(), player1.Get_y());
}
describe_start:
cout << endl;
if(player_type == 's')
{
player1.activeroom->Descrip();
newgrid.Describe_inv(player1.Get_x(), player1.Get_y());
}
action_start:
//cout << list.Get("player3").alive;
if(AP < 1)
break;
if(player_type == 's')
cout << "Action points: " << AP << endl;
if (player_type == 's')
{
getline(cin, s, '\n');
fout.open("/Users/laria/Documents/c++/rpg/rpg/output.txt");
fout << s;
fout.close();
fstream fin;
fin.open("/Users/laria/Documents/c++/rpg/rpg/output.txt");
fin>>verb>>noun;
fin.close();
}
else if (p == 2)