亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? tilemap.h

?? 模擬游戲中人的行走
?? H
?? 第 1 頁 / 共 2 頁
字號:
        // figure out the maximum number of tiles to draw in each
        // direction, based on the width/height of the screen.
        int minx = m_viewer->GetX() - (p_midx / 64) - 1;
        int maxx = m_viewer->GetX() + (p_midx / 64) + 1;
        int miny = m_viewer->GetY() - (p_midy / 64) - 1;
        int maxy = m_viewer->GetY() + (p_midy / 64) + 1;

        // make sure the coordinates are in bounds.
        if( minx < 0 )                  { minx = 0; }
        if( maxx >= m_tiles.Width() )   { maxx = m_tiles.Width() - 1; }
        if( miny < 0 )                  { miny = 0; }
        if( maxy >= m_tiles.Height() )  { maxy = m_tiles.Height() - 1; }
        

        // calculate the offsetsfrom the viewer
        ox = (-m_viewer->GetX() * 64) + p_midx - 32;
        oy = (-m_viewer->GetY() * 64) + p_midy - 32;

        for( y = miny; y <= maxy; y++ )
        {
            for( x = minx; x <= maxx; x++ )
            {
                // calculate the coordinates of the current tile
                px = x * 64 + ox;
                py = y * 64 + oy;

                for( z = 0; z < m_tiles.Depth(); z++ )
                {
                    current = m_tiles.Get( x, y, z );
                    if( current != -1 )
                    {
                        // draw the tile
                        SDLBlit( m_tilebmps[current], p_surface, px, py );
                    }
                }

                i = m_tilemap.Get( x, y ).m_item;
                p = m_tilemap.Get( x, y ).m_person;
                if( i != 0 )
                    SDLBlit( i->GetGraphic(), p_surface, px, py );
                if( p != 0 )
                    SDLBlit( p->GetGraphic(), p_surface, px, py );
            }
        }
    }

// -------------------------------------------------------
// Name:        CanMove
// Description: Determines if the given person can move
//              in the given direction
// -------------------------------------------------------
    bool CanMove( Person* p_person, int p_direction )
    {
        // get the new coordinates
        int newx = p_person->GetX() + DIRECTIONTABLE[p_direction][0]; 
        int newy = p_person->GetY() + DIRECTIONTABLE[p_direction][1];

        // check to see if the cell is in bounds.
        if( newx < 0 || newx >= m_tiles.Width() ||
            newy < 0 || newy >= m_tiles.Height() )
            return false;

        // check to see if the path is blocked or not.
        if( m_tilemap.Get( newx, newy ).m_blocked == true )
            return false;

        // check to see if there is a person blocking the way
        if( m_tilemap.Get( newx, newy ).m_person != 0 )
            return false;

        // check to see if there in an item blocking the way
        if( m_tilemap.Get( newx, newy ).m_item != 0 )
        {
            // some items can block, others can't
            if( m_tilemap.Get( newx, newy ).m_item->CanBlock() == true )
                return false;
        }

        return true;
    }


// -------------------------------------------------------
// Name:        Move
// Description: Moves the given person in the given
//              direction
// -------------------------------------------------------
    void Move( Person* p_person, int p_direction )
    {
        // get the new coordinates
        int newx = p_person->GetX() + DIRECTIONTABLE[p_direction][0]; 
        int newy = p_person->GetY() + DIRECTIONTABLE[p_direction][1];

        // make sure the player can move
        if( CanMove( p_person, p_direction ) == true )
        {
            // move the person to the new cell
            m_tilemap.Get( newx, newy ).m_person = p_person;

            // clear the person pointer in the old cell
            m_tilemap.Get( p_person->GetX(), p_person->GetY() ).m_person = 0;

            // set the new x, y, and cell variables
            p_person->SetX( newx );
            p_person->SetY( newy );
            p_person->SetCell( GetCell( newx, newy ) );
        }
    }


// -------------------------------------------------------
// Name:        GetItem
// Description: Gets a pointer to the item in the given
//              cell
// -------------------------------------------------------
    Item* GetItem( int p_cell )
    {
        // check to see if the cell is in bounds first
        if( p_cell >= GetNumberOfCells() || p_cell < 0 )
            return 0;

        return m_tilemap.m_array[p_cell].m_item;
    }


// -------------------------------------------------------
// Name:        SetItem
// Description: Sets the item in the given cell.
// -------------------------------------------------------
    void SetItem( int p_cell, Item* p_item )
    {
        // check to see if the cell is in bounds first
        if( p_cell >= GetNumberOfCells() || p_cell < 0 )
            return;

        m_tilemap.m_array[p_cell].m_item = p_item;
    }

    
