How to hardcode XMP sprites?

Hurray! Finally I solved it. Here is the code:

Code:

#include “plupp.xpm”
#include “SDL_image.h”

int Position(int x, int y, SDL_Surface* Display)
{
SDL_Rect offset;
offset.x = x;
offset.y = y;
SDL_Surface *Image;

Image=IMG_ReadXPMFromArray(plupp_xpm);
if(!Image)
{
	printf("IMG_ReadXPMFromArray: %s\n", IMG_GetError());
}

SDL_BlitSurface( Image, NULL, Display, &offset );
SDL_FreeSurface ( Image );

return 0;	

}

…and I compiled with this command:
gcc main.c -o main sdl-config --config --cflags --libs -lSDL -lSDL_image

nice one Sababa!On Wed, Mar 3, 2010 at 3:46 AM, sababa.sababa <sababa.sababa at gmail.com>wrote:

Hurray! Finally I solved it. Here is the code:

Code:

#include “plupp.xpm”
#include “SDL_image.h”

int Position(int x, int y, SDL_Surface* Display)
{
SDL_Rect offset;
offset.x = x;
offset.y = y;
SDL_Surface *Image;

Image=IMG_ReadXPMFromArray(plupp_xpm);

if(!Image)
{
printf(“IMG_ReadXPMFromArray: %s\n”, IMG_GetError());
}

SDL_BlitSurface( Image, NULL, Display, &offset );
SDL_FreeSurface ( Image );

return 0;
}

…and I compiled with this command:
gcc main.c -o main sdl-config --config --cflags --libs -lSDL -lSDL_image


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Erik Yuzwa
I’d love to help out! Find me on:


http://www.erikyuzwa.com
http://www.twitter.com/eyuzwa

Well, this is certainly a compact representation of the things you must do
to accomplish what you want, but if you use this without any changes then
you will incur wasteful overhead from instantiating and destroying your
sprite surface every time you draw it with Position()!On Wed, Mar 3, 2010 at 5:46 AM, sababa.sababa <sababa.sababa at gmail.com>wrote:

Hurray! Finally I solved it. Here is the code:

Code:

#include “plupp.xpm”
#include “SDL_image.h”

int Position(int x, int y, SDL_Surface* Display)
{
SDL_Rect offset;
offset.x = x;
offset.y = y;
SDL_Surface *Image;

Image=IMG_ReadXPMFromArray(plupp_xpm);

if(!Image)
{
printf(“IMG_ReadXPMFromArray: %s\n”, IMG_GetError());
}

SDL_BlitSurface( Image, NULL, Display, &offset );
SDL_FreeSurface ( Image );

return 0;
}

…and I compiled with this command:
gcc main.c -o main sdl-config --config --cflags --libs -lSDL -lSDL_image


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


http://codebad.com/