int load_tiles()
{
int i, j;
PD_Surface *buffer;
buffer = PD_LoadImage(“tiles.pcx”);
num=0;
for(i=0;i<4;i++) {
for(j=0;j<10;j++) {
PD_Blit (buffer, gfx_tiles[num++], j32, i50, 0, 0, 32, 50);
}
}
free(buffer);
return(1);
}
This is the code using my PowerDraw lib, to convert it to pure SDL replace
buffer = PD_LoadImage(“tiles.pcx”) with whatever image loader you are
using and replace
PD_Blit(buffer, gfx_tiles[num++], j32, i50, 0, 0, 32, 50); with
src.x = j32;
src.y = i50;
src.w = 32;
src.h =50;
dest.x = 0;
dest.y = 0;
dest.w = 32;
dest.h = 50;
SDL_BlitSurface(Src, &src, Dest, &dest);
Dont forget to declare SDL_Rect src, dest and to declare and create a
surface for gfx_tiles[] you will need to change the 32 and 50 to the width
and height of your sprites.
*note this code is from Frank Ramsey’s isometric engine that I ported over
to my PowerDraw lib. I don’t want to take undue credit.
Ryan Wahle wrote:
Yeah, that would be cool if you could post the code…
Thanks!!
Ryan Wahle wrote:
Hello,
I was wondering if it was possible to have like a pcx file, with
multiple
images in it. So one pcx file would like contain all the frames for
the
animation… all the frames would be the same size, but I was
wondering if
it was possible to grap certain parts of an image and put them into
a
SDL_Surface structure. Kind of like a SDL_loadBMP but it wouldn’t
take the
source from a file, and instead take it from an array instead…
is this possible with the sdl?
Yes, just create a surface for the PCX and a surface for the sprite.
Then do
a blit from the PCX surface to the sprite surface, but don’t blit the
whole
PCX surface, just blit the rectangular area that the sprite is in, and
then
do that for all of the sprites, preferably in a loop that just
increments the
blit by the size of the sprite. I can post the code to do it if you
need meOn Wed, 25 Aug 1999, John Garrison wrote:
to.
thanks. see ya