Advertisement
Panlew

nyan

Nov 27th, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. shell.run ("clear")
  2. print ("Seconds?")
  3. counter = read()*20
  4. shell.run ("clear")
  5.  
  6. term.clear()
  7. term.setCursorPos(1,1)
  8.  
  9. local star = {}
  10. star.__index = star
  11.  
  12. local minX = 1
  13. local maxX = 10
  14. local monWidth, monHeight = term.getSize()
  15.  
  16. function star.create()
  17.     local acnt = {}
  18.     setmetatable(acnt,star)
  19.    
  20.     mx = math.floor(monWidth+2)
  21.     my = math.floor(math.random(1,monHeight))
  22.    
  23.     acnt.x = mx
  24.     acnt.y = my
  25.     acnt.speed = math.floor(math.random(1,4))
  26.     acnt.pos =math.floor(math.random(minX,maxX))
  27.     return acnt
  28. end
  29.  
  30. function rawWriteLoc(x,y,sText)
  31.     term.setCursorPos(x,y)
  32.     term.write(sText)
  33. end
  34.  
  35. function star:clear()
  36. if self.pos == 1 then
  37.     rawWriteLoc(self.x,self.y," ")
  38.     elseif (self.pos == 2) or (self.pos == 3) or (self.pos == 4) or (self.pos == 8) or (self.pos == 9) or (self.pos == 10) then
  39.        
  40.     rawWriteLoc(self.x-1,self.y-1,"   ")
  41.     rawWriteLoc(self.x-1,self.y,  "   ")
  42.     rawWriteLoc(self.x-1,self.y+1,"   ")
  43.     elseif (self.pos == 5) or (self.pos == 6) or (self.pos == 7) then
  44.        
  45.     rawWriteLoc(self.x-2,self.y-2,"     ")
  46.     rawWriteLoc(self.x-2,self.y-1,"     ")
  47.     rawWriteLoc(self.x-2,self.y,  "     ")
  48.     rawWriteLoc(self.x-2,self.y+1,"     ")
  49.     rawWriteLoc(self.x-2,self.y+2,"     ")
  50.     end
  51. end
  52.  
  53. function star:draw()
  54. if self.pos == 1 then
  55.     rawWriteLoc(self.x,self.y,"+")
  56.     elseif self.pos == 2 then
  57.        
  58.     rawWriteLoc(self.x-1,self.y-1," | ")
  59.     rawWriteLoc(self.x-1,self.y,  "-+-")
  60.     rawWriteLoc(self.x-1,self.y+1," | ")
  61.     elseif self.pos == 3 then
  62.        
  63.     rawWriteLoc(self.x-1,self.y-1," | ")
  64.     rawWriteLoc(self.x-1,self.y,  "- -")
  65.     rawWriteLoc(self.x-1,self.y+1," | ")
  66.    
  67.     elseif self.pos == 4 then
  68.            
  69.     rawWriteLoc(self.x-1,self.y-1,"/-\\")
  70.     rawWriteLoc(self.x-1,self.y,  "| |")
  71.     rawWriteLoc(self.x-1,self.y+1,"\\-/")
  72.    
  73.     elseif self.pos == 5 then
  74.            
  75.     rawWriteLoc(self.x-2,self.y-2,"  |  ")
  76.     rawWriteLoc(self.x-2,self.y-1," / \\ ")
  77.     rawWriteLoc(self.x-2,self.y,  "-   -")
  78.     rawWriteLoc(self.x-2,self.y+1," \\ / ")
  79.     rawWriteLoc(self.x-2,self.y+2,"  |  ")
  80.    
  81.     elseif self.pos == 6 then
  82.            
  83.     rawWriteLoc(self.x-2,self.y-2," /-\\ ")
  84.     rawWriteLoc(self.x-2,self.y-1,"/   \\")
  85.     rawWriteLoc(self.x-2,self.y,  "|   |")
  86.     rawWriteLoc(self.x-2,self.y+1,"\\   /")
  87.     rawWriteLoc(self.x-2,self.y+2," \\-/ ")
  88.    
  89.     elseif self.pos == 7 then
  90.            
  91.     rawWriteLoc(self.x-2,self.y-2,"  |  ")
  92.     rawWriteLoc(self.x-2,self.y-1," / \\ ")
  93.     rawWriteLoc(self.x-2,self.y,  "-   -")
  94.     rawWriteLoc(self.x-2,self.y+1," \\ / ")
  95.     rawWriteLoc(self.x-2,self.y+2,"  |  ")
  96.    
  97.     elseif self.pos == 8 then
  98.            
  99.     rawWriteLoc(self.x-1,self.y-1,"/-\\")
  100.     rawWriteLoc(self.x-1,self.y,  "| |")
  101.     rawWriteLoc(self.x-1,self.y+1,"\\-/")
  102.    
  103.     elseif self.pos == 9 then
  104.        
  105.     rawWriteLoc(self.x-1,self.y-1," | ")
  106.     rawWriteLoc(self.x-1,self.y,  "- -")
  107.     rawWriteLoc(self.x-1,self.y+1," | ")
  108.    
  109.     elseif self.pos == 10 then
  110.        
  111.     rawWriteLoc(self.x-1,self.y-1," | ")
  112.     rawWriteLoc(self.x-1,self.y,  "-+-")
  113.     rawWriteLoc(self.x-1,self.y+1," | ")
  114.     end
  115. end
  116.  
  117. function star:move()
  118. self.x = self.x - self.speed
  119. return self.x > -4
  120. end
  121.  
  122. function Addstar()
  123. local new = star.create()
  124. local x = #star+1
  125. star[x] = new
  126. return new,x
  127. end
  128.  
  129. function RenderStar()
  130. local i,w = 1
  131. for i,w in ipairs(star) do
  132.     w:draw()
  133.     end
  134. end
  135.  
  136. function MoveStar()
  137. local i,w = 1
  138. for i,w in ipairs(star) do
  139.     w:clear()
  140.     if (math.random(1,6) < 4) then
  141.         w.pos = w.pos +1
  142.         if w.pos > maxX then w.pos = minX end
  143.         end
  144.     if not w:move() then
  145.        star[i] = star[#star]
  146.        star[#star] = nil
  147.        end
  148.     end
  149. end
  150.  
  151. local catnr = 1
  152. local catmax = 6
  153. local catmin = 1
  154. local catx = 0
  155. local caty = math.floor((monHeight-4)/2)
  156.  
  157.  
  158. function DrawCat()
  159. if catnr == 1 then                  
  160.    
  161.     rawWriteLoc(catx,caty,  "--.__.--.__.--.__.--,------,  ")
  162.     rawWriteLoc(catx,caty+1,"--.__.--.__.--.__.--|   /\\_/\\ ")
  163.     rawWriteLoc(catx,caty+2,"--.__.--.__.--.__.-~|__( ^ .^)")
  164.     rawWriteLoc(catx,caty+3,"--.__.--.__.--.__.--\"\"  \"\" ")
  165.    
  166.     elseif catnr == 2 then
  167.        
  168.     rawWriteLoc(catx,caty,  "-.__.--.__.--.__.--.,------,  ")
  169.     rawWriteLoc(catx,caty+1,"-.__.--.__.--.__.--.|   /\\_/\\ ")
  170.     rawWriteLoc(catx,caty+2,"-.__.--.__.--.__.--~|__( ^ .^)")
  171.     rawWriteLoc(catx,caty+3,"-.__.--.__.--.__.--. \"\"  \"\" ")
  172.  
  173.     elseif catnr == 3 then
  174.        
  175.     rawWriteLoc(catx,caty,  ".__.--.__.--.__.--._,------,  ")
  176.     rawWriteLoc(catx,caty+1,".__.--.__.--.__.--._|   /\\_/\\ ")
  177.     rawWriteLoc(catx,caty+2,".__.--.__.--.__.--.~|__( ^ .^)")
  178.     rawWriteLoc(catx,caty+3,".__.--.__.--.__.--._ \"\"  \"\" ")
  179.  
  180.     elseif catnr == 4 then
  181.        
  182.     rawWriteLoc(catx,caty,  "__.--.__.--.__.--.__,------,  ")
  183.     rawWriteLoc(catx,caty+1,"__.--.__.--.__.--.__|   /\\_/\\ ")
  184.     rawWriteLoc(catx,caty+2,"__.--.__.--.__.--._~|__( ^ .^)")
  185.     rawWriteLoc(catx,caty+3,"__.--.__.--.__.--.__ \"\"  \"\" ")
  186.    
  187.     elseif catnr == 5 then
  188.        
  189.     rawWriteLoc(catx,caty,  "_.--.__.--.__.--.__.,------,  ")
  190.     rawWriteLoc(catx,caty+1,"_.--.__.--.__.--.__.|   /\\_/\\ ")
  191.     rawWriteLoc(catx,caty+2,"_.--.__.--.__.--.__~|__( ^ .^)")
  192.     rawWriteLoc(catx,caty+3,"_.--.__.--.__.--.__.\"\"  \"\" ") 
  193.    
  194.     elseif catnr == 6 then
  195.        
  196.     rawWriteLoc(catx,caty,  ".--.__.--.__.--.__.-,------,  ")
  197.     rawWriteLoc(catx,caty+1,".--.__.--.__.--.__.-|   /\\_/\\ ")
  198.     rawWriteLoc(catx,caty+2,".--.__.--.__.--.__.~|__( ^ .^)")
  199.     rawWriteLoc(catx,caty+3,".--.__.--.__.--.__.-\"\"  \"\" ")
  200.  
  201.     end
  202.  
  203.  
  204. catnr = catnr + 1
  205. if catnr > catmax then catnr = catmin end
  206. end
  207.  
  208. for i = 0, counter do
  209.     if (math.random(1,6) < 4) then
  210.         Addstar()
  211.         end
  212.     MoveStar()
  213.     RenderStar()
  214.     DrawCat()
  215.     sleep(0.05)
  216.     end
  217. shell.run ("clear")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement