SHARE
TWEET

Untitled

a guest Feb 24th, 2020 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. apskritimas ball;
  2. apskritimas[] mas;
  3. void setup()
  4. {
  5.   size(800, 800);
  6.   mas = new apskritimas[32];
  7.  
  8.   for (int i= 0; i<mas.length; i++)
  9.   {
  10.     ball =  new apskritimas();
  11.     ball.x  =(int) random(30, width - 30);
  12.     ball.y  =(int) random(30, width - 30);
  13.     ball.dydis = (int)random(5, 50);
  14.     ball.spalva = color((int)random(0, 255), (int)random(0, 255), (int)random(0, 255));
  15.     ball.greitix =  (int)random(2, 20);
  16.     ball.greitiy = (int)random(1, 15);
  17.     mas[i]=ball;
  18.   }
  19.   ball =  new apskritimas();
  20.   ball.x = 50;
  21.   ball.y = 400;
  22.   ball.dydis = 40;
  23.   ball.spalva =  color(200, 0, 200);
  24.   ball.greitix = 10;
  25.   ball.greitiy = 5;
  26. }
  27.  
  28. void draw()
  29. {
  30.   background(255);
  31.   ball.rodyk();
  32.   ball.judek();
  33.   for (int i= 0; i<mas.length; i++)
  34.   {
  35.     mas[i].rodyk();
  36.     mas[i].judek();
  37.   }
  38. }
  39.  
  40.  
  41. -------------------------------------------------------------------
  42.  
  43. class apskritimas
  44. {
  45.  int x;
  46.  int y;
  47.  int dydis;
  48.  color spalva;
  49.  int greitix;
  50.  int greitiy;
  51.  
  52.  void rodyk()
  53.  {
  54.   fill(spalva);
  55.   ellipse(x, y, dydis, dydis);
  56.  }
  57.  void judek()
  58.  {
  59.    x =  x+ greitix;
  60.    y = y + greitiy;
  61.    if(x>width)
  62.    {
  63.     greitix = -greitix;
  64.     greitiy = greitiy+ (int)random(-10, 10);
  65.    }
  66.    if(x<0)
  67.    {
  68.     greitix = -greitix;
  69.     greitiy = greitiy+ (int)random(-10, 10);
  70.    }
  71.    if(y>height)
  72.    {
  73.     greitiy = -greitiy;
  74.     greitix = greitix+ (int)random(-10, 10);
  75.    }
  76.    if(y<0)
  77.    {
  78.     greitiy = -greitiy;
  79.     greitix = greitix+ (int)random(-10, 10);
  80.    }
  81.  }
  82. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top