Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SDL/SDL.h>
- #include <stdio.h>
- void maluj(SDL_Surface *okno,int x, int y, int w, int h, int R, int G, int B)
- {
- SDL_Rect prostokat;
- prostokat.x=x;
- prostokat.y=y;
- prostokat.w=w;
- prostokat.h=h;
- SDL_FillRect(okno,&prostokat,SDL_MapRGB(okno->format,R,G,B));
- SDL_UpdateRect(okno,x,y,w,h);
- return;
- }
- int main(int argc,char *argv[])
- {
- SDL_Surface *okno;
- if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER))
- {
- printf("%s\n",SDL_GetError());
- }
- else
- {
- okno=SDL_SetVideoMode(640,480,32,SDL_ANYFORMAT);
- if(!okno)
- {
- printf("%s\n",SDL_GetError());
- }
- else
- {
- SDL_WM_SetCaption("dupa","dupa"); //nazwa okna
- /*
- Wyswietlo na ekranie czone, przechodzi w biole i sie zmniejszo
- int R=255,G=255,B=255;
- int x=0,y=0;
- int w=100, h=100;
- for(;R>=0;R--,G--,B--,x++,y++,w+=2,h+=2)
- {
- maluj(okno,x,y,w,h,R,G,B);
- SDL_Delay(10);
- }
- int koniec=0;
- SDL_Event komunikat;
- while((!koniec)&&(SDL_WaitEvent(&komunikat)))
- {
- if(komunikat.type==SDL_QUIT)
- {
- koniec=~0; //inaczej koniec=1, to samo w sumie
- }
- }
- */
- int R=255,G=255,B=255;
- int x=0,y=0;
- int w=100, h=100;
- int koniec=0;
- SDL_Event komunikat;
- while(!koniec)
- {
- if(SDL_PollEvent(&komunikat)&&(komunikat.type==SDL_QUIT))
- {
- koniec=1;
- }
- R=rand()%256;
- G=rand()%256;
- B=rand()%256;
- x=rand()%640;
- y=rand()%480;
- w=rand()%640;
- h=rand()%480;
- maluj(okno,x,y,w,h,R,G,B);
- SDL_FreeSurface(okno);
- }
- SDL_Quit();
- }
- return 0;
- }
- }
Add Comment
Please, Sign In to add comment