Advertisement
Nojus_Globys

football

Jan 25th, 2023
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.86 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. void setup() {
  14.     size(1280, 740);
  15.     rectMode (CENTER);
  16.    
  17.     x = width / 2;
  18.     y = height;
  19.     speed = - (height / 50);
  20.    
  21.     w = width / 6; // half width
  22.     h = width / 10; // half height
  23.     weight = width / 60;
  24.     angle = w / 4;
  25. }
  26.  
  27. void ball () {
  28.     y += speed;
  29.     if (
  30.         (y < 0) || (
  31.             x > mouseX - w &&
  32.             x < mouseX + w &&
  33.             y < mouseY &&
  34.             y > mouseY - h
  35.         )
  36.     ) {
  37.         y = height;
  38.         x = int (random(width));
  39.     }
  40.  
  41.     noStroke();
  42.     fill (255);
  43.     circle (x, y, height / 10);
  44. }
  45.  
  46. void gates () {
  47.     strokeWeight(weight);
  48.     stroke (0);
  49.     noFill ();
  50.    
  51.     rect ( // back
  52.         mouseX + angle, mouseY - angle,
  53.         w * 2, h * 2,
  54.         width / 500 // suapvalinimas
  55.     );
  56.  
  57.     // front
  58.     line ( // upper
  59.         mouseX - w, mouseY - h,
  60.         mouseX + w, mouseY - h
  61.     );
  62.     line ( // left
  63.         mouseX - w, mouseY - h,
  64.         mouseX - w, mouseY + h
  65.     );
  66.     line ( // right
  67.         mouseX + w, mouseY - h,
  68.         mouseX + w, mouseY + h
  69.     );
  70.  
  71.     // angle
  72.     line ( // left top
  73.         mouseX - w,
  74.         mouseY - h,
  75.         mouseX - w + angle,
  76.         mouseY - h - angle
  77.     );
  78.     line ( // left bottom
  79.         mouseX - w,
  80.         mouseY + h,
  81.         mouseX - w + angle,
  82.         mouseY + h - angle
  83.     );
  84.     line ( // right top
  85.         mouseX + w,
  86.         mouseY - h,
  87.         mouseX + w + angle,
  88.         mouseY - h - angle
  89.     );
  90.     line ( // right bottom
  91.         mouseX + w,
  92.         mouseY + h,
  93.         mouseX + w + angle,
  94.         mouseY + h - angle
  95.     );    
  96. }
  97.  
  98. void draw () {
  99.     background (125, 255, 125);
  100.     gates ();
  101.     //net ();
  102.     ball();
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement