Título: canvio de imagen sdl Publicado por: peterfly en 30 Marzo 2012, 19:24 pm HOLA A TODOS... ESPERO QUE ME PUEDAN ayudar
TENGO EL SIGUIENTE CODIGO: #include <stdlib.h> #include <SDL/SDL.h> int main(int argc, char *argv[]) { SDL_Surface *screen, *fondo, *protagonista; SDL_Rect destino; int i, j; int xProt = 320, yProt= 400; int terminado = 0; SDL_Event suceso; Uint8* teclas; if (SDL_InitSubSystem(SDL_INIT_EVERYTHING) < 0) { printf("No se pudo inicializar SDL: %s\n", SDL_GetError()); exit(1); } fondo = SDL_LoadBMP("fondo.bmp"); protagonista = SDL_LoadBMP("fondo3.bmp"); screen = SDL_SetVideoMode( 640, 480, 16, SDL_HWSURFACE ); if(screen == NULL) { printf( "Error al entrar a modo grafico: %s\n", SDL_GetError() ); SDL_Quit(); return -1; } SDL_WM_SetCaption( "programa de procva!" , "Hola mundo" ); while(terminado == 0) { for (i=0; i<3; i++) for (j=0; j<3; j++) { destino.x=207*i; destino.y=211*j; SDL_BlitSurface(fondo, NULL, screen, &destino); } destino.x=xProt; destino.y=yProt; SDL_BlitSurface(protagonista, NULL, screen, &destino); SDL_Flip(screen); while (SDL_PollEvent(&suceso)) { if (suceso.type == SDL_QUIT) terminado = 1; if (suceso.type == SDL_KEYDOWN) if (suceso.key.keysym.sym == SDLK_ESCAPE) terminado = 1; } teclas = SDL_GetKeyState(NULL); if (teclas[SDLK_UP]) { yProt -= 2; } if (teclas[SDLK_DOWN]) { yProt += 2; } if (teclas[SDLK_LEFT]) { xProt -= 3; } if (teclas[SDLK_RIGHT]) { xProt += 3; } SDL_Delay( 50 ); } return 0; } Y MI PREGUNTA ES... COMO PUEDO HACER PARA QUE CUANDO LA IMAGEN QUE SE MUEVE ("fondo.bmp") CUANDO LLEGUE ARRIBA, CANVIE A OTRO FONDO DISTINTO AL ANTERIOR ("fondo3.bmp")??? "necesito para las 4 esquinas" Título: Re: canvio de imagen sdl Publicado por: anonimo12121 en 31 Marzo 2012, 14:35 pm con condicionales.
Te recomiendo que te pases a SFML. SDL esta estancado. Título: Re: canvio de imagen sdl Publicado por: Lateseles en 1 Abril 2012, 22:55 pm Podrias recomendarme un buen libro o algun sitio en el que poder obtener informacion sobre la libreria que mencionaste (sfml)
|