当前位置: 首页>>代码示例>>C++>>正文


C++ Grid::Add_Inv方法代码示例

本文整理汇总了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);
                }
            }
        }

}
开发者ID:eco-terrorist,项目名称:script-game,代码行数:29,代码来源:main.cpp

示例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)
开发者ID:eco-terrorist,项目名称:script-game,代码行数:78,代码来源:main.cpp


注:本文中的Grid::Add_Inv方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。