[SDL] Newb ?

Clemens Kirchgatterer clemens at thf.ath.cx
Tue Mar 25 13:52:01 PST 2003


Clemens Kirchgatterer <clemens at thf.ath.cx> wrote:

i hate to reply to my own mails but ...

> SDL_Init();
> screen = SDL_SetVideoMode();
> bgr = IMG_Load(background);
> tux = IMG_Load(tux);
> bak = SDL_CreateSurface(); // for background backup
> SDL_BlitSurface(background, screen);
> SDL_Flip();
> while (SDL_PollEvent()) {
> 	SDL_Rect pos;
> 
> 	switch (event) {
> 		case LEFT: x--; break
> 		...
> 	}
> 	pos.x = x; pos.y = y; 
> 	SDL_BlitSurface(screen, &pos, bak, NULL); 
> 	SDL_BlitSurface(tux, NULL, screen, &pos);
> 	SDL_UpdateRect(screen, pos.x, pos.y, pos.w, pos.h);

	// blit the backup back to the screen, but just don't update
	SDL_BlitSurface(bak, NULL, screen, &pos);

> }




More information about the SDL mailing list