Advertisement
paramus

Birb

Feb 14th, 2025 (edited)
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | Gaming | 0 0
  1. local vel, x, y = 1, 13, 10
  2. local pX, pYo, pYf = 26, 1, 5
  3.  
  4. function Paint()
  5.     term.clear()
  6.    
  7.     paintutils.drawFilledBox(1,1,26,20,colors.white)
  8.    
  9.      -- Birb
  10.     paintutils.drawPixel(x,y,colors.orange)
  11.    
  12.     PipeGen()
  13. end
  14.  
  15. function Physics()
  16.    
  17.     if (x==pX and (y<=pYo and y>=pYf)) then
  18.         error("You loose",0)
  19.     end
  20.    
  21.     y=y+vel
  22. end
  23.  
  24. function PipeGen()    
  25.     paintutils.drawLine(pX,1,pX,pYo,colors.green) -- Top pipe
  26.     paintutils.drawLine(pX,pYf,pX,20,colors.green) -- Bottom pipe
  27.    
  28.     pX=pX-1
  29.     if (pX<=0) then
  30.         pX = 26
  31.        
  32.         local r = math.random(2,18)
  33.         pYo = r-2
  34.         pYf = r+2
  35.     end
  36. end
  37.  
  38. -- Main --
  39. while(true) do
  40.     parallel.waitForAny(function()
  41.         Physics()
  42.         Paint()
  43.         sleep(0.5)
  44.     end,
  45.     function()
  46.         os.pullEvent("key")
  47.         y=y-2
  48.     end)
  49. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement