1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
|
#include "SDL.h"
#include <string>
#include <list>
#include "cardtypes.h"
#pragma comment (lib, "SDL.lib")
#pragma comment (lib, "SDLmain.lib")
const int SCREEN_WIDTH = 480;
const int SCREEN_HEIGHT = 272;
const int SCREEN_BPP = 32;
SDL_Surface * Load_Image( std::string filename )
{
SDL_Surface *loadedimage = NULL;
SDL_Surface *optimizedimage = NULL;
loadedimage = SDL_LoadBMP( filename.c_str() );
if( loadedimage != NULL )
{
optimizedimage = SDL_DisplayFormat( loadedimage );
SDL_FreeSurface( loadedimage );
}
return optimizedimage;
}
void 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 );
}
/*********************************/
// 108 cards total
// 19 Blue
// 19 Green
// 19 Red
// 19 Yellow
// 8 Draw two cards
// 8 Reverse cards
// 8 Skip cards
// 4 wild cards
// 4 Wild draw four cards
/*********************************/
int main( int argc, char* args[] )
{
std::list <Card> deck(108);
//std::vector <int>
if( SDL_Init( SDL_INIT_EVERYTHING ) )
return 1;
SDL_Surface *screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );
SDL_Surface *card = Load_Image( "card.bmp" );
if( screen == NULL )
return -1;
SDL_WM_SetCaption( "UNO", NULL );
Apply_Surface( ((SCREEN_WIDTH / 2)-(50/2)), ((SCREEN_HEIGHT / 2)-(60/2)), card, screen );
if( SDL_Flip( screen ) == -1 )
return 1;
SDL_Delay( 5000 );
SDL_FreeSurface( card );
SDL_Quit();
return 0;
}
|