背景系统增加“默认背景”功能,新增节日飘雪背景
This commit is contained in:
@@ -7,6 +7,7 @@ local BGlist={
|
|||||||
}
|
}
|
||||||
local BG={
|
local BG={
|
||||||
cur="none",
|
cur="none",
|
||||||
|
defaultBG="none",
|
||||||
init=false,
|
init=false,
|
||||||
resize=false,
|
resize=false,
|
||||||
update=NULL,
|
update=NULL,
|
||||||
@@ -23,7 +24,13 @@ function BG.send(...)
|
|||||||
BG.event(...)
|
BG.event(...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
function BG.setDefaultBG(bg)
|
||||||
|
defaultBG=bg
|
||||||
|
end
|
||||||
function BG.set(background)
|
function BG.set(background)
|
||||||
|
if not background then
|
||||||
|
background=defaultBG
|
||||||
|
end
|
||||||
if background==BG.cur or not SETTING.bg then return end
|
if background==BG.cur or not SETTING.bg then return end
|
||||||
BG.discard()
|
BG.discard()
|
||||||
BG.cur=background
|
BG.cur=background
|
||||||
|
|||||||
4
main.lua
4
main.lua
@@ -375,4 +375,6 @@ do
|
|||||||
S.version=VERSION_CODE
|
S.version=VERSION_CODE
|
||||||
FILE.save(STAT,"conf/data")
|
FILE.save(STAT,"conf/data")
|
||||||
end
|
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={}
|
local scene={}
|
||||||
|
|
||||||
function scene.sceneInit()
|
function scene.sceneInit()
|
||||||
BG.set("space")
|
BG.set()
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene.draw()
|
function scene.draw()
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ local scene={}
|
|||||||
local t1,t2,r
|
local t1,t2,r
|
||||||
|
|
||||||
function scene.sceneInit()
|
function scene.sceneInit()
|
||||||
BG.set("space")
|
BG.set()
|
||||||
BGM.play("blank")
|
BGM.play("blank")
|
||||||
t1,t2=0,0--Timer
|
t1,t2=0,0--Timer
|
||||||
r={}--Random animation type
|
r={}--Random animation type
|
||||||
|
|||||||
@@ -45,7 +45,10 @@ local tip
|
|||||||
|
|
||||||
function scene.sceneInit()
|
function scene.sceneInit()
|
||||||
tip=text.getTip()
|
tip=text.getTip()
|
||||||
BG.set("space")
|
BG.set(
|
||||||
|
FESTIVAL=="Xmas"and"snow"or
|
||||||
|
"space"
|
||||||
|
)
|
||||||
|
|
||||||
GAME.modeEnv=NONE
|
GAME.modeEnv=NONE
|
||||||
--Create demo player
|
--Create demo player
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local scene={}
|
local scene={}
|
||||||
|
|
||||||
function scene.sceneInit()
|
function scene.sceneInit()
|
||||||
BG.set("space")
|
BG.set()
|
||||||
end
|
end
|
||||||
|
|
||||||
scene.widgetList={
|
scene.widgetList={
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ local touchDist
|
|||||||
local scene={}
|
local scene={}
|
||||||
|
|
||||||
function scene.sceneInit(org)
|
function scene.sceneInit(org)
|
||||||
BG.set("space")
|
BG.set()
|
||||||
destroyPlayers()
|
destroyPlayers()
|
||||||
local cam=mapCam
|
local cam=mapCam
|
||||||
cam.zoomK=org=="main"and 5 or 1
|
cam.zoomK=org=="main"and 5 or 1
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ local int=math.floor
|
|||||||
local scene={}
|
local scene={}
|
||||||
|
|
||||||
function scene.sceneInit()
|
function scene.sceneInit()
|
||||||
BG.set("space")
|
BG.set()
|
||||||
end
|
end
|
||||||
function scene.sceneBack()
|
function scene.sceneBack()
|
||||||
FILE.save(SETTING,"conf/settings")
|
FILE.save(SETTING,"conf/settings")
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ function scene.sceneInit()
|
|||||||
last=0
|
last=0
|
||||||
jump=0
|
jump=0
|
||||||
cv=SETTING.cv
|
cv=SETTING.cv
|
||||||
BG.set("space")
|
BG.set()
|
||||||
end
|
end
|
||||||
function scene.sceneBack()
|
function scene.sceneBack()
|
||||||
FILE.save(SETTING,"conf/settings")
|
FILE.save(SETTING,"conf/settings")
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
local scene={}
|
local scene={}
|
||||||
|
|
||||||
function scene.sceneInit()
|
function scene.sceneInit()
|
||||||
BG.set("space")
|
BG.set()
|
||||||
end
|
end
|
||||||
function scene.sceneBack()
|
function scene.sceneBack()
|
||||||
FILE.save(SETTING,"conf/settings")
|
FILE.save(SETTING,"conf/settings")
|
||||||
@@ -51,7 +51,7 @@ scene.widgetList={
|
|||||||
code=function()
|
code=function()
|
||||||
BG.set("none")
|
BG.set("none")
|
||||||
SETTING.bg=not SETTING.bg
|
SETTING.bg=not SETTING.bg
|
||||||
BG.set("space")
|
BG.set()
|
||||||
end},
|
end},
|
||||||
WIDGET.newSwitch{name="power", x=990, y=640,font=35,disp=WIDGET.lnk_SETval("powerInfo"),
|
WIDGET.newSwitch{name="power", x=990, y=640,font=35,disp=WIDGET.lnk_SETval("powerInfo"),
|
||||||
code=function()
|
code=function()
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ local time,v
|
|||||||
function scene.sceneInit()
|
function scene.sceneInit()
|
||||||
time=0
|
time=0
|
||||||
v=1
|
v=1
|
||||||
BG.set("space")
|
BG.set()
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene.mouseDown(x,y)
|
function scene.mouseDown(x,y)
|
||||||
|
|||||||
Reference in New Issue
Block a user