#ifndef IMAGE_H
#define IMAGE_H

SDL_Surface *screen;
SDL_Surface *space;
SDL_Surface *space_2;
SDL_Surface *player_up, *player_rt, *player_dn, *player_lt, *player;
SDL_Surface *ship_up, *ship_rt, *ship_dn, *ship_lt; 
SDL_Surface *ship_2;
SDL_Surface *planet_1;
SDL_Surface *planet_2;
SDL_Surface *sputnik_1;
SDL_Surface *sputnik_2;
SDL_Surface *arrow_up, *arrow_rt, *arrow_dn, *arrow_lt;
SDL_Surface *menu, *inv, *battle;
SDL_Surface *p_beam, *e_beam;

SDL_Surface *boom_1,*boom_2,*boom_3,*boom_4,*boom_5,*boom_6,*boom_7,*boom_8,*boom_9,*boom_10,*p_rocket;

//загрузка ÐºÐ°Ñ€Ñ‚инок
SDL_Surface *load_image( std::string filename ) 
{
    //The image that's loaded
    SDL_Surface* loadedImage = NULL;
    
    //The optimized image that will be used
    SDL_Surface* optimizedImage = NULL;
    
    //Load the image
    loadedImage = IMG_Load( filename.c_str() );
    
    //If the image loaded
    if( loadedImage != NULL )
    {
        //Create an optimized image
        optimizedImage = SDL_DisplayFormatAlpha( loadedImage );
        
        //Free the old image
        SDL_FreeSurface( loadedImage );
    }
    
    //Return the optimized image
    return optimizedImage;
}

//просто Ð½Ð°Ñ€Ð¸ÑÐ¾Ð²Ð°Ñ‚ÑŒ ÐºÐ°Ñ€Ñ‚инку
void img_draw ( SDL_Surface *img, int x, int y )
{
    SDL_Rect dest;
    dest.x = x;
    dest.y = y;
    SDL_BlitSurface ( img, NULL, screen, &dest );
}

//рисует Ð·Ð°ÐºÑ€Ð°ÑˆÐµÐ½Ð½Ñ‹Ð¹ Ð¿Ñ€ÑÐ¼Ð¾ÑƒÐ³Ð¾Ð»ÑŒÐ½Ð¸Ðº
void img_rect ( int x, int y, int w, int h, Uint8 R = 255, Uint8 G = 255, Uint8 B = 255 )
{
    Uint32 color = SDL_MapRGB ( screen->format, R, G, B );
    SDL_Rect dest;
    dest.x = x;
    dest.y = y;
    dest.w = w;
    dest.h = h;
    SDL_FillRect ( screen, &dest, color );
}

//рисует (или Ð¿ÐµÑ‡Ð°Ñ‚ает) Ñ‚екст Ð½Ð° ÑÐºÑ€Ð°Ð½Ðµ - ÑÐ°Ð¼Ð°Ñ Ñ‚ормозящая Ñ„ункция Ð² Ð¸Ð³Ñ€Ðµ,
//но Ñ€Ð°Ð·Ñ€Ð°Ð±Ð°Ñ‚ывать ÐµÑ‰Ðµ Ð¸ ÑÐ²Ð¾Ð¸ ÑˆÑ€Ð¸Ñ„ты Ð¾Ñ‚кровенно Ð»ÐµÐ½ÑŒ
void img_text ( char message[200], int size, int x, int y, Uint8 R = 0, Uint8 G = 0, Uint8 B = 0 )
{
    SDL_Color color = {R, G, B, 0};
    SDL_Rect dest;
    dest.x = x;
    dest.y = y;
    //с Ñ‚рудом Ð´Ð¾Ð±Ñ‹Ñ‚ый ÑˆÑ€Ð¸Ñ„Ñ‚, Ñ‡Ñ‚обы ÐºÐ¸Ñ€Ð¸Ð»Ð»Ð¸Ñ†Ð° Ñ€Ð°Ð±Ð¾Ñ‚ала
    TTF_Font *fnt = TTF_OpenFont ( "un1251n.ttf", size );
    SDL_Surface *sText = TTF_RenderText_Blended ( fnt, message, color );
    SDL_BlitSurface ( sText, NULL, screen, &dest );
    SDL_FreeSurface ( sText );
    TTF_CloseFont ( fnt );
}
#endif