Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SDL/SDL.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[])
- {
- //odpalanie okna
- 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("moj","moj");
- int koniec=0,R,G,B,x,y,w,h;
- 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);
- /*int R=255,G=255,B=255,x=0,y=0,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;
- }
- }
- */
- }
- SDL_FreeSurface(okno);
- SDL_Quit();
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment