2 * Copyright (C) 2008 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 #include <SDL_image.h>
25 #define IS_CENTER(cx, cy, x, y) \
26 ((x + WIDTH/2 == cx) && (y + HEIGHT/2 == cy))
36 static SDL_Rect rect = {0, 0, WIDTH, HEIGHT};
40 next = (cur + 1) % (sizeof (points) / sizeof (SDL_Rect));
41 if (IS_CENTER (points[next].x, points[next].y, rect.x, rect.y))
44 next = (cur + 1) % (sizeof (points) / sizeof (SDL_Rect));
46 dx = (points[next].x > points[cur].x) ? 1 : -1;
47 dy = (points[next].y > points[cur].y) ? 1 : -1;
48 rect.x = (rect.x + dx) % WIDTH;
49 rect.y = (rect.y + dy) % HEIGHT;
54 ShowPoint (SDL_Surface *screen, SDL_Surface *image, SDL_Rect *rect)
56 SDL_BlitSurface (image, rect, screen, NULL);
57 SDL_UpdateRect (screen, 0, 0, 0, 0);
61 ShowNext (Uint32 interval, void *data)
64 event.type = SDL_USEREVENT;
66 SDL_PushEvent ((SDL_Event *) &event);
71 main (int argc, char **argv)
76 SDL_Init (SDL_INIT_VIDEO | SDL_INIT_TIMER);
77 screen = SDL_SetVideoMode (800, 600, 32, SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN);
78 image = IMG_Load ("/home/cascardo/fotos/debconf.jpg");
79 SDL_AddTimer (0, ShowNext, NULL);
80 while (SDL_WaitEvent (&event))
82 if (event.type == SDL_KEYDOWN)
84 else if (event.type == SDL_USEREVENT)
85 ShowPoint (screen, image, GetNextPoint ());
87 SDL_FreeSurface (image);