vencinachev

Flappy01

Aug 4th, 2021
681
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. float obspos, obsw = 20, h, d, obsspeed = 5;
  3. boolean gameover = false;
  4. PImage flappy;
  5.  
  6. void setup(){
  7.   size(500, 800);
  8.   obspos = width;
  9.   h = random(50, 600);
  10.   d = random(50, 150);
  11.   flappy = loadImage("flappy.png");
  12. }
  13.  
  14. void draw(){
  15.   if (!gameover){
  16.     background(0, 0, 255);
  17.     obstacle();
  18.     image(flappy, mouseX, mouseY, 50, 50);
  19.   } else {
  20.    
  21.   }
  22. }
  23.  
  24. void obstacle(){
  25.   fill(0, 255, 0);
  26.   rect(obspos, 0, obsw, h);
  27.   rect(obspos, h + d, obsw, height - (h + d));
  28.   obspos = obspos - obsspeed;
  29.   if (obspos < 0){
  30.     obspos = width;
  31.     h = random(50, 600);
  32.     d = random(50, 150);
  33.   }
  34. }
RAW Paste Data