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


C++ Dot::get_x方法代码示例

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


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

示例1: load_files

bool load_files( Dot &thisDot, Uint32 &bg )
{
    //Load the dot image
    dot = load_image( "dot.png" );

    //If there was a problem in loading the dot
    if( dot == NULL )
    {
        return false;
    }

    //Open a file for reading
    std::ifstream load( "game_save" );

    //If the file loaded
    if( load != NULL )
    {
        //The offset
        int offset;

        //The level name
        std::string level;

        //Set the x offset
        load >> offset;
        thisDot.set_x( offset );

        //Set the y offset
        load >> offset;
        thisDot.set_y( offset );

        //If the x offset is invalid
        if( ( thisDot.get_x() < 0 ) || ( thisDot.get_x() > SCREEN_WIDTH - DOT_WIDTH ) )
        {
            return false;
        }

        //If the y offset is invalid
        if( ( thisDot.get_y() < 0 ) || ( thisDot.get_y() > SCREEN_HEIGHT - DOT_HEIGHT ) )
        {
            return false;
        }

        //Skip past the end of the line
        load.ignore();

        //Get the next line
        getline( load, level );

        //If an error occurred while trying to read the data
        if( load.fail() == true )
        {
            return false;
        }

        //If the level was white
        if( level == "White Level" )
        {
            //Set the background color
            bg = SDL_MapRGB( screen->format, 0xFF, 0xFF, 0xFF );
        }
        //If the level was red
        else if( level == "Red Level" )
        {
            //Set the background color
            bg = SDL_MapRGB( screen->format, 0xFF, 0x00, 0x00 );
        }
        //If the level was green
        else if( level == "Green Level" )
        {
            //Set the background color
            bg = SDL_MapRGB( screen->format, 0x00, 0xFF, 0x00 );
        }
        //If the level was blue
        else if( level == "Blue Level" )
        {
            //Set the background color
            bg = SDL_MapRGB( screen->format, 0x00, 0x00, 0xFF );
        }

        //Close the file
        load.close();
    }
开发者ID:Isu-Bae,项目名称:HW-ISU,代码行数:83,代码来源:lesson24.cpp


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