#include <stdio.h> #include <stdlib.h> #include <SDL/SDL.h> #include <SDL/SDL_image.h> int main(int argc, char *argv[]) { SDL_Surface *screen, *imagen_cursor; SDL_Rect dest; SDL_Event event; int done = 0; // Iniciar SDL if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO) < 0) { printf("No se pudo iniciar SDL: %s\n",SDL_GetError()); exit(1); } // Activamos modo de video screen = SDL_SetVideoMode(738,633,32,SDL_HWSURFACE | SDL_DOUBLEBUF); if (screen == NULL) { printf("No se puede inicializar el modo gráfico: \n",SDL_GetError()); exit(1); } imagen_cursor = IMG_Load("cursor.png"); SDL_ShowCursor( SDL_DISABLE ); while(done == 0) { while(SDL_PollEvent(&event)){ switch( event.type ) { case SDL_MOUSEMOTION: dest.x=event.motion.x; dest.y=event.motion.y; break; case SDL_QUIT: done = 1; break; } } dest = (SDL_Rect) {dest.x,dest.y, 0, 0}; SDL_BlitSurface( imagen_cursor, NULL, screen, &dest ); SDL_Flip(screen); } return 0; }
|