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