// -------------------------------------------------------
// Name:        GetPerson
// Description: Gets a pointer to the person in the given
//              cell
// -------------------------------------------------------
    Person* GetPerson( int p_cell )
    {
        // check to see if the cell is in bounds first
        if( p_cell >= GetNumberOfCells() || p_cell < 0 )
            return 0;

        return m_tilemap.m_array[p_cell].m_person;
    }


// -------------------------------------------------------
// Name:        SetPerson
// Description: sets the person in the given cell.
// -------------------------------------------------------
    void SetPerson( int p_cell, Person* p_person )
    {
        // check to see if the cell is in bounds first
        if( p_cell >= GetNumberOfCells() || p_cell < 0 )
            return;

        m_tilemap.m_array[p_cell].m_person = p_person;
    }


// -------------------------------------------------------
// Name:        GetCellNumber
// Description: Gets the number of the cell in the
//              given direction
// -------------------------------------------------------
    int GetCellNumber( int p_cell, int p_direction )
    {
        int x, y;
    
        // calculate the x and y coords of the current cell first
        y = p_cell / m_tiles.Width();
        x = p_cell - (y * m_tiles.Width());
    
        // now calculate the new coordinates
        x = x + DIRECTIONTABLE[p_direction][0];
        y = y + DIRECTIONTABLE[p_direction][1];

        // check to see if the cell is out of bounds
        if( x < 0 || x >= m_tiles.Width() ||
            y < 0 || y >= m_tiles.Height() )
        {
            return -1;
        }

        // return the cell number
        return GetCell( x, y );
    }

    
// -------------------------------------------------------
// Name:        GetNumberOfCells
// Description: Gets the number of cells in the map
// -------------------------------------------------------
    int GetNumberOfCells()
    {
        return m_tilemap.Size();
    }


// -------------------------------------------------------
// Name:        GetClosestDirection
// Description: Gets the direction that will move the
//              first person closer to the second person.
// -------------------------------------------------------
    int GetClosestDirection( Person* p_one, Person* p_two )
    {
        int direction = -1;

        // if person 1 is above person 2, then go north
        if( p_one->GetY() > p_two->GetY() )
            direction = 0;
        // if person 1 is left of person 2, then go east
        else if( p_one->GetX() < p_two->GetX() )
            direction = 1;
        // if person 1 is below person 2, then go south
        else if( p_one->GetY() < p_two->GetY() )
            direction = 2;
        // if person 1 is right of person 2, then go west
        else if( p_one->GetX() > p_two->GetX() )
            direction = 3;

        return direction;
    }
};







