diff --git a/Zframework/bg.lua b/Zframework/bg.lua index 8f72bb7f..f5d4a5ee 100644 --- a/Zframework/bg.lua +++ b/Zframework/bg.lua @@ -201,8 +201,8 @@ back.matrix={ draw=function() gc.scale(scr.k) gc.clear(.15,.15,.15) - local Y=ceil(scr.h*scr.dpi/80) - for x=1,ceil(scr.w*scr.dpi/80)do + local Y=ceil(scr.H/80) + for x=1,ceil(scr.W/80)do for y=1,Y do gc.setColor(1,1,1,sin(x+matrixT[x][y]*t)*.1+.1) gc.rectangle("fill",80*x,80*y,-80,-80) diff --git a/Zframework/init.lua b/Zframework/init.lua index 2cca4d8b..a7e12552 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -616,10 +616,9 @@ function keyDown.pause(key) SCN.goto("setting_sound") elseif key=="r"then TASK.clear("play") - mergeStat(stat,players[1].stat) resetGameData() SCN.swapTo("play","none") - elseif key=="p"and game.result then + elseif key=="p"and(game.result or game.replaying)then TASK.removeTask_code(TICK.autoPause) resetPartGameData(true) SCN.swapTo("play","none") @@ -779,11 +778,11 @@ function keyDown.history(key) end ------------------------------------------------------------- local lastX,lastY=0,0--Last clickDown pos -function love.mousepressed(x,y,k,t,num) - if t then return end +function love.mousepressed(x,y,k,touch,num) + if touch then return end mouseShow=true mx,my=xOy:inverseTransformPoint(x,y) - if devMode==1 then print(mx,my)end + if devMode==1 then DBP(mx,my)end if SCN.swapping then return end if mouseDown[SCN.cur]then mouseDown[SCN.cur](mx,my,k) @@ -810,15 +809,17 @@ function love.mousemoved(x,y,dx,dy,t) WIDGET.moveCursor(mx,my) end end -function love.mousereleased(x,y,k,t,num) - if t then return end +function love.mousereleased(x,y,k,touch,num) + if touch or SCN.swapping then return end mx,my=xOy:inverseTransformPoint(x,y) - if t or SCN.swapping then return end if mouseUp[SCN.cur]then mouseUp[SCN.cur](mx,my,k) end - if lastX and(mx-lastX)^2+(my-lastY)^2<26 and mouseClick[SCN.cur]then - mouseClick[SCN.cur](mx,my,k) + if lastX and(mx-lastX)^2+(my-lastY)^2<26 then + if mouseClick[SCN.cur]then + mouseClick[SCN.cur](mx,my,k) + end + sysFX.newRipple(.3,mx,my,30) end end function love.wheelmoved(x,y) @@ -888,7 +889,7 @@ function love.keypressed(i) end else if i=="f5"then - print("DEBUG:") + DBP("DEBUG:") elseif i=="f8"then devMode=nil TEXT.show("DEBUG OFF",640,360,80,"fly",.8) elseif i=="f9"then devMode=1 TEXT.show("DEBUG 1",640,360,80,"fly",.8) elseif i=="f10"then devMode=2 TEXT.show("DEBUG 2",640,360,80,"fly",.8) @@ -910,7 +911,7 @@ function love.keypressed(i) assert(false,"Techmino:挂了") elseif i=="e"then for k,v in next,_G do - print(k,v) + DBP(k,v) end elseif WIDGET.sel then local W=WIDGET.sel @@ -995,10 +996,11 @@ function love.lowmemory() collectgarbage() end function love.resize(w,h) - scr.w,scr.h=w,h + scr.w,scr.h,scr.dpi=w,h,gc.getDPIScale() + scr.W,scr.H=scr.w*scr.dpi,scr.h*scr.dpi scr.r=h/w scr.rad=(w^2+h^2)^.5 - scr.dpi=gc.getDPIScale() + if scr.r>=.5625 then scr.k=w/1280 scr.x,scr.y=0,(h-w*9/16)*.5 @@ -1014,7 +1016,6 @@ function love.resize(w,h) end function love.focus(f) if f then - TASK.new(TICK.autoResize,{0}) love.timer.step() elseif SCN.cur=="play"and setting.autoPause then pauseGame() @@ -1145,9 +1146,13 @@ function love.run() end --Fresh power info. - if Timer()-lastFreshPow>3 and setting.powerInfo and SCN.cur~="load"then + if Timer()-lastFreshPow>2 and setting.powerInfo and SCN.cur~="load"then updatePowerInfo() lastFreshPow=Timer() + _=gc.getWidth() + if _~=scr.w then + love.resize(_,gc.getHeight()) + end end --Keep 60fps diff --git a/Zframework/paint.lua b/Zframework/paint.lua index a4d8597a..5bef1f2a 100644 --- a/Zframework/paint.lua +++ b/Zframework/paint.lua @@ -520,7 +520,7 @@ function Pnt.play() gc.origin() if restartCount>0 then gc.setColor(0,0,0,restartCount*.05) - gc.rectangle("fill",0,0,scr.w*scr.dpi,scr.h*scr.dpi) + gc.rectangle("fill",0,0,scr.W,scr.H) end if game.warnLVL>0 then gc.setColor(0,0,0,0) @@ -545,7 +545,7 @@ function Pnt.pause() gc.setColor(.15,.15,.15,_) gc.push("transform") gc.origin() - gc.rectangle("fill",0,0,scr.w*scr.dpi,scr.h*scr.dpi) + gc.rectangle("fill",0,0,scr.W,scr.H) gc.pop() --Pause Info diff --git a/Zframework/scene.lua b/Zframework/scene.lua index df6cca31..77df87c3 100644 --- a/Zframework/scene.lua +++ b/Zframework/scene.lua @@ -364,26 +364,24 @@ local swap={ fade={30,15,function(t) local t=t>15 and 2-t/15 or t/15 gc.setColor(0,0,0,t) - gc.rectangle("fill",0,0,scr.w*scr.dpi,scr.h*scr.dpi) + gc.rectangle("fill",0,0,scr.W,scr.H) end}, fade_togame={120,20,function(t) local t=t>20 and(120-t)/100 or t/20 gc.setColor(0,0,0,t) - gc.rectangle("fill",0,0,scr.w*scr.dpi,scr.h*scr.dpi) + gc.rectangle("fill",0,0,scr.W,scr.H) end}, slowFade={180,90,function(t) local t=t>90 and 2-t/90 or t/90 gc.setColor(0,0,0,t) - gc.rectangle("fill",0,0,scr.w*scr.dpi,scr.h*scr.dpi) + gc.rectangle("fill",0,0,scr.W,scr.H) end}, swipe={30,15,function(t) - gc.setColor(0,0,0,1-abs(t-15)/15) - if t>15 then - t=t/15-1 - gc.rectangle("fill",scr.w*scr.dpi,0,-scr.w*scr.dpi*(1-t),scr.h*scr.dpi) - else - gc.rectangle("fill",0,0,scr.w*scr.dpi*t/15,scr.h*scr.dpi) - end + t=t/30 + gc.setColor(.1,.1,.1,1-abs(t-.5)) + t=t*t*(3-2*t)*2-1 + local w=scr.W + gc.rectangle("fill",t*w,0,w,scr.H) end}, }--Scene swapping animations function SCN.swapTo(tar,style)--Parallel scene swapping, cannot back diff --git a/Zframework/sysFX.lua b/Zframework/sysFX.lua index 2ef49937..fb302a21 100644 --- a/Zframework/sysFX.lua +++ b/Zframework/sysFX.lua @@ -1,31 +1,47 @@ local gc=love.graphics local setColor=gc.setColor local setWidth=gc.setLineWidth -local rect=gc.rectangle +local ins,rem=table.insert,table.remove local fx={} +local FXupdate={} +function FXupdate.ripple(S,dt) + S.t=S.t+dt*S.rate + return S.t>=1 +end +function FXupdate.rectRipple(S,dt) + S.t=S.t+dt*S.rate + return S.t>=1 +end +function FXupdate.shade(S,dt) + S.t=S.t+dt*S.rate + return S.t>=1 +end + local FXdraw={} function FXdraw.ripple(S) + setWidth(2) + local t=S.t + setColor(1,1,1,1-t) + gc.circle("line",S.x,S.y,t*(2-t)*S.r) +end +function FXdraw.rectRipple(S) setWidth(6) setColor(1,1,1,1-S.t) local r=(10*S.t)^1.2 - rect("line",S[1]-r,S[2]-r,S[3]+2*r,S[4]+2*r) + gc.rectangle("line",S.x-r,S.y-r,S.w+2*r,S.h+2*r) end function FXdraw.shade(S) - setColor(S[1],S[2],S[3],1-S.t) - rect("fill",S[4],S[5],S[6],S[7],2) + setColor(S.r,S.g,S.b,1-S.t) + gc.rectangle("fill",S.x,S.y,S.w,S.h,2) end local sysFX={} function sysFX.update(dt) for i=#fx,1,-1 do - local S=fx[i] - S.t=S.t+dt*S.rate - if S.t>=1 then - for i=i,#fx do - fx[i]=fx[i+1] - end + if fx[i]:update(dt) then + rem(fx,i) end end end @@ -34,9 +50,33 @@ function sysFX.draw() fx[i]:draw() end end ---0=ripple,x,y,w,h ---1=shade,r,g,b,x,y,w,h -function sysFX.new(type,duration,...) - fx[#fx+1]={draw=FXdraw[type],t=0,rate=1/duration,...} + +function sysFX.newRipple(duration,x,y,r) + fx[#fx+1]={ + update=FXupdate.ripple, + draw=FXdraw.ripple, + t=0, + rate=1/duration, + x=x,y=y,r=r, + } +end +function sysFX.newRectRipple(duration,x,y,w,h) + fx[#fx+1]={ + update=FXupdate.rectRipple, + draw=FXdraw.rectRipple, + t=0, + rate=1/duration, + x=x,y=y,w=w,h=h, + } +end +function sysFX.newShade(duration,r,g,b,x,y,w,h) + fx[#fx+1]={ + update=FXupdate.shade, + draw=FXdraw.shade, + t=0, + rate=1/duration, + r=r,g=g,b=b, + x=x,y=y,w=w,h=h, + } end return sysFX \ No newline at end of file diff --git a/Zframework/voice.lua b/Zframework/voice.lua index 58fb615f..98eea817 100644 --- a/Zframework/voice.lua +++ b/Zframework/voice.lua @@ -121,7 +121,7 @@ function VOC.play(s,chn) if chn then local L=voiceQueue[chn] local _=VOC.list[s] - if not _ then print("no VOC called:"..s)return end + if not _ then DBP("no VOC called:"..s)return end L[#L+1]=_[rnd(#_)] L.s=1 --Add to queue[chn] diff --git a/Zframework/widget.lua b/Zframework/widget.lua index ce18cd3b..dc2eb6f0 100644 --- a/Zframework/widget.lua +++ b/Zframework/widget.lua @@ -25,13 +25,13 @@ function button:getCenter() end function button:FX() local ATV=self.ATV - sysFX.new( - "ripple", + sysFX.newRectRipple( .16, self.x-ATV, self.y-ATV, self.w+2*ATV, self.h+2*ATV + ,5 ) end function button:update() @@ -68,7 +68,7 @@ function button:draw() end end function button:getInfo() - print(format("x=%d,y=%d,w=%d,h=%d,font=%d",self.x+self.w*.5,self.y+self.h*.5,self.w,self.h,self.font)) + DBP(format("x=%d,y=%d,w=%d,h=%d,font=%d",self.x+self.w*.5,self.y+self.h*.5,self.w,self.h,self.font)) end local key={ @@ -118,7 +118,7 @@ function key:draw() end end function key:getInfo() - print(format("x=%d,y=%d,w=%d,h=%d,font=%d",self.x+self.w*.5,self.y+self.h*.5,self.w,self.h,self.font)) + DBP(format("x=%d,y=%d,w=%d,h=%d,font=%d",self.x+self.w*.5,self.y+self.h*.5,self.w,self.h,self.font)) end local switch={ @@ -171,11 +171,11 @@ function switch:draw() if t then gc.setColor(1,1,1) setFont(self.font) - gc.printf(t,x-412-ATV,y+20-self.font*.7-ATV*.5,400,"right") + gc.printf(t,x-412-ATV,y+20-self.font*.7,400,"right") end end function switch:getInfo() - print(format("x=%d,y=%d,font=%d",self.x,self.y,self.font)) + DBP(format("x=%d,y=%d,font=%d",self.x,self.y,self.font)) end local slider={ @@ -236,11 +236,11 @@ function slider:draw() if t then gc.setColor(1,1,1) setFont(self.font) - gc.printf(t,x-312-ATV,y-self.font*.7-ATV*.5,300,"right") + gc.printf(t,x-312-ATV,y-self.font*.7,300,"right") end end function slider:getInfo() - print(format("x=%d,y=%d,w=%d",self.x,self.y,self.w)) + DBP(format("x=%d,y=%d,w=%d",self.x,self.y,self.w)) end local WIDGET={} diff --git a/main.lua b/main.lua index 4b91d18b..b010ae10 100644 --- a/main.lua +++ b/main.lua @@ -8,13 +8,16 @@ Techmino is my first "huge project" optimization is welcomed if you also love tetromino game ]]-- +--? +function NULL()end +DBP=print--use this if need debugging print + --Global Setting & Vars math.randomseed(os.time()*626) love.keyboard.setKeyRepeat(true) love.keyboard.setTextInput(false) love.mouse.setVisible(false) -function NULL()end system=love.system.getOS() game={} mapCam={ @@ -122,16 +125,8 @@ if S.version~=gameVersion then TEXT.show(text.newBigVersion,640,200,30,"fly",.3) newVersionLaunch=true + fs.remove("sprintPenta.dat") fs.remove("master_adavnce.dat") fs.remove("master_beginner.dat") - for name,M in next,Modes do - if M.score then - if modeRanks[name]==6 then - modeRanks[name]=0 - end - else - modeRanks[name]=6 - end - end end R,S=nil \ No newline at end of file