diff --git a/Zframework/widget.lua b/Zframework/widget.lua index eaf62a37..6e9a16cc 100644 --- a/Zframework/widget.lua +++ b/Zframework/widget.lua @@ -829,6 +829,8 @@ function WIDGET.set(list) local c1,c2,c3 if FESTIVAL=="Xmas"then c1,c2,c3=COLOR.red,COLOR.white,COLOR.green + elseif FESTIVAL=="sprFes"then + c1,c2,c3=COLOR.red,COLOR.orange,COLOR.yellow end for _,W in next,list do if W.color then diff --git a/main.lua b/main.lua index cfed5332..28d25b9d 100644 --- a/main.lua +++ b/main.lua @@ -26,7 +26,16 @@ LOGIN=false EDITING="" WSCONN=false FESTIVAL= - os.date"%m"=="12"and math.abs(os.date"%d"-25)<4 and"Xmas" + os.date"%m"=="12"and math.abs(os.date"%d"-25)<4 and"Xmas"or + os.date"%m"<"03"and math.abs(({--Spring festival dates, 1.2=2, 2.1=32, etc. + 24,43,32,22,40,29,49,38,26,45, + 34,23,41,31,50,39,28,47,36,25, + 43,32,22,41,29,48,37,26,44,34, + 23,42,31,50,39,28,46,35,24,43, + 32,22,41,30,48,37,26,45,33,23, + 42,32,50,39,28,46,35,24,43,33, + 21,40, + })[0+os.date"%y"]-((os.date"%m"=="01"and 0 or 31)+os.date"%d"))<8 and"sprFes" math.randomseed(os.time()*626) love.keyboard.setKeyRepeat(true) @@ -356,5 +365,13 @@ do end end -BG.setDefault(FESTIVAL=="Xmas"and"snow"or"space") -BGM.setDefault(FESTIVAL=="Xmas"and"mXmas"or"blank") \ No newline at end of file +if FESTIVAL=="Xmas"then + BG.setDefault("snow") + BGM.setDefault("mXmas") +elseif FESTIVAL=="sprFes"then + BG.setDefault("firework") + BGM.setDefault("spring festival") +else + BG.setDefault("space") + BGM.setDefault("blank") +end \ No newline at end of file diff --git a/media/BGM/spring festival.ogg b/media/BGM/spring festival.ogg new file mode 100644 index 00000000..b32516e6 Binary files /dev/null and b/media/BGM/spring festival.ogg differ diff --git a/parts/backgrounds/firework.lua b/parts/backgrounds/firework.lua new file mode 100644 index 00000000..8584fff2 --- /dev/null +++ b/parts/backgrounds/firework.lua @@ -0,0 +1,99 @@ +--Firework +local gc=love.graphics +local circle,line=gc.circle,gc.line +local rnd=math.random +local ins,rem=table.insert,table.remove +local back={} + +local t +local firework,particle +function back.init() + t=26 + firework,particle={},{} + BG.resize() +end +function back.update(dt) + t=t-1 + if t==0 then + ins(firework,{ + x=nil,y=nil, + x0=SCR.W*(rnd()*1.2-.1), + y0=SCR.H*1.5, + x1=SCR.W*(.15+rnd()*.7), + y1=SCR.H*(.15+rnd()*.4), + t=0, + v=.5+rnd(), + color=COLOR.random_bright(), + big=rnd()<.1, + }) + t=rnd(26,62) + end + for i=#firework,1,-1 do + local F=firework[i] + local time=F.t^.5 + if time>1 then + local x,y,color=F.x,F.y,F.color + if F.big then + SFX.play("clear_3",.4) + for _=1,rnd(62,126)do + ins(particle,{ + x=x,y=y, + color=color, + vx=rnd()*16-8, + vy=rnd()*16-8, + t=1, + }) + end + else + SFX.play("clear_2",.35) + for _=1,rnd(16,26)do + ins(particle,{ + x=x,y=y, + color=color, + vx=rnd()*8-4, + vy=rnd()*8-4, + t=1, + }) + end + end + rem(firework,i) + else + F.t=F.t+dt*F.v + F.x=F.x0*(1-time)+F.x1*time + F.y=F.y0*(1-time)+F.y1*time + end + end + for i=#particle,1,-1 do + local P=particle[i] + if P.t<0 then + rem(particle,i) + else + P.x=P.x+P.vx + P.y=P.y+P.vy + P.vy=P.vy+.04 + P.t=P.t-dt*.6 + end + end +end +function back.draw() + gc.clear(.1,.1,.1) + gc.push("transform") + gc.origin() + for i=1,#firework do + local F=firework[i] + gc.setColor(F.color) + circle("fill",F.x,F.y,F.big and 8 or 4) + end + gc.setLineWidth(3) + for i=1,#particle do + local P=particle[i] + local c=P.color + gc.setColor(c[1],c[2],c[3],P.t) + line(P.x,P.y,P.x-P.vx*4,P.y-P.vy*4) + end + gc.pop() +end +function back.discard() + firework=nil +end +return back \ No newline at end of file diff --git a/parts/scenes/dict.lua b/parts/scenes/dict.lua index 444068f0..fd7f5784 100644 --- a/parts/scenes/dict.lua +++ b/parts/scenes/dict.lua @@ -65,6 +65,13 @@ local eggInput={ BGM.setDefault("mXmas") BGM.play() end, + sprfes=function() + FESTIVAL="sprFes" + BG.setDefault("firework") + BGM.setDefault("spring festival") + BGM.play() + end, + spring="sprfes", }for k,v in next,eggInput do if type(v)=="string"then eggInput[k]=eggInput[v]end end local function search() if eggInput[input]then