升级SCR模块,整理大量坐标系变换代码
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
--Blackhole
|
||||
local gc=love.graphics
|
||||
local gc_push,gc_pop,gc_clear,gc_origin=gc.push,gc.pop,gc.clear,gc.origin
|
||||
local gc_translate,gc_scale=gc.translate,gc.scale
|
||||
local gc_clear,gc_replaceTransform=gc.clear,gc.replaceTransform
|
||||
local gc_setColor,gc_setLineWidth=gc.setColor,gc.setLineWidth
|
||||
local gc_draw,gc_circle=gc.draw,gc.circle
|
||||
|
||||
@@ -43,9 +42,7 @@ function back.update()
|
||||
end
|
||||
function back.draw()
|
||||
gc_clear(.1,.1,.1)
|
||||
gc_push('transform')
|
||||
gc_origin()
|
||||
gc_translate(SCR.cx,SCR.cy)
|
||||
gc_replaceTransform(SCR.xOy_m)
|
||||
|
||||
--Squares
|
||||
gc_setColor(1,1,1,.2)
|
||||
@@ -55,7 +52,6 @@ function back.draw()
|
||||
end
|
||||
|
||||
--Blackhole
|
||||
gc_scale(SCR.rad/1600)
|
||||
gc_setColor(.07,.07,.07)
|
||||
gc_circle('fill',0,0,157)
|
||||
gc_setLineWidth(6)
|
||||
@@ -63,8 +59,6 @@ function back.draw()
|
||||
gc_setColor(.07,.07,.07,1-i*.0666)
|
||||
gc_circle('line',0,0,160+6*i)
|
||||
end
|
||||
gc_scale(1600/SCR.rad)
|
||||
gc_pop()
|
||||
end
|
||||
function back.discard()
|
||||
squares=nil
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--Large falling tetrominoes
|
||||
local gc=love.graphics
|
||||
local gc_push,gc_pop,gc_clear,gc_origin=gc.push,gc.pop,gc.clear,gc.origin
|
||||
local gc_clear=gc.clear
|
||||
local gc_setColor,gc_draw=gc.setColor,gc.draw
|
||||
|
||||
local rnd=math.random
|
||||
@@ -36,8 +36,6 @@ function back.update()
|
||||
end
|
||||
function back.draw()
|
||||
gc_clear(.1,.1,.1)
|
||||
gc_push('transform')
|
||||
gc_origin()
|
||||
gc_setColor(1,1,1,.2)
|
||||
for i=1,#mino do
|
||||
local M=mino[i]
|
||||
@@ -50,7 +48,6 @@ function back.draw()
|
||||
end
|
||||
end
|
||||
end
|
||||
gc_pop()
|
||||
end
|
||||
function back.discard()
|
||||
mino=nil
|
||||
|
||||
@@ -41,15 +41,12 @@ function back.update()
|
||||
end
|
||||
function back.draw()
|
||||
gc.clear(.1,.1,.1)
|
||||
gc.push('transform')
|
||||
gc.origin()
|
||||
for i=1,#mino do
|
||||
local C=mino[i]
|
||||
local c=C.color
|
||||
gc.setColor(c[1],c[2],c[3],.2)
|
||||
gc.draw(C.block,C.x,C.y,C.ang,C.k,C.k,C.block:getWidth()/2,C.block:getHeight()/2)
|
||||
end
|
||||
gc.pop()
|
||||
end
|
||||
function back.discard()
|
||||
mino=nil
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
--Space but tetrominoes
|
||||
local gc=love.graphics
|
||||
local gc_push,gc_pop,gc_clear,gc_origin=gc.push,gc.pop,gc.clear,gc.origin
|
||||
local gc_translate,gc_setColor,gc_draw=gc.translate,gc.setColor,gc.draw
|
||||
local gc_clear,gc_translate=gc.clear,gc.translate
|
||||
local gc_setColor,gc_draw=gc.setColor,gc.draw
|
||||
|
||||
local sin,cos=math.sin,math.cos
|
||||
local rnd=math.random
|
||||
@@ -36,14 +36,12 @@ function back.update()
|
||||
rem(mino,i)
|
||||
else
|
||||
M.rotate=M.rotate+M.vr
|
||||
M.v=M.v*(1+M.d/SCR.rad*.05)
|
||||
M.v=M.v*(1+M.d/rad*.05)
|
||||
end
|
||||
end
|
||||
end
|
||||
function back.draw()
|
||||
gc_clear(.1,.1,.1)
|
||||
gc_push('transform')
|
||||
gc_origin()
|
||||
gc_translate(SCR.cx,SCR.cy)
|
||||
for i=1,#mino do
|
||||
local M=mino[i]
|
||||
@@ -51,7 +49,7 @@ function back.draw()
|
||||
gc_setColor(c[1],c[2],c[3],.2)
|
||||
gc_draw(M.block,M.d*cos(M.ang),M.d*sin(M.ang),M.rotate,(18*M.d/SCR.rad)^1.6,nil,M.block:getWidth()/2,M.block:getHeight()/2)
|
||||
end
|
||||
gc_pop()
|
||||
gc_translate(-SCR.cx,-SCR.cy)
|
||||
end
|
||||
function back.discard()
|
||||
mino=nil
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--Flying cubes
|
||||
local gc=love.graphics
|
||||
local gc_push,gc_pop,gc_clear,gc_origin=gc.push,gc.pop,gc.clear,gc.origin
|
||||
local gc_clear=gc.clear
|
||||
local gc_setColor,gc_setLineWidth=gc.setColor,gc.setLineWidth
|
||||
local gc_rectangle=gc.rectangle
|
||||
|
||||
@@ -65,8 +65,6 @@ function back.update(dt)
|
||||
end
|
||||
function back.draw()
|
||||
gc_clear(.1,.1,.1)
|
||||
gc_push('transform')
|
||||
gc_origin()
|
||||
gc_setLineWidth(6)
|
||||
for i=1,#squares do
|
||||
local S=squares[i]
|
||||
@@ -76,7 +74,6 @@ function back.draw()
|
||||
gc_setColor(c[1],c[2],c[3],.3)
|
||||
gc_rectangle('fill',S.x,S.y,S.size,S.size)
|
||||
end
|
||||
gc_pop()
|
||||
end
|
||||
function back.discard()
|
||||
squares=nil
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--UUZ's fan
|
||||
local gc=love.graphics
|
||||
local gc_push,gc_pop,gc_clear,gc_origin=gc.push,gc.pop,gc.clear,gc.origin
|
||||
local gc_clear,gc_origin,gc_replaceTransform=gc.clear,gc.origin,gc.replaceTransform
|
||||
local gc_translate=gc.translate
|
||||
local gc_setColor,gc_setLineWidth=gc.setColor,gc.setLineWidth
|
||||
local gc_line,gc_polygon=gc.line,gc.polygon
|
||||
@@ -44,11 +44,11 @@ function back.update()
|
||||
end
|
||||
end
|
||||
function back.draw()
|
||||
gc_push('transform')
|
||||
gc.replaceTransform(SCR.xOy)
|
||||
gc_translate(640,360+20*sin(t*.02))
|
||||
gc_clear(.1,.1,.1)
|
||||
|
||||
gc_replaceTransform(SCR.xOy_m)
|
||||
gc_translate(0,20*sin(t*.02))
|
||||
|
||||
gc_setLineWidth(320)
|
||||
gc_setColor(.9,.6,.9,.1)
|
||||
gc_arc('line','open',0,420,500,-.8*3.1416,-.2*3.1416)
|
||||
@@ -72,7 +72,6 @@ function back.draw()
|
||||
local P=petal[i]
|
||||
gc_ellipse('fill',P.x,P.y,P.rx,P.ry)
|
||||
end
|
||||
gc_pop()
|
||||
end
|
||||
function back.discard()
|
||||
petal=nil
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
--Firework
|
||||
local gc=love.graphics
|
||||
local gc_push,gc_pop,gc_clear,gc_origin=gc.push,gc.pop,gc.clear,gc.origin
|
||||
local gc_clear=gc.clear
|
||||
local gc_setColor,gc_setLineWidth=gc.setColor,gc.setLineWidth
|
||||
local gc_line,gc_circle=gc.line,gc.circle
|
||||
|
||||
@@ -79,8 +79,6 @@ function back.update(dt)
|
||||
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)
|
||||
@@ -93,7 +91,6 @@ function back.draw()
|
||||
gc_setColor(c[1],c[2],c[3],P.t*.4)
|
||||
gc_line(P.x,P.y,P.x-P.vx*4,P.y-P.vy*4)
|
||||
end
|
||||
gc_pop()
|
||||
end
|
||||
function back.discard()
|
||||
firework=nil
|
||||
|
||||
@@ -38,14 +38,11 @@ function back.update(dt)
|
||||
end
|
||||
function back.draw()
|
||||
gc.clear(.1,.1,.1)
|
||||
gc.push('transform')
|
||||
gc.origin()
|
||||
gc.setColor(1,1,1,.2)
|
||||
local img=IMG.lanterns
|
||||
for i=1,#lanterns do
|
||||
local L=lanterns[i]
|
||||
mDraw(img[int(L.phase*6)+1],L.x,L.y,nil,L.size)
|
||||
end
|
||||
gc.pop()
|
||||
end
|
||||
return back
|
||||
@@ -1,7 +1,6 @@
|
||||
--Black-White grid
|
||||
local gc=love.graphics
|
||||
local gc_push,gc_pop,gc_clear=gc.push,gc.pop,gc.clear
|
||||
local gc_scale=gc.scale
|
||||
local gc_clear,gc_scale=gc.clear,gc.scale
|
||||
local gc_setColor=gc.setColor
|
||||
local gc_rectangle=gc.rectangle
|
||||
|
||||
@@ -19,16 +18,14 @@ function back.update(dt)
|
||||
end
|
||||
function back.draw()
|
||||
gc_clear(.1,.1,.1)
|
||||
gc_push('transform')
|
||||
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
|
||||
gc_setColor(1,1,1,sin(x+matrixT[x][y]*t)*.04+.04)
|
||||
gc_rectangle('fill',80*x,80*y,-80,-80)
|
||||
end
|
||||
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
|
||||
gc_setColor(1,1,1,sin(x+matrixT[x][y]*t)*.04+.04)
|
||||
gc_rectangle('fill',80*x,80*y,-80,-80)
|
||||
end
|
||||
gc_pop()
|
||||
end
|
||||
end
|
||||
return back
|
||||
@@ -39,14 +39,11 @@ function back.update()
|
||||
end
|
||||
function back.draw()
|
||||
gc.clear(.1,.1,.1)
|
||||
gc.push('transform')
|
||||
gc.setColor(.7,.7,.7)
|
||||
gc.origin()
|
||||
for i=1,#snow do
|
||||
local P=snow[i]
|
||||
ellipse('fill',P.x,P.y,P.rx,P.ry)
|
||||
end
|
||||
gc.pop()
|
||||
end
|
||||
function back.discard()
|
||||
snow=nil
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
local gc=love.graphics
|
||||
local gc_push,gc_pop=gc.push,gc.pop
|
||||
local gc_origin,gc_translate=gc.origin,gc.translate
|
||||
local gc_origin,gc_replaceTransform=gc.origin,gc.replaceTransform
|
||||
local gc_setLineWidth,gc_setColor=gc.setLineWidth,gc.setColor
|
||||
local gc_setShader=gc.setShader
|
||||
local gc_draw,gc_rectangle,gc_line,gc_printf=gc.draw,gc.rectangle,gc.line,gc.printf
|
||||
@@ -563,7 +563,7 @@ do--function drawSelfProfile()
|
||||
function drawSelfProfile()
|
||||
local selfAvatar=USERS.getAvatar(USER.uid)
|
||||
gc_push('transform')
|
||||
gc_translate(1280,0)
|
||||
gc_replaceTransform(SCR.xOy_ur)
|
||||
|
||||
--Draw avatar
|
||||
gc_setLineWidth(2)
|
||||
@@ -590,12 +590,13 @@ do--function drawSelfProfile()
|
||||
gc_pop()
|
||||
end
|
||||
end
|
||||
do--function drawOnlinePlayerCount()
|
||||
function drawOnlinePlayerCount()
|
||||
setFont(20)
|
||||
gc_setColor(1,1,1)
|
||||
gc_printf(("%s: %s/%s/%s"):format(text.onlinePlayerCount,NET.UserCount,NET.PlayCount,NET.StreamCount),0,80,1272,'right')
|
||||
end
|
||||
function drawOnlinePlayerCount()
|
||||
setFont(20)
|
||||
gc_setColor(1,1,1)
|
||||
gc_push('transform')
|
||||
gc_replaceTransform(SCR.xOy_ur)
|
||||
gc_printf(("%s: %s/%s/%s"):format(text.onlinePlayerCount,NET.UserCount,NET.PlayCount,NET.StreamCount),-600,80,594,'right')
|
||||
gc_pop()
|
||||
end
|
||||
do--function drawWarning()
|
||||
local shader_warning=SHADER.warning
|
||||
|
||||
@@ -21,23 +21,21 @@ return{
|
||||
end,
|
||||
mesDisp=function(P)
|
||||
if not GAME.result then
|
||||
gc.push('transform')
|
||||
if GAME.replaying then
|
||||
gc.setColor(.3,.3,.3,.7)
|
||||
gc.push('transform')
|
||||
gc.origin()
|
||||
gc.setColor(.3,.3,.3,.7)
|
||||
gc.rectangle('fill',0,0,SCR.w,SCR.h)
|
||||
gc.pop()
|
||||
else
|
||||
gc.clear(.2,.2,.2)
|
||||
--Frame
|
||||
gc.setColor(.5,.5,.5)
|
||||
gc.push('transform')
|
||||
gc.translate(150,0)
|
||||
gc.setColor(.5,.5,.5)
|
||||
--Frame
|
||||
gc.rectangle('line',-1,-11,302,612)--Boarder
|
||||
gc.rectangle('line',301,-3,15,604)--AtkBuffer boarder
|
||||
gc.rectangle('line',-16,-3,15,604)--B2b bar boarder
|
||||
gc.pop()
|
||||
end
|
||||
gc.pop()
|
||||
end
|
||||
|
||||
--Figures
|
||||
|
||||
@@ -26,10 +26,9 @@ function scene.draw()
|
||||
|
||||
--Gray screen cover
|
||||
gc.setColor(.15,.15,.15,timer*1.26)
|
||||
gc.push('transform')
|
||||
gc.origin()
|
||||
gc.rectangle('fill',0,0,SCR.w,SCR.h)
|
||||
gc.pop()
|
||||
gc.replaceTransform(SCR.origin)
|
||||
gc.rectangle('fill',0,0,SCR.w,SCR.h)
|
||||
gc.replaceTransform(SCR.xOy)
|
||||
|
||||
--Pie counter
|
||||
gc.setColor(1,1,1,4*(1-timer))
|
||||
|
||||
@@ -53,13 +53,13 @@ function scene.draw()
|
||||
local t=t1-i*15
|
||||
if t>0 then
|
||||
gc.push('transform')
|
||||
gc.setColor(1,1,1,min(t*.025,1))
|
||||
titleTransform[animeType[i]](t,i)
|
||||
local dt=(t1+62-5*i)%300
|
||||
if dt<20 then
|
||||
gc.translate(0,math.abs(10-dt)-10)
|
||||
end
|
||||
gc.polygon('line',L[i])
|
||||
gc.setColor(1,1,1,min(t*.025,1))
|
||||
titleTransform[animeType[i]](t,i)
|
||||
local dt=(t1+62-5*i)%300
|
||||
if dt<20 then
|
||||
gc.translate(0,math.abs(10-dt)-10)
|
||||
end
|
||||
gc.polygon('line',L[i])
|
||||
gc.pop()
|
||||
end
|
||||
end
|
||||
|
||||
@@ -373,11 +373,10 @@ function scene.draw()
|
||||
|
||||
--Black screen
|
||||
if blackTime>0 or openTime>3 then
|
||||
gc.push('transform')
|
||||
gc.origin()
|
||||
gc.replaceTransform(SCR.origin)
|
||||
gc.setColor(0,0,0,blackTime+(openTime-3)*4)
|
||||
gc.rectangle('fill',0,0,SCR.w,SCR.h)
|
||||
gc.pop()
|
||||
gc.replaceTransform(SCR.xOy)
|
||||
end
|
||||
gc.pop()
|
||||
end
|
||||
|
||||
@@ -174,10 +174,9 @@ function scene.draw()
|
||||
local _=T
|
||||
if GAME.result then _=_*.7 end
|
||||
gc.setColor(.15,.15,.15,_)
|
||||
gc.push('transform')
|
||||
gc.origin()
|
||||
gc.rectangle('fill',0,0,SCR.w,SCR.h)
|
||||
gc.pop()
|
||||
gc.replaceTransform(SCR.origin)
|
||||
gc.rectangle('fill',0,0,SCR.w,SCR.h)
|
||||
gc.replaceTransform(SCR.xOy)
|
||||
|
||||
--Pause Info
|
||||
setFont(25)
|
||||
|
||||
@@ -77,8 +77,7 @@ function scene.update(dt)
|
||||
end
|
||||
|
||||
function scene.draw()
|
||||
gc.push('transform')
|
||||
gc.origin()
|
||||
gc.replaceTransform(SCR.origin)
|
||||
for i=1,#names do
|
||||
local N=names[i]
|
||||
if type(N.color)=='table'then
|
||||
@@ -88,7 +87,7 @@ function scene.draw()
|
||||
end
|
||||
gc.draw(N.text,N.x,N.y)
|
||||
end
|
||||
gc.pop()
|
||||
gc.replaceTransform(SCR.xOy)
|
||||
|
||||
gc.setColor(1,1,1)
|
||||
local T=40*math.min(time,45)
|
||||
|
||||
Reference in New Issue
Block a user