屏幕尺寸相关代码整理,修复部分背景显示不正确

This commit is contained in:
MrZ626
2020-09-03 16:07:46 +08:00
parent 4da23852a7
commit c82f04e115
5 changed files with 24 additions and 16 deletions

View File

@@ -345,16 +345,18 @@ back.matrix={
t=t+dt t=t+dt
end, end,
draw=function() draw=function()
gc.scale(scr.k)
gc.clear(.15,.15,.15) gc.clear(.15,.15,.15)
local Y=ceil(scr.H/80) gc.push("transform")
for x=1,ceil(scr.W/80)do local k=scr.k
gc.scale(k)
local Y=ceil(scr.h/80/k)
for x=1,ceil(scr.w/80/k)do
for y=1,Y do for y=1,Y do
gc.setColor(1,1,1,sin(x+matrixT[x][y]*t)*.1+.1) gc.setColor(1,1,1,sin(x+matrixT[x][y]*t)*.1+.1)
gc.rectangle("fill",80*x,80*y,-80,-80) gc.rectangle("fill",80*x,80*y,-80,-80)
end end
end end
gc.scale(1/scr.k) gc.pop()
end, end,
} }

View File

@@ -54,23 +54,23 @@ local swap={
fade={30,15,function(t) fade={30,15,function(t)
local t=t>15 and 2-t/15 or t/15 local t=t>15 and 2-t/15 or t/15
gc.setColor(0,0,0,t) gc.setColor(0,0,0,t)
gc.rectangle("fill",0,0,scr.W,scr.H) gc.rectangle("fill",0,0,scr.w,scr.h)
end}, end},
fade_togame={120,20,function(t) fade_togame={120,20,function(t)
local t=t>20 and(120-t)/100 or t/20 local t=t>20 and(120-t)/100 or t/20
gc.setColor(0,0,0,t) gc.setColor(0,0,0,t)
gc.rectangle("fill",0,0,scr.W,scr.H) gc.rectangle("fill",0,0,scr.w,scr.h)
end}, end},
slowFade={180,90,function(t) slowFade={180,90,function(t)
local t=t>90 and 2-t/90 or t/90 local t=t>90 and 2-t/90 or t/90
gc.setColor(0,0,0,t) gc.setColor(0,0,0,t)
gc.rectangle("fill",0,0,scr.W,scr.H) gc.rectangle("fill",0,0,scr.w,scr.h)
end}, end},
swipe={30,15,function(t) swipe={30,15,function(t)
t=t/30 t=t/30
gc.setColor(.1,.1,.1,1-abs(t-.5)) gc.setColor(.1,.1,.1,1-abs(t-.5))
t=t*t*(3-2*t)*2-1 t=t*t*(3-2*t)*2-1
gc.rectangle("fill",t*scr.W,0,scr.W,scr.H) gc.rectangle("fill",t*scr.w,0,scr.w,scr.h)
end}, end},
}--Scene swapping animations }--Scene swapping animations
function SCN.swapTo(tar,style)--Parallel scene swapping, cannot back function SCN.swapTo(tar,style)--Parallel scene swapping, cannot back

View File

@@ -33,7 +33,13 @@ mapCam={
zoomMethod=nil, zoomMethod=nil,
zoomK=nil, zoomK=nil,
} }
scr={x=0,y=0,w=0,h=0,W=0,H=0,rad=0,k=1}--wid,hei,radius,scale K scr={
x=0,y=0,--Up-left Coord on screen
w=0,h=0,--Fullscreen w/h in gc
W=0,H=0,--Fullscreen w/h in shader
rad=0,--Radius
k=1,--Scale size
}--1280:720-Rect Screen Info
customSel={1,22,1,1,7,3,1,1,8,4,1,1,1} customSel={1,22,1,1,7,3,1,1,8,4,1,1,1}
preField={h=20}for i=1,20 do preField[i]={0,0,0,0,0,0,0,0,0,0}end preField={h=20}for i=1,20 do preField[i]={0,0,0,0,0,0,0,0,0,0}end

View File

@@ -4,7 +4,7 @@ local Timer=love.timer.getTime
local int,ceil,abs,rnd,max,min=math.floor,math.ceil,math.abs,math.random,math.max,math.min local int,ceil,abs,rnd,max,min=math.floor,math.ceil,math.abs,math.random,math.max,math.min
local ins,rem=table.insert,table.remove local ins,rem=table.insert,table.remove
local format=string.format local format=string.format
local scr=scr--Screen camera local scr=scr
local setFont=setFont local setFont=setFont
--------------------------<GameData>-------------------------- --------------------------<GameData>--------------------------
local gameEnv0={ local gameEnv0={

View File

@@ -1751,7 +1751,7 @@ do--play
gc.origin() gc.origin()
if restartCount>0 then if restartCount>0 then
gc.setColor(0,0,0,restartCount*.05) gc.setColor(0,0,0,restartCount*.05)
gc.rectangle("fill",0,0,scr.W,scr.H) gc.rectangle("fill",0,0,scr.w,scr.h)
end end
if game.warnLVL>0 then if game.warnLVL>0 then
gc.setColor(0,0,0,0) gc.setColor(0,0,0,0)
@@ -1886,7 +1886,7 @@ do--pause
gc.setColor(.15,.15,.15,_) gc.setColor(.15,.15,.15,_)
gc.push("transform") gc.push("transform")
gc.origin() gc.origin()
gc.rectangle("fill",0,0,scr.W,scr.H) gc.rectangle("fill",0,0,scr.w,scr.h)
gc.pop() gc.pop()
--Pause Info --Pause Info