Advertisement
Guest User

Untitled

a guest
Sep 19th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.02 KB | None | 0 0
  1.         cloudPosition = {}
  2.        
  3.         cloudPosition[1] = 20
  4.         cloudPosition[2] = 250
  5.         cloudPosition[3] = 40
  6.         cloudPosition[4] = 500
  7.         cloudPosition[5] = 200
  8.         cloudPosition[6] = 800
  9.         cloudPosition[7] = 500
  10.        
  11.     cloudPositionY = {}
  12.    
  13. function random(A, B)
  14.  
  15.     math.randomseed(os.time())
  16.  
  17. math.random(); math.random(); math.random()
  18.  
  19. return math.random(A, B)
  20.  
  21. end
  22.  
  23.     cloudPositionY[1] = random(40, 40 + 80)
  24.     cloudPositionY[2] = random(150 - 80, 150 + 80)
  25.     cloudPositionY[3] = random(250 - 80, 250 + 80)
  26.     cloudPositionY[4] = random(20, 20 + 80)
  27.     cloudPositionY[5] = random(180 - 80, 180 + 80)
  28.     cloudPositionY[6] = random(40, 40 + 80)
  29.     cloudPositionY[7] = random(10, 10 + 80)
  30.    
  31.         randTable = {}
  32.        
  33.         randTable[1] = random(40, 40 + 80)
  34.         randTable[2] = random(150 - 80, 150 + 80)
  35.         randTable[3] = random(250 - 80, 250 + 80)
  36.         randTable[4] = random(20, 20 + 80)
  37.         randTable[5] = random(180 - 80, 180 + 80)
  38.         randTable[6] = random(40, 40 + 80)
  39.         randTable[7] = random(10, 10 + 80)
  40.    
  41. function love.update(dt)
  42.  
  43.     if cloud_m_movementC1[1] > max_cloud_movement then
  44.         cloud_m_movementC1[1] = 500
  45.         cloud_m_movementC2[2] = 497
  46.         cloud_m_movementC3[3] = 495
  47.  
  48.     end
  49.    
  50. for l = 1, 3, 1 do
  51.    
  52.     if cloud_m_movementC1[1] < min_cloud_movement[1] or cloud_m_movementC2[2] < min_cloud_movement[2] or cloud_m_movementC3[3] < min_cloud_movement[3] then
  53.    
  54.         cloud_m_movementC1[1] = 10
  55.         cloud_m_movementC2[2] = 7
  56.         cloud_m_movementC3[3] = 5
  57.  
  58.     end
  59. end
  60.  
  61. if love.keyboard.isDown("right") then
  62.  
  63.     sun_movement = sun_movement + 0.5 * dt
  64.    
  65.         cloud_m_movementC1[1] = cloud_m_movementC1[1] + 50 * dt
  66.         cloud_m_movementC1[1] = cloud_m_movementC1[1] + 50 * dt
  67.         cloud_m_movementC1[1] = cloud_m_movementC1[1] + 50 * dt
  68.         cloud_m_movementC2[2] = cloud_m_movementC2[2] + 50 * dt
  69.         cloud_m_movementC2[2] = cloud_m_movementC2[2] + 50 * dt
  70.         cloud_m_movementC3[3] = cloud_m_movementC3[3] + 50 * dt
  71.         cloud_m_movementC3[3] = cloud_m_movementC3[3] + 50 * dt
  72.        
  73. elseif love.keyboard.isDown("left") then
  74.  
  75.     sun_movement = sun_movement - 0.5 * dt
  76.    
  77.         cloud_m_movementC1[1] = cloud_m_movementC1[1] - 50 * dt
  78.         cloud_m_movementC1[1] = cloud_m_movementC1[1] - 50 * dt
  79.         cloud_m_movementC1[1] = cloud_m_movementC1[1] - 50 * dt
  80.         cloud_m_movementC2[2] = cloud_m_movementC2[2] - 50 * dt
  81.         cloud_m_movementC2[2] = cloud_m_movementC2[2] - 50 * dt
  82.         cloud_m_movementC3[3] = cloud_m_movementC3[3] - 50 * dt
  83.         cloud_m_movementC3[3] = cloud_m_movementC3[3] - 50 * dt
  84.  
  85. elseif love.keyboard.isDown(" ") then      
  86.        
  87.         sun_movement = 0.05
  88.        
  89.     cloud_m_movementC1[1] = 10
  90.     cloud_m_movementC2[2] = 7
  91.     cloud_m_movementC3[3] = 5
  92.        
  93. end
  94.  
  95.     for cloudIndex = 1, 9, 1 do
  96.    
  97.         if cloudPositionY[cloudIndex] == cloudPositionY[cloudIndex + 1] then
  98.        
  99.             cloudPositionY[cloudIndex] = randTable[cloudIndex]
  100.        
  101.         end
  102.        
  103.         if cloudIndex > 7 then
  104.        
  105.             cloudIndex = 1
  106.        
  107.         end
  108.     end
  109.  
  110. cloudPosition[1] = cloudPosition[1] + cloud_m_movementC1[1] * dt
  111.  
  112.     if cloudPosition[1] > 840 then
  113.    
  114.         cloudPosition[1] = -260
  115.        
  116.         cloudPositionY[1] = random(40, 40 + 80)
  117.             clouds_passed = clouds_passed + 1
  118.    
  119.     end
  120.    
  121.     cloudPosition[2] = cloudPosition[2] + cloud_m_movementC1[1] * dt
  122.  
  123.     if cloudPosition[2] > 840 then
  124.    
  125.         cloudPosition[2] = -260
  126.        
  127.         cloudPositionY[2] = random(150 - 80, 150 + 80)
  128.             clouds_passed = clouds_passed + 1
  129.    
  130.     end
  131.    
  132.     cloudPosition[3] = cloudPosition[3] + cloud_m_movementC1[1] * dt
  133.  
  134.     if cloudPosition[3] > 840 then
  135.    
  136.         cloudPosition[3] = -260
  137.        
  138.         cloudPositionY[3] = random(250 - 80, 250 + 80)
  139.             clouds_passed = clouds_passed + 1
  140.    
  141.     end
  142.    
  143.     cloudPosition[4] = cloudPosition[4] + cloud_m_movementC2[2] * dt
  144.  
  145.     if cloudPosition[4] > 840 then
  146.    
  147.         cloudPosition[4] = -260
  148.        
  149.         cloudPositionY[4] = random(20, 20 + 80)
  150.             clouds_passed = clouds_passed + 1
  151.    
  152.     end
  153.    
  154.     cloudPosition[5] = cloudPosition[5] + cloud_m_movementC2[2] * dt
  155.  
  156.     if cloudPosition[5] > 840 then
  157.    
  158.         cloudPosition[5] = -260
  159.        
  160.         cloudPositionY[5] = random(180 - 80, 180 + 80)
  161.             clouds_passed = clouds_passed + 1
  162.    
  163.     end
  164.    
  165.     cloudPosition[6] = cloudPosition[6] + cloud_m_movementC3[3] * dt
  166.  
  167.     if cloudPosition[6] > 840 then
  168.    
  169.         cloudPosition[6] = -260
  170.        
  171.         cloudPositionY[6] = random(40, 40 + 80)
  172.             clouds_passed = clouds_passed + 1
  173.    
  174.     end
  175.    
  176.     cloudPosition[7] = cloudPosition[7] + cloud_m_movementC3[3] * dt
  177.  
  178.     if cloudPosition[7] > 840 then
  179.    
  180.         cloudPosition[7] = -260
  181.        
  182.         cloudPositionY[7] = random(10, 10 + 80)
  183.        
  184.             clouds_passed = clouds_passed + 1
  185.    
  186.     end
  187.  
  188. end
  189.  
  190. function drawClouds()
  191.  
  192. love.graphics.draw( cloud_1, cloudPosition[1], cloudPositionY[1], 0, 1, 1, 0, 0 )
  193. love.graphics.draw( cloud_2, cloudPosition[2], cloudPositionY[2], 0, 0.5, 0.5, 0, 0 )
  194. love.graphics.draw( cloud_3, cloudPosition[3],  cloudPositionY[3], 0, 1, 1, 0, 0 )
  195. love.graphics.draw( cloud_3, cloudPosition[4],  cloudPositionY[4], 0, 1, 1, 0, 0 )
  196. love.graphics.draw( cloud_3, cloudPosition[5], cloudPositionY[5], 0, 1, 1, 0, 0 )
  197. love.graphics.draw( cloud_2, cloudPosition[6], cloudPositionY[6], 0, 0.5, 0.5, 0, 0 )
  198. love.graphics.draw( cloud_1, cloudPosition[7], cloudPositionY[7], 0, 1, 1, 0, 0 )
  199.  
  200. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement