背景系统增加“默认背景”功能,新增节日飘雪背景
This commit is contained in:
@@ -7,6 +7,7 @@ local BGlist={
|
||||
}
|
||||
local BG={
|
||||
cur="none",
|
||||
defaultBG="none",
|
||||
init=false,
|
||||
resize=false,
|
||||
update=NULL,
|
||||
@@ -23,7 +24,13 @@ function BG.send(...)
|
||||
BG.event(...)
|
||||
end
|
||||
end
|
||||
function BG.setDefaultBG(bg)
|
||||
defaultBG=bg
|
||||
end
|
||||
function BG.set(background)
|
||||
if not background then
|
||||
background=defaultBG
|
||||
end
|
||||
if background==BG.cur or not SETTING.bg then return end
|
||||
BG.discard()
|
||||
BG.cur=background
|
||||
|
||||
4
main.lua
4
main.lua
@@ -375,4 +375,6 @@ do
|
||||
S.version=VERSION_CODE
|
||||
FILE.save(STAT,"conf/data")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
BG.setDefaultBG(FESTIVAL=="Xmas"and"snow"or"space")
|
||||
54
parts/backgrounds/snow.lua
Normal file
54
parts/backgrounds/snow.lua
Normal file
@@ -0,0 +1,54 @@
|
||||
--Snow
|
||||
local gc=love.graphics
|
||||
local rnd=math.random
|
||||
local max,min=math.max,math.min
|
||||
local ins,rem=table.insert,table.remove
|
||||
local back={}
|
||||
|
||||
local t
|
||||
local snow
|
||||
function back.init()
|
||||
t=0
|
||||
snow={}
|
||||
BG.resize()
|
||||
end
|
||||
function back.update()
|
||||
t=t+1
|
||||
if t%(t%626>260 and 3 or 6)==0 then
|
||||
ins(snow,{
|
||||
x=SCR.w*rnd(),
|
||||
y=0,
|
||||
vy=1+rnd()*.6,
|
||||
vx=rnd()*2-.5,
|
||||
rx=2+rnd()*2,
|
||||
ry=2+rnd()*2,
|
||||
})
|
||||
end
|
||||
for i=#snow,1,-1 do
|
||||
local P=snow[i]
|
||||
P.y=P.y+P.vy
|
||||
if P.y>SCR.h then
|
||||
rem(snow,i)
|
||||
else
|
||||
P.x=P.x+P.vx
|
||||
P.vx=P.vx-.02+rnd()*.04
|
||||
P.rx=max(min(P.rx+rnd()-.5,4),2)
|
||||
P.ry=max(min(P.ry+rnd()-.5,5),3)
|
||||
end
|
||||
end
|
||||
end
|
||||
function back.draw()
|
||||
gc.clear(.2,.2,.2)
|
||||
gc.push("transform")
|
||||
gc.setColor(.7,.7,.7)
|
||||
gc.origin()
|
||||
for i=1,#snow do
|
||||
local P=snow[i]
|
||||
gc.ellipse("fill",P.x,P.y,P.rx,P.ry)
|
||||
end
|
||||
gc.pop()
|
||||
end
|
||||
function back.discard()
|
||||
snow=false
|
||||
end
|
||||
return back
|
||||
@@ -5,7 +5,7 @@ local sin=math.sin
|
||||
local scene={}
|
||||
|
||||
function scene.sceneInit()
|
||||
BG.set("space")
|
||||
BG.set()
|
||||
end
|
||||
|
||||
function scene.draw()
|
||||
|
||||
@@ -9,7 +9,7 @@ local scene={}
|
||||
local t1,t2,r
|
||||
|
||||
function scene.sceneInit()
|
||||
BG.set("space")
|
||||
BG.set()
|
||||
BGM.play("blank")
|
||||
t1,t2=0,0--Timer
|
||||
r={}--Random animation type
|
||||
|
||||
@@ -45,7 +45,10 @@ local tip
|
||||
|
||||
function scene.sceneInit()
|
||||
tip=text.getTip()
|
||||
BG.set("space")
|
||||
BG.set(
|
||||
FESTIVAL=="Xmas"and"snow"or
|
||||
"space"
|
||||
)
|
||||
|
||||
GAME.modeEnv=NONE
|
||||
--Create demo player
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local scene={}
|
||||
|
||||
function scene.sceneInit()
|
||||
BG.set("space")
|
||||
BG.set()
|
||||
end
|
||||
|
||||
scene.widgetList={
|
||||
|
||||
@@ -20,7 +20,7 @@ local touchDist
|
||||
local scene={}
|
||||
|
||||
function scene.sceneInit(org)
|
||||
BG.set("space")
|
||||
BG.set()
|
||||
destroyPlayers()
|
||||
local cam=mapCam
|
||||
cam.zoomK=org=="main"and 5 or 1
|
||||
|
||||
@@ -4,7 +4,7 @@ local int=math.floor
|
||||
local scene={}
|
||||
|
||||
function scene.sceneInit()
|
||||
BG.set("space")
|
||||
BG.set()
|
||||
end
|
||||
function scene.sceneBack()
|
||||
FILE.save(SETTING,"conf/settings")
|
||||
|
||||
@@ -13,7 +13,7 @@ function scene.sceneInit()
|
||||
last=0
|
||||
jump=0
|
||||
cv=SETTING.cv
|
||||
BG.set("space")
|
||||
BG.set()
|
||||
end
|
||||
function scene.sceneBack()
|
||||
FILE.save(SETTING,"conf/settings")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local scene={}
|
||||
|
||||
function scene.sceneInit()
|
||||
BG.set("space")
|
||||
BG.set()
|
||||
end
|
||||
function scene.sceneBack()
|
||||
FILE.save(SETTING,"conf/settings")
|
||||
@@ -51,7 +51,7 @@ scene.widgetList={
|
||||
code=function()
|
||||
BG.set("none")
|
||||
SETTING.bg=not SETTING.bg
|
||||
BG.set("space")
|
||||
BG.set()
|
||||
end},
|
||||
WIDGET.newSwitch{name="power", x=990, y=640,font=35,disp=WIDGET.lnk_SETval("powerInfo"),
|
||||
code=function()
|
||||
|
||||
@@ -8,7 +8,7 @@ local time,v
|
||||
function scene.sceneInit()
|
||||
time=0
|
||||
v=1
|
||||
BG.set("space")
|
||||
BG.set()
|
||||
end
|
||||
|
||||
function scene.mouseDown(x,y)
|
||||
|
||||
Reference in New Issue
Block a user