SHOW:
|
|
- or go back to the newest paste.
| 1 | function love.load(arg) | |
| 2 | if arg and arg[#arg] == "-debug" then require("mobdebug").start() end
| |
| 3 | rotace = 0 | |
| 4 | points = {}
| |
| 5 | points_mirror = {}
| |
| 6 | ||
| 7 | -- for i = 1,20 do | |
| 8 | -- local x, y | |
| 9 | -- points[#points+1] = { x=(100 + 10*i), y = (100 + (math.cos(0.5*i))*20)}
| |
| 10 | -- end | |
| 11 | local plus = 400; | |
| 12 | local minus = 520; | |
| 13 | ||
| 14 | points[#points+1] = { x = plus + 100, y = minus-87}
| |
| 15 | points[#points+1] = { x = plus + 100, y = minus-130}
| |
| 16 | points[#points+1] = { x = plus + 100, y = minus-195}
| |
| 17 | points[#points+1] = { x = plus + 120, y = minus-273}
| |
| 18 | points[#points+1] = { x = plus + 130, y = minus-322}
| |
| 19 | points[#points+1] = { x = plus + 191, y = minus-356}
| |
| 20 | points[#points+1] = { x = plus + 243, y = minus-367}
| |
| 21 | points[#points+1] = { x = plus + 298, y = minus-353}
| |
| 22 | points[#points+1] = { x = plus + 341, y = minus-315}
| |
| 23 | points[#points+1] = { x = plus + 366, y = minus-271}
| |
| 24 | points[#points+1] = { x = plus + 379, y = minus-220}
| |
| 25 | points[#points+1] = { x = plus + 370, y = minus-166}
| |
| 26 | points[#points+1] = { x = plus + 354, y = minus-115}
| |
| 27 | points[#points+1] = { x = plus + 329, y = minus-73}
| |
| 28 | ||
| 29 | local plus_mirror = 570 | |
| 30 | local spodni_rozdil = - 25 | |
| 31 | ||
| 32 | points_mirror[#points_mirror+1] = { x = plus_mirror - 100, y = minus-87 + spodni_rozdil}
| |
| 33 | points_mirror[#points_mirror+1] = { x = plus_mirror - 100, y = minus-130 + spodni_rozdil}
| |
| 34 | points_mirror[#points_mirror+1] = { x = plus_mirror - 100, y = minus-195 + spodni_rozdil}
| |
| 35 | points_mirror[#points_mirror+1] = { x = plus_mirror - 120, y = minus-273}
| |
| 36 | points_mirror[#points_mirror+1] = { x = plus_mirror - 130, y = minus-322}
| |
| 37 | points_mirror[#points_mirror+1] = { x = plus_mirror - 191, y = minus-356}
| |
| 38 | points_mirror[#points_mirror+1] = { x = plus_mirror - 243, y = minus-367}
| |
| 39 | points_mirror[#points_mirror+1] = { x = plus_mirror - 298, y = minus-353}
| |
| 40 | points_mirror[#points_mirror+1] = { x = plus_mirror - 341, y = minus-315}
| |
| 41 | points_mirror[#points_mirror+1] = { x = plus_mirror - 366, y = minus-271}
| |
| 42 | points_mirror[#points_mirror+1] = { x = plus_mirror - 379, y = minus-220}
| |
| 43 | points_mirror[#points_mirror+1] = { x = plus_mirror - 370, y = minus-166}
| |
| 44 | points_mirror[#points_mirror+1] = { x = plus_mirror - 354, y = minus-115}
| |
| 45 | points_mirror[#points_mirror+1] = { x = plus_mirror - 329, y = minus-73}
| |
| 46 | ||
| 47 | ||
| 48 | rockets = {}
| |
| 49 | ||
| 50 | for i=1, #points do | |
| 51 | if i%3 == 0 then | |
| 52 | rockets[i] = love.graphics.newImage("1.png")
| |
| 53 | elseif i%2 == 0 then | |
| 54 | rockets[i] = love.graphics.newImage("2.png")
| |
| 55 | else | |
| 56 | rockets[i] = love.graphics.newImage("3.png")
| |
| 57 | end | |
| 58 | ||
| 59 | end | |
| 60 | prubeh = 1 | |
| 61 | pozadi = love.graphics.newImage("pozadi.png")
| |
| 62 | love.graphics.setMode( 1041, 781) | |
| 63 | end | |
| 64 | ||
| 65 | ||
| 66 | ||
| 67 | function love.draw() | |
| 68 | love.graphics.draw(pozadi,0, 0, 0, 1, sx) | |
| 69 | ||
| 70 | - | love.graphics.setBackgroundColor(100, 150, 150, 255) |
| 70 | + | |
| 71 | for i=1, #points do | |
| 72 | animuj_mezi(i,prubeh) | |
| 73 | end | |
| 74 | ||
| 75 | love.graphics.print("Rotace: " ..rotace, 20, 20)
| |
| 76 | ||
| 77 | prubeh = prubeh + 1 | |
| 78 | if prubeh == 20 then | |
| 79 | prubeh = 0 | |
| 80 | rotuj_pole() | |
| 81 | end | |
| 82 | love.timer.sleep(0.05) | |
| 83 | -- | |
| 84 | -- Test | |
| 85 | -- | |
| 86 | sirka = love.graphics.getWidth() | |
| 87 | vyska = love.graphics.getHeight() | |
| 88 | love.graphics.print("\Šířka: " .. sirka, 20, 40)
| |
| 89 | love.graphics.print("\Výška: " ..vyska, 20, 60)
| |
| 90 | -- | |
| 91 | -- | |
| 92 | end | |
| 93 | ||
| 94 | function animuj_mezi(i,prubeh) | |
| 95 | if i < #points then | |
| 96 | diff_x = points[i].x - points[i+1].x | |
| 97 | diff_y = points[i].y - points[i+1].y | |
| 98 | else | |
| 99 | diff_x = points[i].x - points[1].x | |
| 100 | diff_y = points[i].y - points[1].y | |
| 101 | end | |
| 102 | ||
| 103 | if i < #points then | |
| 104 | diff_x_mirror = points_mirror[i].x - points_mirror[i+1].x | |
| 105 | diff_y_mirror = points_mirror[i].y - points_mirror[i+1].y | |
| 106 | else | |
| 107 | diff_x_mirror = points_mirror[i].x - points_mirror[1].x | |
| 108 | diff_y_mirror = points_mirror[i].y - points_mirror[1].y | |
| 109 | end | |
| 110 | ||
| 111 | diff_x_mirror = (diff_x_mirror / 20)*prubeh | |
| 112 | diff_y_mirror = (diff_y_mirror / 20)*prubeh | |
| 113 | ||
| 114 | diff_x = (diff_x / 20)*prubeh | |
| 115 | diff_y = (diff_y / 20)*prubeh | |
| 116 | ||
| 117 | love.graphics.draw(rockets[i], points[i].x - (diff_x), points[i].y - (diff_y)) | |
| 118 | love.graphics.draw(rockets[i], points_mirror[i].x - (diff_x_mirror), points_mirror[i].y - (diff_y_mirror)) | |
| 119 | end | |
| 120 | ||
| 121 | ||
| 122 | function rotuj_pole() | |
| 123 | points_1st = points[1] | |
| 124 | points_1st_mirror = points_mirror[1] | |
| 125 | for i = 1, #points do | |
| 126 | if i < #points then | |
| 127 | points[i] = points[i+1] | |
| 128 | points_mirror[i] = points_mirror[i+1] | |
| 129 | else | |
| 130 | points[i] = points_1st | |
| 131 | points_mirror[i] = points_1st_mirror | |
| 132 | end | |
| 133 | ||
| 134 | end | |
| 135 | rotace = rotace +1 | |
| 136 | if rotace == #points then rotace = 0 end | |
| 137 | end |