#include #include #include void refrescar (SDL_Surface *screen); int main(int argc, char *argv[]) { SDL_Surface *screen; SDL_Event event; int x = 10; int y = 10; if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) == -1) { printf("No se ha iniciado SDL"); } screen = SDL_SetVideoMode(320, 240, 16, SDL_SWSURFACE); SDL_WM_SetCaption("Programa pr0 del infinit", NULL); // Voy a dibujar cositas Uint32 tiempo = 50; while (x < 50) { Uint8 *key = SDL_GetKeyState(NULL); refrescar(screen); SDL_Rect rectangulo = {x, y, 20, 20}; Uint32 color = SDL_MapRGB(screen->format, 200, 200, 200); SDL_FillRect(screen, &rectangulo, color); SDL_UpdateRect(screen, 0, 0, 320, 240); x++; y++; SDL_Delay(tiempo); } while (SDL_WaitEvent(&event)) { if (event.type == SDL_QUIT) break; } SDL_Quit(); return 0; } void refrescar(SDL_Surface *screen) { Uint32 c = SDL_MapRGB(screen->format, 0, 0, 0); SDL_FillRect(screen, NULL, c); }