Guest User

Untitled

a guest
Jan 19th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. #include <SDL/SDL.h>
  2.  
  3.  
  4. void maluj(SDL_Surface *okno,int x, int y, int w, int h, int R, int G, int B)
  5. {
  6. SDL_Rect prostokat;
  7. prostokat.x=x;
  8. prostokat.y=y;
  9. prostokat.w=w;
  10. prostokat.h=h;
  11.  
  12. SDL_FillRect(okno, &prostokat, SDL_MapRGB(okno->format, R,G,B));
  13. SDL_UpdateRect(okno,x,y,w,h);
  14. return;
  15. }
  16.  
  17.  
  18. int main (int argc, char *argv[])
  19.  
  20. {
  21. //odpalanie okna
  22. SDL_Surface *okno;
  23.  
  24. if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER))
  25. {
  26. printf("%s\n",SDL_GetError());
  27. }
  28.  
  29. else
  30. {
  31. okno=SDL_SetVideoMode(640,480,32,SDL_ANYFORMAT);
  32. if(!okno)
  33. {
  34. printf("%s\n",SDL_GetError());
  35. }
  36. else
  37. {
  38.  
  39. }
  40.  
  41. SDL_WM_SetCaption("moj","moj");
  42. int koniec = 0,R,G,B,x,y,w,h;
  43. SDL_Event komunikat;
  44. while(!koniec) //! = nie
  45. {
  46.  
  47. if((SDL_PollEvent(&komunikat)&&(komunikat.type==SDL_QUIT)))
  48. {
  49. koniec=1;
  50. }
  51.  
  52. R=rand()%256;
  53. G=rand()%256;
  54. B=rand()%256;
  55.  
  56. x=rand()%640;
  57. y=rand()%480;
  58. w=rand()%640;
  59. h=rand()%480;
  60.  
  61. maluj(okno,x,y,w,h,R,G,B);
  62.  
  63.  
  64. }
  65.  
  66.  
  67. /*
  68. int R=255,G=255,B=255,x=0,y=0,w=100,h=100;
  69. for(;R>=0;R--,G--,B--,x++,y++,w+=2,h+=2)
  70. {
  71. maluj(okno,x,y,w,h,R,G,B);
  72. SDL_Delay(10);
  73. }
  74.  
  75. int koniec = 0;
  76. SDL_Event komunikat;
  77.  
  78.  
  79. while((!koniec)&&(SDL_WaitEvent(&komunikat)))
  80. {
  81. if (komunikat.type==SDL_QUIT)
  82. {
  83. koniec =~0;
  84. }
  85. }
  86. */
  87. SDL_FreeSurface(okno);
  88. SDL_Quit();
  89. }
  90. return 0;
  91.  
  92. }
Add Comment
Please, Sign In to add comment