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


C++ Map::GetTileDest方法代码示例

本文整理汇总了C++中Map::GetTileDest方法的典型用法代码示例。如果您正苦于以下问题:C++ Map::GetTileDest方法的具体用法?C++ Map::GetTileDest怎么用?C++ Map::GetTileDest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Map的用法示例。


在下文中一共展示了Map::GetTileDest方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LoadEnemies

void Enemy_Handler::LoadEnemies( Game_Renderer* renderer, Map& map )
{
    //Delete all of the data before clearing
    for( int i = 0; i < enemies.size(); i++ )
        delete enemies[ i ];
    enemies.clear();

    for( int y = 0; y < map.GetMapTileHeight(); y++ ) {
        for( int x = 0; x < map.GetMapTileWidth(); x++ ) {
            switch( map.GetEnemy( x, y ) )
            {
            case Map::NONE:
                break;
            case Map::CORGI:
                enemies.push_back( new Enemy_Corgi( renderer, map.GetTileDest( x, y ).x, map.GetTileDest( x, y ).y - 64 ) );
                break;
            case Map::GREYHOUND:
                enemies.push_back( new Enemy_GreyHound( renderer, map.GetTileDest( x, y ).x, map.GetTileDest( x, y ).y - 64 ) );
                break;
            case Map::HUSKY:
                enemies.push_back( new Enemy_Husky( renderer, map.GetTileDest( x, y ).x, map.GetTileDest( x, y ).y - 64 ) );
                break;
            case Map::SHIBA:
                enemies.push_back( new Enemy_Shiba( renderer, map.GetTileDest( x, y ).x, map.GetTileDest( x, y ).y - 64 ) );
                break;
            case Map::BULLDOG:
                enemies.push_back( new Enemy_Bulldog( renderer, map.GetTileDest( x, y ).x, map.GetTileDest( x, y ).y - 64 ) );
                break;
            }
        }
    }
}
开发者ID:dbaker23,项目名称:TacoGato,代码行数:32,代码来源:Enemy_Handler.cpp

示例2: Move

void Corgi_Physics::Move( Component_Game_Actor& actor, Map &map, float timeStep )
{        
    int previousx = tempNewX;
    int previousy = tempNewY;
    //Temporary holdings for the speeds
    tempNewX += (int)xVelocity * timeStep;
    tempNewY += (int)yVelocity * timeStep;    

    actorBox.x = tempNewX;
    actorBox.y = tempNewY;

    //moving right
    if( xVelocity > 0 )
    {
        //Check out of bounds right
        if( tempNewX + actorBox.w < map.GetMapWidth() ) {
            //Get the tile where the actor is
            xTile       = ( tempNewX + actorBox.w ) / TILE_SIZE;
            yTile       = tempNewY / TILE_SIZE;
            int midTile = ( tempNewY + ( actorBox.h / 2 ) ) / TILE_SIZE;
            //int botTile = ( tempNewY + actorBox.h - 1 ) / TILE_SIZE;
            //Check the tile just to the right
            if( map.GetCollision( xTile, yTile ) || map.GetCollision( xTile, midTile ) ) {
                //Check box collision for all tiles in front of the character.
                if( Game_Collision::CheckCollisionBox( map.GetTileDest( xTile, yTile ), actorBox ) ) {
                    actorBox.x = previousx;
                    tempNewX = previousx;
                    StopX();
                    SetXVelocity( NEGATIVE_MOVEMENT );
                } else if( Game_Collision::CheckCollisionBox( map.GetTileDest( xTile, midTile ), actorBox ) ) {
                    actorBox.x = previousx;
                    tempNewX = previousx;
                    StopX();
                    SetXVelocity( NEGATIVE_MOVEMENT );
                } /*else if( Game_Collision::CheckCollisionBox( map.GetTileDest( xTile, botTile ), actorBox ) ) {
                    actorBox.x = previousx;
                    tempNewX = previousx;
                } */
            }
            
        } else {
            tempNewX = map.GetMapWidth() - actor.GetGraphics()->GetDestination().w - TILE_SIZE;
            StopX();
            SetXVelocity( NEGATIVE_MOVEMENT );
        }
    }

    //moving left
    else if( xVelocity < 0 )
    {
        //Check out of bounds left
        if( tempNewX > 0 ) {
            //Get the tile where the actor is
            xTile       = tempNewX / TILE_SIZE;
            yTile       = tempNewY / TILE_SIZE;
            int midTile = ( tempNewY + ( actorBox.h / 2 ) ) / TILE_SIZE;
            //int botTile = ( tempNewY + actorBox.h - 1) / TILE_SIZE;
            //Check the tile just to the right
            if( map.GetCollision( xTile, yTile ) || map.GetCollision( xTile, midTile ) ) {
                //Check box collision for all tiles in front of the character.a
                if( Game_Collision::CheckCollisionBox( map.GetTileDest( xTile, yTile ), actorBox ) ) {
                    actorBox.x = previousx;
                    tempNewX = previousx;
                    StopX();
                    SetXVelocity( POSITIVE_MOVEMENT );
                } else if ( Game_Collision::CheckCollisionBox( map.GetTileDest( xTile, midTile ), actorBox ) ) {
                    actorBox.x = previousx;
                    tempNewX = previousx;
                    StopX();
                    SetXVelocity( POSITIVE_MOVEMENT );
                }/* else if ( Game_Collision::CheckCollisionBox( map.GetTileDest( xTile, botTile ), actorBox ) ) {
                    actorBox.x = previousx;
                    tempNewX = previousx;
                }  */ 
            }
        } else  {
            tempNewX = 0;
            StopX();
            SetXVelocity( POSITIVE_MOVEMENT );
            }
    }

    //Falling
    //if( yVelocity > 0 ) {
        //Check bounds bottom
        if( tempNewY + actor.GetGraphics()->GetDestination().h < SCREEN_HEIGHT ) {
            // left side of the sprite underneath
            yTile = ( tempNewY + actorBox.h ) / TILE_SIZE;
            xTile = tempNewX / TILE_SIZE;
            //middle underneath
            int midX   = ( tempNewX + ( actorBox.w / 2 ) ) / TILE_SIZE;
            // right side of the sprite underneath
            int rightX = ( tempNewX + actorBox.w ) / TILE_SIZE;
            //Check both undersides of the sprite to see if it should stop falling
            if( map.GetCollision( xTile, yTile ) || map.GetCollision( rightX, yTile ) || map.GetCollision( midX, yTile ) ) {
                if( Game_Collision::CheckCollisionBox( map.GetTileDest( xTile, yTile ), actorBox ) ) {
                        actor.SetState( ACTOR_STAND );
                        jumpTotal = 0;
                        tempNewY = map.GetTileDest( xTile, yTile ).y - actorBox.h;
                        actorBox.y = tempNewY;
//.........这里部分代码省略.........
开发者ID:dbaker23,项目名称:TacoGato,代码行数:101,代码来源:Corgi_Physics.cpp


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