Guest User

Untitled

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