paramus

Birb

Feb 14th, 2025 (edited)
443
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.44 KB | Gaming | 0 0
  1. local vel, x, y = 1, 13, 10
  2. local pX, pYo, pYf = 26, 1, 5
  3. local Score = 0
  4. local Speed = 1
  5.  
  6. function Paint()
  7.     term.clear()
  8.     paintutils.drawFilledBox(1,1,26,20,colors.cyan)
  9.    
  10.     -- Clouds
  11.     paintutils.drawFilledBox(1,1,3,1,colors.white)
  12.     paintutils.drawFilledBox(5,2,10,2,colors.white)
  13.     paintutils.drawFilledBox(6,2,8,3,colors.white)
  14.     paintutils.drawFilledBox(17,1,18,1,colors.white)
  15.     paintutils.drawFilledBox(16,4,21,5,colors.white)
  16.    
  17.     -- Sun
  18.     paintutils.drawFilledBox(23,1,26,2,colors.yellow)
  19.    
  20.     -- Buildings/Mountains (Not sure what they are)
  21.     paintutils.drawFilledBox(3,14,5,20,colors.lightGray)
  22.     paintutils.drawFilledBox(5,12,7,20,colors.lightBlue)
  23.     paintutils.drawFilledBox(9,13,11,20,colors.pink)
  24.     paintutils.drawFilledBox(11,16,13,20,colors.lime)
  25.     paintutils.drawFilledBox(14,14,16,20,colors.red)
  26.    
  27.     -- Birb
  28.     paintutils.drawPixel(x,y,colors.orange)
  29.    
  30.     -- Pipes
  31.     PipeGen()
  32.    
  33.     --Ground
  34.     paintutils.drawFilledBox(1,18,26,20,colors.brown)
  35.    
  36.     -- Pond/Puddle
  37.     paintutils.drawLine(18,18,26,18,colors.blue)
  38.     paintutils.drawLine(19,19,26,19,colors.blue)
  39.    
  40.     if (Speed == 0.01) then
  41.         paintutils.drawPixel(9,10,colors.cyan)
  42.         term.setCursorPos(9,10)
  43.         term.setTextColor(colors.red)
  44.         term.write("GAME OVER")
  45.     end
  46.    
  47.     --Score
  48.     paintutils.drawPixel(13,1,colors.cyan)
  49.     term.setCursorPos(13,1)
  50.     term.setTextColor(colors.white)
  51.     term.write(Score)
  52. end
  53.  
  54. function Physics()
  55.    
  56.     if (x==pX) then
  57.         if (y<pYo or y>=pYf) then -- Game over
  58.             Speed = 0.01
  59.         else
  60.             Score =Score+1
  61.             Speed=Speed+0.1
  62.         end
  63.     elseif (y>=17) then -- Game over
  64.         Speed = 0.01
  65.     end
  66.    
  67.     y=y+vel
  68. end
  69.  
  70. function PipeGen()    
  71.     paintutils.drawLine(pX,1,pX,pYo,colors.green) -- Top pipe
  72.     paintutils.drawLine(pX,pYf,pX,20,colors.green) -- Bottom pipe
  73.    
  74.     pX=pX-1
  75.     if (pX<=0) then
  76.         pX = 26
  77.        
  78.         local r = math.random(2,16)
  79.         pYo = r-2
  80.         pYf = r+2
  81.     end
  82. end
  83.  
  84. -- Main --
  85. while(true) do
  86.     parallel.waitForAny(function()
  87.         if (Speed>0.01) then
  88.             Physics()
  89.             Paint()
  90.         end
  91.         sleep(0.5/Speed)
  92.     end,
  93.     function()
  94.         os.pullEvent("key")
  95.         if (Speed>0.01) then
  96.             y=y-2
  97.         end
  98.     end,
  99.     function()
  100.         os.pullEvent("mouse_click")
  101.         if (Speed>0.01) then
  102.             y=y-2
  103.         end
  104.     end)
  105. end
Advertisement
Add Comment
Please, Sign In to add comment