Advertisement
Nojus_Globys

football

Dec 14th, 2022
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.46 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.         )
  35.     ) {
  36.         y = height;
  37.         x = int (random(width));
  38.     }
  39.  
  40.     noStroke();
  41.     fill (255);
  42.     circle (x, y, height / 10);
  43. }
  44.  
  45. void net () {
  46.     strokeWeight(5);
  47.     stroke (0);
  48.     for (int y = -h; y < h; y += h / 4) { // horizontal
  49.         // main
  50.         line (mouseX - w + angle, mouseY + y - angle, mouseX + w + angle, mouseY + y - angle);
  51.         //sides
  52.         line (mouseX - w, mouseY + y, mouseX - w + angle, mouseY + y - angle);
  53.         line (mouseX + w, mouseY + y, mouseX + w + angle, mouseY + y - angle);
  54.     }
  55.     for (int x = -w; x < w; x += w / 5){ // vertical
  56.         line (mouseX + x + angle, mouseY - h - angle, mouseX + x + angle, mouseY + h - angle);
  57.         line (mouseX + x, mouseY - h, mouseX + x + angle, mouseY - h - angle);
  58.     }
  59. }
  60.  
  61. void gates () {
  62.     strokeWeight(weight);
  63.     stroke (0);
  64.     noFill ();
  65.    
  66.     rect ( // back
  67.         mouseX + angle, mouseY - angle,
  68.         w * 2, h * 2,
  69.         width / 500 // suapvalinimas
  70.     );
  71.  
  72.     // front
  73.     line ( // upper
  74.         mouseX - w, mouseY - h,
  75.         mouseX + w, mouseY - h
  76.     );
  77.     line ( // left
  78.         mouseX - w, mouseY - h,
  79.         mouseX - w, mouseY + h
  80.     );
  81.     line ( // right
  82.         mouseX + w, mouseY - h,
  83.         mouseX + w, mouseY + h
  84.     );
  85.  
  86.     // angle
  87.     line ( // left top
  88.         mouseX - w,
  89.         mouseY - h,
  90.         mouseX - w + angle,
  91.         mouseY - h - angle
  92.     );
  93.     line ( // left bottom
  94.         mouseX - w,
  95.         mouseY + h,
  96.         mouseX - w + angle,
  97.         mouseY + h - angle
  98.     );
  99.     line ( // right top
  100.         mouseX + w,
  101.         mouseY - h,
  102.         mouseX + w + angle,
  103.         mouseY - h - angle
  104.     );
  105.     line ( // right bottom
  106.         mouseX + w,
  107.         mouseY + h,
  108.         mouseX + w + angle,
  109.         mouseY + h - angle
  110.     );    
  111. }
  112.  
  113. void draw() {
  114.     background (125, 255, 125);
  115.     gates ();
  116.     //net ();
  117.     ball();
  118. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement