stdafx.h #pragma once #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers #include #include #include // TODO: reference additional headers your program requires here #include "SDL/SDL.h" #include "SDL/SDL_image.h" #include "Display.h" #include "strekman.h" strekman.cpp #include "stdafx.h" void Strekman::set_display_pointer( Display *pointer ) { display = pointer; } void Strekman::print_man( int x, int y ) { if( display ) display->print_image( "test.png", x, y ); } strekman.h #pragma once class Strekman { public: Strekman() {}; virtual ~Strekman() {}; int print_man( int x, int y ); int set_display_pointer( Display *pointer ); private: Display *display; }; Display.cpp #include "stdafx.h" /* Ativates the window */ int Display::Activate( int a, int b, int c, int d ) { //Initialize all SDL subsystems if(SDL_Init( SDL_INIT_EVERYTHING ) == -1 ) { return 1; } screen = SDL_SetVideoMode( a, b, c, d ); if( screen == NULL ) { return 1; } SDL_WM_SetCaption( "WCS", NULL ); return 0; } SDL_Surface *Display::load_image( std::string filename ) { SDL_Surface* loadedImage = NULL; SDL_Surface* optimizedImage = NULL; loadedImage = IMG_Load( filename.c_str() ); if( loadedImage != NULL ) { optimizedImage = SDL_DisplayFormat( loadedImage ); SDL_FreeSurface( loadedImage ); } return optimizedImage; } int Display::print_image( std::string filename, int x, int y ) { message = load_image( filename ); apply_surface( x, y, message, screen ); SDL_Flip( screen ); } void Display::apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination ) { SDL_Rect offset; offset.x = x; offset.y = y; SDL_BlitSurface( source, NULL, destination, &offset ); } Display.h #pragma once class Display { public: Display() {}; virtual ~Display() {} int Activate( int a, int b, int c, int d ); int print_image( std::string filename, int x, int y ); private: //The surfaces that will be used void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination ); SDL_Surface *load_image( std::string filename ); SDL_Surface *message; SDL_Surface *background; SDL_Surface *screen; };