Пример #1
0
//! Load image file
bool loadMedia( const std::string& foreground, 
		const std::string& background )
{
  bool success = true;
  
  // Load the foreground image
  if( !g_foreground.loadFromFile( foreground ) )
  {
    std::cerr << "Can't load foreground image "
	      << foreground
	      << "! SDL_Error: "
	      << SDL_GetError()
	      << std::endl;
    success = false;
  }   

  // Load the background image
  if( !g_background.loadFromFile( background ) )
  {
    std::cerr << "Can't load background image "
	      << background
	      << "! SDL_Error: "
	      << SDL_GetError()
	      << std::endl;
    success = false;
  }
    
  return success;
}
Пример #2
0
// Load image file
bool loadMedia( const std::string& sprite_sheet_name,
		const unsigned char color_key_red,
		const unsigned char color_key_green,
		const unsigned char color_key_blue )
{
  bool success = true;
  
  // Load the image file
  bool file_loaded = 
    g_sprite_sheet_texture.loadFromFile( sprite_sheet_name, 
					 color_key_red,
					 color_key_green,
					 color_key_blue );
  if( !file_loaded )
  {
    std::cerr << "Can't load sprite sheet " << sprite_sheet_name
	      << "! SDL_Error: " << SDL_GetError()
	      << std::endl;
    success = false;
  }   
  else
  {
    // Set sprite clips
    g_sprite_clips[0].x = 0;
    g_sprite_clips[0].y = 0;
    g_sprite_clips[0].w = 64;
    g_sprite_clips[0].h = 205;
    
    g_sprite_clips[1].x = 64;
    g_sprite_clips[1].y = 0;
    g_sprite_clips[1].w = 64;
    g_sprite_clips[1].h = 205;
    
    g_sprite_clips[2].x = 128;
    g_sprite_clips[2].y = 0;
    g_sprite_clips[2].w = 64;
    g_sprite_clips[2].h = 205;
    
    g_sprite_clips[3].x = 196;
    g_sprite_clips[3].y = 0;
    g_sprite_clips[3].w = 64;
    g_sprite_clips[3].h = 205;
  }
  
  return success;
}
Пример #3
0
//! Load image file
bool loadMedia( const std::string& filename,
		const unsigned char color_key_red,
		const unsigned char color_key_green,
		const unsigned char color_key_blue )
{
  bool success = true;
  
  // Load the image file
  bool file_loaded = 
    g_modulated_texture.loadFromFile( filename, 
				      color_key_red,
				      color_key_green,
				      color_key_blue );
  if( !file_loaded )
  {
    std::cerr << "Can't load image " << filename
	      << "! SDL_Error: " << SDL_GetError()
	      << std::endl;
    success = false;
  }   
  
  return success;
}