Advertisement
Nojus_Globys

jan25

Jan 25th, 2023 (edited)
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.98 KB | Software | 0 0
  1. int
  2.     // ball
  3.     x,
  4.     y,
  5.     speed,
  6.    
  7.     // gates
  8.     w, // half width
  9.     h, // half height
  10.     weight,
  11.     angle,
  12.    
  13.     points = 0; // taškai
  14.  
  15. void setup() {
  16.     size(1280, 740);
  17.     rectMode (CENTER);
  18.     textSize (height / 10);
  19.    
  20.     x = width / 2;
  21.     y = height;
  22.     speed = - (height / 50);
  23.    
  24.     w = width / 6; // half width
  25.     h = width / 10; // half height
  26.     weight = width / 60;
  27.     angle = w / 4;
  28. }
  29.  
  30. void ball () {
  31.     y += speed;
  32.     if (y < 0) { // jei kamuolys pasiekė viršų
  33.         y = height; // grįžtu į apačią
  34.         x = int (random(width)); // bet kokia x pozicija
  35.     }
  36.    
  37.     if (points % 5 == 0 && points != 0)
  38.      --speed;
  39.  
  40.     noStroke();
  41.     fill (255);
  42.     circle (x, y, height / 10);
  43. }
  44.  
  45. void gates () {
  46.     strokeWeight(weight);
  47.     stroke (0);
  48.     noFill ();
  49.    
  50.     // back
  51.     rect (mouseX + angle, mouseY - angle, w * 2, h * 2, width / 500); // +suapvalinimas
  52.  
  53.     // front
  54.     line (mouseX - w, mouseY - h, mouseX + w, mouseY - h); // upper
  55.     line (mouseX - w, mouseY - h, mouseX - w, mouseY + h); // left
  56.     line (mouseX + w, mouseY - h, mouseX + w, mouseY + h); // right
  57.  
  58.     // angle
  59.     line (mouseX - w,mouseY - h, mouseX - w + angle, mouseY - h - angle); // left top
  60.     line (mouseX - w, mouseY + h, mouseX - w + angle, mouseY + h - angle); // left bottom
  61.     line (mouseX + w, mouseY - h, mouseX + w + angle, mouseY - h - angle); // right top
  62.     line (mouseX + w, mouseY + h, mouseX + w + angle, mouseY + h - angle); // right bottom
  63.    
  64.     if ( // kamuolys yra vartuose
  65.         x > mouseX - w &&
  66.         x < mouseX + w &&
  67.         y < mouseY &&
  68.         y > mouseY - h
  69.     ) {
  70.       y = height; // grįžtu į apačią
  71.       x = int (random(width)); // bet kokia x pozicija
  72.       ++points; // padidinti taškus
  73.     }
  74. }
  75.  
  76. void draw () {
  77.     background (125, 255, 125);
  78.     gates ();
  79.     ball();
  80.     fill (0, 0, 255);
  81.     text (points, width * 0.9, height / 8);
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement