Dépendances (dans l'archive) :
fond.bmp
#include <sdl/sdl.h> #pragma comment(lib,"sdl.lib") #pragma comment(lib,"sdlmain.lib") #define SPEED -1 #define IMX 368 #define IMY 388 SDL_Surface* Charger(const char* fic) { SDL_Surface *res; SDL_Surface* tmp = SDL_LoadBMP(fic); if (tmp==NULL) { printf("Erreur chargement %s\n",fic); exit(-1); } res = SDL_DisplayFormat(tmp); SDL_FreeSurface(tmp); return res; } int KeyHit() { SDL_Event e; if (SDL_PollEvent(&e)) if (e.type == SDL_KEYDOWN) return 1; return 0; } int negatmodulo(int x,int mod) { if (x>=0) return x%mod; return (x%mod)+mod; } int main(int argc,char** argv) { SDL_Surface* fond,*screen; int x = 0; SDL_Init(SDL_INIT_VIDEO); screen=SDL_SetVideoMode(IMX,IMY,32,SDL_SWSURFACE|SDL_DOUBLEBUF); fond=Charger("fond.bmp"); while(!KeyHit()) { SDL_Rect R; R.x = negatmodulo(x,IMX); R.y = 0; SDL_BlitSurface(fond,NULL,screen,&R); R.x = negatmodulo(x,IMX) - IMX; SDL_BlitSurface(fond,NULL,screen,&R); x+=SPEED; SDL_Flip(screen); SDL_Delay(3); } SDL_FreeSurface(fond); SDL_Quit(); return 0; }
No explanations yet.