I’m doing a tiled background but when the tiles get clipped the
function SDL_BlitSurface doesn’t write more tiles.
Have I to use a function to inform the surface about the clipping,
or it’s a bug in SDL?
I attach my code.
|||
(o -)
oOOo(_)oOOo-----------------------------
" Real users hate Real programmers " |
---|
@Gorka |
http://web.jet.es/~olsago/ |
http://fly.to/luzluciernaga |
-------------- next part --------------
#include <SDL.h>
SDL_Surface *image, *screen;
#define X 15 /* Change this to a minor number to see that it works /
#define Y 11 / Change this to a minor number to see that it works */
void draw_background(SDL_Surface *source, SDL_Surface *dest)
{
SDL_Rect pos;
unsigned int i, j;
pos.w = source->w;
pos.h = source->w;
pos.y=0;
for (i=0; i<Y; i++){
pos.x=0;
for (j=0; j<X; j++) {
SDL_BlitSurface(source, NULL, dest, &pos);
pos.x+=source->w;
}
pos.y+=source->h;
}
}
main()
{
SDL_Init(SDL_INIT_VIDEO);
screen = SDL_SetVideoMode(640, 480, 16, SDL_DOUBLEBUF);
image=SDL_LoadBMP("tile.bmp");
draw_background(image, screen);
SDL_Flip(screen);
while(!SDL_PollEvent(NULL));
return(0);
}