Dev codigo

Solo disponible en BuenasTareas
  • Páginas : 3 (573 palabras )
  • Descarga(s) : 0
  • Publicado : 27 de mayo de 2011
Leer documento completo
Vista previa del texto
//The headers
#include "SDL/SDL.h"
#include "SDL/SDL_image.h"

//Screen attributes
const int SCREEN_WIDTH = 640;
const int SCREEN_HEIGHT = 480;
const int SCREEN_BPP = 32;

//Flip flagsconst int FLIP_VERTICAL = 1;
const int FLIP_HORIZONTAL = 2;

//The surfaces
SDL_Surface *topLeft = NULL;
SDL_Surface *topRight = NULL;
SDL_Surface *bottomLeft = NULL;
SDL_Surface *bottomRight =NULL;
SDL_Surface *screen = NULL;

//The event structure
SDL_Event event;

SDL_Surface *load_image( char* filename )
{
//The image that's loaded
SDL_Surface* loadedImage = NULL;//The optimized surface that will be used
SDL_Surface* optimizedImage = NULL;

//Load the image
loadedImage = IMG_Load( filename );

//If the image loaded
if( loadedImage !=NULL )
{
//Create an optimized surface
optimizedImage = SDL_DisplayFormat( loadedImage );

//Free the old surface
SDL_FreeSurface( loadedImage );//If the surface was optimized
if( optimizedImage != NULL )
{
//Color key surface
SDL_SetColorKey( optimizedImage, SDL_SRCCOLORKEY, SDL_MapRGB(optimizedImage->format, 0, 0xFF, 0xFF ) );
}
}

//Return the optimized surface
return optimizedImage;
}

void apply_surface( int x, int y, SDL_Surface* source, SDL_Surface* destination,SDL_Rect* clip = NULL )
{
//Holds offsets
SDL_Rect offset;

//Get offsets
offset.x = x;
offset.y = y;

//Blit
SDL_BlitSurface( source, clip, destination, &offset);
}

Uint32 get_pixel32( SDL_Surface *surface, int x, int y )
{
//Convert the pixels to 32 bit
Uint32 *pixels = (Uint32 *)surface->pixels;

//Get the requested pixel
returnpixels[ ( y * surface->w ) + x ];
}

void put_pixel32( SDL_Surface *surface, int x, int y, Uint32 pixel )
{
//Convert the pixels to 32 bit
Uint32 *pixels = (Uint32 *)surface->pixels;...
tracking img