#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
经典三级视频一区| 开心九九激情九九欧美日韩精美视频电影| 国产69精品一区二区亚洲孕妇| 久久久久久久久99精品| 国产成人精品三级麻豆| 国产精品欧美久久久久无广告 | 亚洲一区二区三区激情| 欧美日韩国产影片| 激情久久五月天| 国产精品九色蝌蚪自拍| 日韩视频在线永久播放| 国产在线精品一区二区不卡了 | 国产乱码精品1区2区3区| 欧美经典一区二区三区| 91丨九色丨黑人外教| 午夜欧美在线一二页| 欧美v日韩v国产v| 成人av在线看| 天堂蜜桃91精品| 国产精品三级视频| 欧美色男人天堂| 国产精品亚洲第一区在线暖暖韩国 | 欧美综合色免费| 国产在线精品免费| 伊人色综合久久天天| 日韩精品一区二区三区swag | 久久久青草青青国产亚洲免观| www.欧美亚洲| 婷婷久久综合九色综合绿巨人| 国产日本欧洲亚洲| 欧美三级视频在线播放| 国产激情精品久久久第一区二区| 亚洲人成人一区二区在线观看| 欧美va亚洲va香蕉在线| 一本色道久久综合亚洲91| 久久国产精品一区二区| 亚洲香肠在线观看| 国产精品不卡一区| 欧美mv和日韩mv的网站| 欧美在线你懂得| 成人深夜视频在线观看| 青草国产精品久久久久久| 亚洲男人电影天堂| 中文字幕av一区二区三区| 91精品国产欧美一区二区 | 欧美日韩另类国产亚洲欧美一级| 国产成人综合在线| 青青青爽久久午夜综合久久午夜| 一区二区在线观看视频| 国产亚洲欧美一级| 精品捆绑美女sm三区| 欧美视频中文一区二区三区在线观看 | 国产成人在线视频免费播放| 日韩一区欧美二区| 一区二区国产盗摄色噜噜| 国产精品萝li| 国产欧美日韩视频一区二区| 日韩精品中午字幕| 日韩一区国产二区欧美三区| 欧美亚洲国产一区二区三区va | 日本 国产 欧美色综合| 亚洲成a人在线观看| 亚洲欧美一区二区三区国产精品| 国产精品私人自拍| 中文字幕av一区 二区| 亚洲国产成人在线| 国产色综合一区| 国产婷婷一区二区| 久久久久久影视| 中文字幕欧美激情一区| 中文字幕第一区| 国产精品情趣视频| 国产精品家庭影院| 综合久久一区二区三区| 亚洲男同性恋视频| 一区二区三区鲁丝不卡| 亚洲主播在线播放| 亚洲午夜成aⅴ人片| 日韩国产欧美在线视频| 蜜臀久久99精品久久久久宅男| 日本欧洲一区二区| 久久av老司机精品网站导航| 老司机精品视频导航| 国产一区二区视频在线| 国产精品自拍三区| 99久久久国产精品免费蜜臀| 一本久道久久综合中文字幕| 欧美日韩一区二区三区视频| 91精品国产综合久久久久久漫画 | 久久这里都是精品| 国产欧美一区二区精品婷婷| 日本一区二区不卡视频| 亚洲激情成人在线| 七七婷婷婷婷精品国产| 国产精品99久久久久久久vr| 成人黄页在线观看| 欧美色视频一区| 精品国产乱码久久久久久影片| 久久久九九九九| 亚洲精品成a人| 日本亚洲欧美天堂免费| 国产精品77777| 在线视频一区二区免费| 日韩欧美成人一区二区| 中文字幕在线观看不卡| 亚洲成人免费影院| 国产成人精品免费| 欧美日韩五月天| 久久精品日韩一区二区三区| 亚洲最新视频在线观看| 麻豆国产欧美一区二区三区| youjizz久久| 欧美日本视频在线| 国产精品私人影院| 日本va欧美va精品发布| 99在线视频精品| 欧美一级欧美一级在线播放| 国产精品免费久久久久| 蜜桃久久久久久| 色婷婷亚洲婷婷| 久久久影视传媒| 日韩精品电影在线| 成人av在线网站| 精品国产一区二区三区久久影院| 亚洲另类在线视频| 国产精品小仙女| 日韩色视频在线观看| 亚洲另类春色国产| 国产精品自在欧美一区| 7777精品伊人久久久大香线蕉| 中文字幕永久在线不卡| 久久超碰97中文字幕| 欧洲一区二区三区免费视频| 久久久久9999亚洲精品| 美女视频网站久久| 欧美三级视频在线| 亚洲三级在线免费| 成人在线视频一区| 亚洲精品一区二区在线观看| 婷婷激情综合网| 欧美性xxxxxx少妇| 亚洲色欲色欲www在线观看| 国产一区二区精品久久99| 欧美日韩国产另类不卡| 亚洲精品国产品国语在线app| 国产大陆精品国产| 精品免费视频.| 免费欧美在线视频| 69精品人人人人| 亚洲bt欧美bt精品| 欧美色涩在线第一页| 亚洲宅男天堂在线观看无病毒| 岛国一区二区三区| 国产欧美日韩不卡| 国产成人免费av在线| 久久综合久久99| 国产另类ts人妖一区二区| 精品国产乱码久久久久久浪潮| 秋霞午夜鲁丝一区二区老狼| 7777精品伊人久久久大香线蕉超级流畅 | 国产69精品久久久久777| 久久综合久久鬼色| 国产福利91精品一区| 久久综合成人精品亚洲另类欧美| 久久国产欧美日韩精品| 精品国产伦一区二区三区观看体验| 蜜臀av一区二区在线观看| 欧美一区二区三区在线观看视频 | 亚洲夂夂婷婷色拍ww47| 欧洲视频一区二区| 亚洲福中文字幕伊人影院| 欧美日韩国产bt| 美腿丝袜亚洲一区| 久久综合色综合88| 粉嫩av一区二区三区粉嫩| 欧美国产日韩a欧美在线观看| 成人蜜臀av电影| 亚洲欧洲一区二区在线播放| 91视频观看视频| 性做久久久久久免费观看欧美| 欧美精选午夜久久久乱码6080| 日本欧美一区二区| 久久综合狠狠综合| 北条麻妃一区二区三区| 一区二区视频在线看| 3atv在线一区二区三区| 精品一区二区三区的国产在线播放| 久久综合九色综合97婷婷| 成人黄色777网| 亚洲一区二区精品视频| 欧美一区二区在线看| 国产精品一级黄| 亚洲三级电影全部在线观看高清| 91福利国产成人精品照片| 青娱乐精品视频在线| 国产精品拍天天在线| 欧美天堂一区二区三区| 国产综合久久久久久久久久久久| 国产精品乱码人人做人人爱| 欧美亚州韩日在线看免费版国语版|