新增灯笼背景
This commit is contained in:
49
parts/backgrounds/lanterns.lua
Normal file
49
parts/backgrounds/lanterns.lua
Normal file
@@ -0,0 +1,49 @@
|
||||
--Cool liquid background
|
||||
local gc=love.graphics
|
||||
local int,rnd=math.floor,math.random
|
||||
local ins,rem=table.insert,table.remove
|
||||
local back={}
|
||||
local lanterns
|
||||
local t
|
||||
|
||||
function back.init()
|
||||
lanterns={}
|
||||
t=0
|
||||
end
|
||||
function back.update(dt)
|
||||
t=t-dt
|
||||
local H=SCR.h
|
||||
if t<=0 then
|
||||
local size=SCR.rad*(2+rnd()*3)/5/2000
|
||||
local L={
|
||||
x=SCR.w*rnd(),
|
||||
y=H*1.05,
|
||||
vy=size*2,
|
||||
size=size,
|
||||
phase=rnd(),
|
||||
vp=.02+.02*rnd(),
|
||||
}
|
||||
ins(lanterns,L)
|
||||
t=rnd(.626,1.626)
|
||||
end
|
||||
for i=#lanterns,1,-1 do
|
||||
local L=lanterns[i]
|
||||
L.y=L.y-L.vy*dt*60
|
||||
L.phase=(L.phase+L.vp*dt*60)%1
|
||||
if L.y<.05*H then
|
||||
rem(lanterns,i)
|
||||
end
|
||||
end
|
||||
end
|
||||
function back.draw()
|
||||
gc.clear(.1,.1,.1)
|
||||
gc.push("transform")
|
||||
gc.origin()
|
||||
gc.setColor(1,1,1)
|
||||
for i=1,#lanterns do
|
||||
local L=lanterns[i]
|
||||
mDraw(IMG.lanterns[int(L.phase*6)+1],L.x,L.y,nil,L.size)
|
||||
end
|
||||
gc.pop()
|
||||
end
|
||||
return back
|
||||
Reference in New Issue
Block a user