Advertisement
Nojus_Globys

christmas_football

Dec 20th, 2022
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.74 KB | Software | 0 0
  1.  
  2. int
  3.     // ball
  4.     x,
  5.     y,
  6.     speed,
  7.     size,
  8.    
  9.     // gates
  10.     w, // half width
  11.     h, // half height
  12.     weight,
  13.     angle;
  14.  
  15. void setup() {
  16.     size(1280, 740);
  17.     rectMode (CENTER);
  18.    
  19.     x = width / 2;
  20.     y = height;
  21.     speed = - (height / 50);
  22.     size = height / 20;
  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 present () {
  31.     y += speed;
  32.     if (
  33.         (y < 0) || (
  34.             x > mouseX - w &&
  35.             x < mouseX + w &&
  36.             y < mouseY
  37.         )
  38.     ) {
  39.         y = height;
  40.         x = int (random(width));
  41.     }
  42.    
  43.     //y = height / 2;
  44.    
  45.     // body
  46.     noStroke();
  47.     fill (255, 0, 0);
  48.     square (x, y, size * 2);
  49.    
  50.     // ribbon
  51.     // body
  52.     stroke (255, 215, 0);
  53.     strokeWeight (weight/2);
  54.     line (x - size, y, x + size, y);
  55.     line (x, y - size, x, y + size);
  56.     // bow
  57.     noFill ();
  58.     circle (x - size / 3, y - size * 1.25, size / 2);
  59.     circle (x + size / 3, y - size * 1.25, size / 2);
  60. }
  61.  
  62. void ball () {
  63.     y += speed;
  64.     if (
  65.         (y < 0) || (
  66.             x > mouseX - w &&
  67.             x < mouseX + w &&
  68.             y < mouseY
  69.         )
  70.     ) {
  71.         y = height;
  72.         x = int (random(width));
  73.     }
  74.  
  75.     noStroke();
  76.     fill (255);
  77.     circle (x, y, height / 10);
  78. }
  79.  
  80. void net () {
  81.     strokeWeight(5);
  82.     stroke (0);
  83.     for (int y = -h; y < h; y += h / 4) { // horizontal
  84.         // main
  85.         line (mouseX - w + angle, mouseY + y - angle, mouseX + w + angle, mouseY + y - angle);
  86.         //sides
  87.         line (mouseX - w, mouseY + y, mouseX - w + angle, mouseY + y - angle);
  88.         line (mouseX + w, mouseY + y, mouseX + w + angle, mouseY + y - angle);
  89.     }
  90.     for (int x = -w; x < w; x += w / 5){ // vertical
  91.         line (mouseX + x + angle, mouseY - h - angle, mouseX + x + angle, mouseY + h - angle);
  92.         line (mouseX + x, mouseY - h, mouseX + x + angle, mouseY - h - angle);
  93.     }
  94. }
  95.  
  96. void gates () {
  97.     strokeWeight(weight);
  98.     stroke (0);
  99.     noFill ();
  100.    
  101.     rect ( // back
  102.         mouseX + angle, mouseY - angle,
  103.         w * 2, h * 2,
  104.         width / 500 // suapvalinimas
  105.     );
  106.  
  107.     // front
  108.     line ( // upper
  109.         mouseX - w, mouseY - h,
  110.         mouseX + w, mouseY - h
  111.     );
  112.     line ( // left
  113.         mouseX - w, mouseY - h,
  114.         mouseX - w, mouseY + h
  115.     );
  116.     line ( // right
  117.         mouseX + w, mouseY - h,
  118.         mouseX + w, mouseY + h
  119.     );
  120.  
  121.     // angle
  122.     line ( // left top
  123.         mouseX - w,
  124.         mouseY - h,
  125.         mouseX - w + angle,
  126.         mouseY - h - angle
  127.     );
  128.     line ( // left bottom
  129.         mouseX - w,
  130.         mouseY + h,
  131.         mouseX - w + angle,
  132.         mouseY + h - angle
  133.     );
  134.     line ( // right top
  135.         mouseX + w,
  136.         mouseY - h,
  137.         mouseX + w + angle,
  138.         mouseY - h - angle
  139.     );
  140.     line ( // right bottom
  141.         mouseX + w,
  142.         mouseY + h,
  143.         mouseX + w + angle,
  144.         mouseY + h - angle
  145.     );
  146. }
  147.  
  148. void snow () {
  149.     strokeWeight (weight / 2);
  150.     stroke (255);
  151.     // virลกus - galas
  152.     line (mouseX + angle - w, mouseY - angle - h, mouseX + angle + w, mouseY - angle - h);
  153.     // front
  154.     line ( // upper
  155.         mouseX - w, mouseY - h,
  156.         mouseX + w, mouseY - h
  157.     );
  158.         // angle
  159.     line ( // right top
  160.         mouseX + w,
  161.         mouseY - h,
  162.         mouseX + w + angle,
  163.         mouseY - h - angle
  164.     );
  165.     line ( // left top
  166.         mouseX - w,
  167.         mouseY - h,
  168.         mouseX - w + angle,
  169.         mouseY - h - angle
  170.     );
  171. }
  172.  
  173. void draw() {
  174.     background (125, 255, 125);
  175.     gates ();
  176.     //net ();
  177.     //ball();
  178.     present ();
  179.     snow ();
  180. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement