Advertisement
Nojus_Globys

feb01

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