------

[ AD ] Port Monitor ( Try to use a Best WebSite Monitoring Tool )

------
#include 

#include "SDL/SDL.h"

#include 




SDL_Surface*     load_image( std::string filename );

void             apply_surface( int x, int y, SDL_Surface* src, SDL_Surface *dest );




enum

{

    SCREEN_WIDTH = 640,

    SCREEN_HEIGHT = 480,

    SCREEN_BPP=32

};




int main(int argc, char **argv)

{

    SDL_Surface* message = NULL;

    SDL_Surface* background = NULL;

    SDL_Surface* screen=NULL;

    

    // Start SDL

    if ( SDL_Init(SDL_INIT_EVERYTHING) == -1 )

    {

         return 1;

    }

    // Set up screen

    // 640 pixel wide, 480 pixel high

    // 32 bits per pixel

    screen=SDL_SetVideoMode(

        SCREEN_WIDTH,

        SCREEN_HEIGHT,

        SCREEN_BPP,

        SDL_SWSURFACE);

    if ( screen == NULL )

    {

         return 1;

    }

    // Set the window caption

    SDL_WM_SetCaption( "kight & castle" , NULL );

    // image : Load -> Blit ( Block Image Transfer from Bit blit ) 

    // Load image

    //background = SDL_LoadBMP("back.bmp");

    background = load_image("background.bmp");

    message = load_image("knight.bmp");




    // Apply image to screen

    //SDL_BlitSurface( background, NULL, screen, NULL );

    apply_surface(0,0, background, screen );




    apply_surface(240,50, message, screen );

    // ----------X

    // |

    // |

    // |

    // Y

    

    // Update Screen

    if ( SDL_Flip(screen) == -1 )

    {

         return 1;

    }

    // Pause

    SDL_Delay(5000);

    

    // Free the loaded image

    SDL_FreeSurface( message );

    SDL_FreeSurface( background );

    //

    SDL_Quit();

    return 0;

}




// image loading function

SDL_Surface* load_image( std::string filename )

{

    // Temporary storage for the image that's loaded

    SDL_Surface* loadedImage = NULL;

    

    // The optimized image that will be used

    SDL_Surface* optimizedImage = NULL;

    

    // Load the image

    loadedImage = SDL_LoadBMP ( filename.c_str() );

    // because bitmap is 24-bit, The screen is 32-bit

    if ( loadedImage != NULL )

    {

         // Create an optimized image : 24 bits -> 32 bits

         optimizedImage = SDL_DisplayFormat ( loadedImage ) ;

         // 

         

         // SDL_FreeSurface ( loadedImage );

    }

    // Return the optimized image

    return optimizedImage;         

}




// surface blitting function

void apply_surface( int x, int y, SDL_Surface* src, SDL_Surface *dest )

{

     // Make a temporary rectangle to hold the offsets

     SDL_Rect  offset;

     

     // Give the offsets to the rectangle

     offset.x = x;

     offset.y = y;

     

     // Blit the surface

     SDL_BlitSurface ( src, NULL, dest, &offset );

}     

       

'온라인게임' 카테고리의 다른 글

기획 방법론 문제 해결  (0) 2011.10.10
게임학(ludology)과 서사학(narratology)  (0) 2011.10.10
MSSQL DB 복사  (0) 2011.08.03
순환 순서 방식  (0) 2011.07.14
Stack with std::list  (0) 2011.07.01

+ Recent posts