Advertisement
Nojus_Globys

jan11

Jan 18th, 2023
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.81 KB | Software | 0 0
  1. int
  2.   // ball
  3.   x, y,
  4.   speed,
  5.   size,
  6.  
  7.   // gates
  8.   w, // half width
  9.   h, // half height
  10.   angle,
  11.   weight;
  12.  
  13.   int points;
  14.  
  15. void setup () {
  16.   size (1280, 740);
  17.   rectMode (CENTER);
  18.  
  19.   // ball
  20.   x = width / 2;
  21.   y = height;
  22.   speed = -(height / 50);
  23.   size = height / 20;
  24.  
  25.   // gates
  26.   w = width / 6; // half width
  27.   h = width / 10; // half height
  28.   weight = width / 60;
  29.   angle = w / 4;
  30. }
  31.  
  32. void ball () {
  33.   y += speed;
  34.  
  35.   if (y < 0) {
  36.     y = height;
  37.     x = int (random (0, width));
  38.   }
  39.  
  40.   //y = height / 2;
  41.  
  42.   noStroke ();
  43.   fill (255);
  44.   //circle (x, y, height / 10); // kamuolys
  45.  
  46.   // dėžutė
  47.   noStroke ();
  48.   fill (255, 0, 0); // raudona
  49.   square (x, y, size * 2);
  50.  
  51.   // juosta
  52.   stroke (255, 215, 0); // geltona
  53.   strokeWeight (weight / 2);
  54.   line (x - size, y, x + size, y);
  55.   //line (x - height / 20, y, x + height / 20, y);
  56.   // size = height / 20;
  57.   line (x, y - size, x, y + size);
  58.  
  59.   // kaspinas
  60.   noFill ();
  61.   circle (x - size / 3, y - size * 1.25, size / 2);
  62.   circle (x + size / 3, y - size * 1.25, size / 2);
  63. }
  64.  
  65. void gate () {
  66.   strokeWeight (weight); // vamzdžių storis
  67.   stroke (0); // juoda spalva
  68.   noFill (); // nespalvinti vidaus
  69.  
  70.   // galinė siena
  71.   rect (mouseX + angle, mouseY - angle, w * 2, h * 2, width / 500);
  72.   //    x               y             plotis  aukštis apvalumas
  73.   //rect (mouseX, mouseY, w * 2, h * 2, width / 500);
  74.  
  75.   // line (mouseX, mouseY, mouseX, mouseY);
  76.   // priekio viršus
  77.   //stroke (255);
  78.   line (mouseX - w, mouseY - h, mouseX + w, mouseY - h);
  79.  
  80.   // priekio kairė
  81.   line (mouseX - w, mouseY - h, mouseX - w, mouseY + h);
  82.  
  83.   // priekio dešinė
  84.   line (mouseX + w, mouseY - h, mouseX + w, mouseY + h);
  85.  
  86. }
  87.  
  88. void draw () {
  89.   background (125, 255, 125);
  90.   ball ();
  91.   gate ();
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement