整理代码
This commit is contained in:
@@ -45,7 +45,7 @@ THEME= require'Zframework.theme'
|
|||||||
local ms,kb=love.mouse,love.keyboard
|
local ms,kb=love.mouse,love.keyboard
|
||||||
|
|
||||||
local gc=love.graphics
|
local gc=love.graphics
|
||||||
local gc_push,gc_pop,gc_clear=gc.push,gc.pop,gc.clear
|
local gc_push,gc_pop,gc_clear,gc_discard=gc.push,gc.pop,gc.clear,gc.discard
|
||||||
local gc_replaceTransform,gc_present=gc.replaceTransform,gc.present
|
local gc_replaceTransform,gc_present=gc.replaceTransform,gc.present
|
||||||
local gc_setColor,gc_setLineWidth=gc.setColor,gc.setLineWidth
|
local gc_setColor,gc_setLineWidth=gc.setColor,gc.setLineWidth
|
||||||
local gc_draw,gc_line,gc_print=gc.draw,gc.line,gc.print
|
local gc_draw,gc_line,gc_print=gc.draw,gc.line,gc.print
|
||||||
@@ -522,18 +522,21 @@ local cursor_holdImg=DOGC{16,16,
|
|||||||
function love.run()
|
function love.run()
|
||||||
local love=love
|
local love=love
|
||||||
|
|
||||||
local VOC,BG,SYSFX=VOC,BG,SYSFX
|
local BG=BG
|
||||||
local TASK,TEXT=TASK,TEXT
|
local TEXT_update,TEXT_draw=TEXT.update,TEXT.draw
|
||||||
|
local MES_update,MES_draw=MES.update,MES.draw
|
||||||
local TEXTURE,TIME=TEXTURE,TIME
|
local WS_update=WS.update
|
||||||
local SETTING,VERSION=SETTING,VERSION
|
local TASK_update=TASK.update
|
||||||
|
local SYSFX_update,SYSFX_draw=SYSFX.update,SYSFX.draw
|
||||||
|
local WIDGET_update,WIDGET_draw=WIDGET.update,WIDGET.draw
|
||||||
|
|
||||||
local STEP,WAIT=love.timer.step,love.timer.sleep
|
local STEP,WAIT=love.timer.step,love.timer.sleep
|
||||||
local FPS,MINI=love.timer.getFPS,love.window.isMinimized
|
local FPS,MINI=love.timer.getFPS,love.window.isMinimized
|
||||||
local PUMP,POLL=love.event.pump,love.event.poll
|
local PUMP,POLL=love.event.pump,love.event.poll
|
||||||
|
|
||||||
local frameTimeList={}
|
local TIME,SETTING,VERSION=TIME,SETTING,VERSION
|
||||||
|
|
||||||
|
local frameTimeList={}
|
||||||
local lastFrame=TIME()
|
local lastFrame=TIME()
|
||||||
local lastFreshPow=lastFrame
|
local lastFreshPow=lastFrame
|
||||||
local FCT=0--Framedraw counter, from 0~99
|
local FCT=0--Framedraw counter, from 0~99
|
||||||
@@ -567,14 +570,14 @@ function love.run()
|
|||||||
STEP()
|
STEP()
|
||||||
VOC.update()
|
VOC.update()
|
||||||
BG.update(dt)
|
BG.update(dt)
|
||||||
TEXT.update()
|
TEXT_update()
|
||||||
MES.update(dt)
|
MES_update(dt)
|
||||||
WS.update(dt)
|
WS_update(dt)
|
||||||
TASK.update()
|
TASK_update()
|
||||||
SYSFX.update(dt)
|
SYSFX_update(dt)
|
||||||
if SCN.update then SCN.update(dt)end
|
if SCN.update then SCN.update(dt)end
|
||||||
if SCN.swapping then SCN.swapUpdate()end
|
if SCN.swapping then SCN.swapUpdate()end
|
||||||
WIDGET.update()
|
WIDGET_update()
|
||||||
|
|
||||||
--DRAW
|
--DRAW
|
||||||
if not MINI()then
|
if not MINI()then
|
||||||
@@ -582,14 +585,15 @@ function love.run()
|
|||||||
if FCT>=100 then
|
if FCT>=100 then
|
||||||
FCT=FCT-100
|
FCT=FCT-100
|
||||||
|
|
||||||
|
local safeX=SCR.safeX
|
||||||
gc_replaceTransform(SCR.origin)
|
gc_replaceTransform(SCR.origin)
|
||||||
gc_setColor(1,1,1)
|
gc_setColor(1,1,1)
|
||||||
BG.draw()
|
BG.draw()
|
||||||
gc_replaceTransform(SCR.xOy)
|
gc_replaceTransform(SCR.xOy)
|
||||||
if SCN.draw then SCN.draw()end
|
if SCN.draw then SCN.draw()end
|
||||||
WIDGET.draw()
|
WIDGET_draw()
|
||||||
SYSFX.draw()
|
SYSFX_draw()
|
||||||
TEXT.draw()
|
TEXT_draw()
|
||||||
|
|
||||||
--Draw cursor
|
--Draw cursor
|
||||||
if mouseShow then
|
if mouseShow then
|
||||||
@@ -602,12 +606,12 @@ function love.run()
|
|||||||
gc_draw(ms.isDown(1)and cursor_holdImg or cursorImg,mx,my,nil,nil,nil,8,8)
|
gc_draw(ms.isDown(1)and cursor_holdImg or cursorImg,mx,my,nil,nil,nil,8,8)
|
||||||
end
|
end
|
||||||
gc_replaceTransform(SCR.xOy_ul)
|
gc_replaceTransform(SCR.xOy_ul)
|
||||||
MES.draw()
|
MES_draw()
|
||||||
gc_replaceTransform(SCR.origin)
|
gc_replaceTransform(SCR.origin)
|
||||||
--Draw power info.
|
--Draw power info.
|
||||||
if SETTING.powerInfo then
|
if SETTING.powerInfo then
|
||||||
gc_setColor(1,1,1)
|
gc_setColor(1,1,1)
|
||||||
gc_draw(infoCanvas,SCR.safeX,0,0,SCR.k)
|
gc_draw(infoCanvas,safeX,0,0,SCR.k)
|
||||||
end
|
end
|
||||||
|
|
||||||
--Draw scene swapping animation
|
--Draw scene swapping animation
|
||||||
@@ -625,16 +629,16 @@ function love.run()
|
|||||||
--Draw FPS
|
--Draw FPS
|
||||||
setFont(15)
|
setFont(15)
|
||||||
gc_setColor(1,1,1)
|
gc_setColor(1,1,1)
|
||||||
gc_print(FPS(),SCR.safeX+5,-20)
|
gc_print(FPS(),safeX+5,-20)
|
||||||
|
|
||||||
--Debug info.
|
--Debug info.
|
||||||
if devMode then
|
if devMode then
|
||||||
--Left-down infos
|
--Left-down infos
|
||||||
gc_setColor(devColor[devMode])
|
gc_setColor(devColor[devMode])
|
||||||
gc_print("MEM "..gcinfo(),SCR.safeX+5,-40)
|
gc_print("MEM "..gcinfo(),safeX+5,-40)
|
||||||
gc_print("Lines "..FREEROW.getCount(),SCR.safeX+5,-60)
|
gc_print("Lines "..FREEROW.getCount(),safeX+5,-60)
|
||||||
gc_print("Tasks "..TASK.getCount(),SCR.safeX+5,-80)
|
gc_print("Tasks "..TASK.getCount(),safeX+5,-80)
|
||||||
gc_print("Voices "..VOC.getQueueCount(),SCR.safeX+5,-100)
|
gc_print("Voices "..VOC.getQueueCount(),safeX+5,-100)
|
||||||
|
|
||||||
--Update & draw frame time
|
--Update & draw frame time
|
||||||
ins(frameTimeList,1,dt)rem(frameTimeList,126)
|
ins(frameTimeList,1,dt)rem(frameTimeList,126)
|
||||||
@@ -680,7 +684,7 @@ function love.run()
|
|||||||
gc_present()
|
gc_present()
|
||||||
|
|
||||||
--SPEED UPUPUP!
|
--SPEED UPUPUP!
|
||||||
if SETTING.cleanCanvas then gc.discard()end
|
if SETTING.cleanCanvas then gc_discard()end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -696,8 +700,12 @@ function love.run()
|
|||||||
end
|
end
|
||||||
|
|
||||||
--Slow devmode
|
--Slow devmode
|
||||||
if devMode==3 then WAIT(.1)
|
if devMode then
|
||||||
elseif devMode==4 then WAIT(.5)
|
if devMode==3 then
|
||||||
|
WAIT(.1)
|
||||||
|
elseif devMode==4 then
|
||||||
|
WAIT(.5)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--Keep 60fps
|
--Keep 60fps
|
||||||
|
|||||||
@@ -488,17 +488,17 @@ do
|
|||||||
list[i][12]=a;list[i][21]=b;list[i][32]=b;list[i][23]=a
|
list[i][12]=a;list[i][21]=b;list[i][32]=b;list[i][23]=a
|
||||||
end
|
end
|
||||||
BRS=TABLE.new(function(P,d,ifpre)
|
BRS=TABLE.new(function(P,d,ifpre)
|
||||||
local cur=P.cur
|
local C=P.cur
|
||||||
local idir=(cur.dir+d)%4
|
local idir=(C.dir+d)%4
|
||||||
local kickList=list[cur.id][cur.dir*10+idir]
|
local kickList=list[C.id][C.dir*10+idir]
|
||||||
local icb=BLOCKS[cur.id][idir]
|
local icb=BLOCKS[C.id][idir]
|
||||||
local isc=SCS[cur.id][idir]
|
local isc=SCS[C.id][idir]
|
||||||
local ix,iy=P.curX+cur.sc[2]-isc[2],P.curY+cur.sc[1]-isc[1]
|
local ix,iy=P.curX+C.sc[2]-isc[2],P.curY+C.sc[1]-isc[1]
|
||||||
local dx,dy=0,0 do
|
local dx,dy=0,0 do
|
||||||
local pressing=P.keyPressing
|
local pressing=P.keyPressing
|
||||||
if pressing[1]and P:ifoverlap(cur.bk,P.curX-1,P.curY)then dx=dx-1 end
|
if pressing[1]and P:ifoverlap(C.bk,P.curX-1,P.curY)then dx=dx-1 end
|
||||||
if pressing[2]and P:ifoverlap(cur.bk,P.curX+1,P.curY)then dx=dx+1 end
|
if pressing[2]and P:ifoverlap(C.bk,P.curX+1,P.curY)then dx=dx+1 end
|
||||||
if pressing[7]and P:ifoverlap(cur.bk,P.curX,P.curY-1)then dy=-1 end
|
if pressing[7]and P:ifoverlap(C.bk,P.curX,P.curY-1)then dy=-1 end
|
||||||
end
|
end
|
||||||
while true do
|
while true do
|
||||||
for test=1,#kickList do
|
for test=1,#kickList do
|
||||||
@@ -514,8 +514,8 @@ do
|
|||||||
if P.gameEnv.moveFX and P.gameEnv.block then
|
if P.gameEnv.moveFX and P.gameEnv.block then
|
||||||
P:createMoveFX()
|
P:createMoveFX()
|
||||||
end
|
end
|
||||||
P.curX,P.curY,cur.dir=x,y,idir
|
P.curX,P.curY,C.dir=x,y,idir
|
||||||
cur.sc,cur.bk=isc,icb
|
C.sc,C.bk=isc,icb
|
||||||
P.spinLast=test==2 and 0 or 1
|
P.spinLast=test==2 and 0 or 1
|
||||||
|
|
||||||
local t=P.freshTime
|
local t=P.freshTime
|
||||||
|
|||||||
@@ -547,8 +547,9 @@ function draw.drawNext_norm(P)
|
|||||||
gc_push('transform')
|
gc_push('transform')
|
||||||
gc_translate(62,40)
|
gc_translate(62,40)
|
||||||
gc_setShader(shader_blockSatur)
|
gc_setShader(shader_blockSatur)
|
||||||
while N<=ENV.nextCount and P.nextQueue[N]do
|
local queue=P.nextQueue
|
||||||
local bk,sprite=P.nextQueue[N].bk,texture[P.nextQueue[N].color]
|
while N<=ENV.nextCount and queue[N]do
|
||||||
|
local bk,sprite=queue[N].bk,texture[queue[N].color]
|
||||||
local k=#bk>2 and 2.2/#bk or 1
|
local k=#bk>2 and 2.2/#bk or 1
|
||||||
gc_scale(k)
|
gc_scale(k)
|
||||||
for i=1,#bk do for j=1,#bk[1]do
|
for i=1,#bk do for j=1,#bk[1]do
|
||||||
@@ -678,18 +679,19 @@ function draw.norm(P)
|
|||||||
|
|
||||||
--Draw current block
|
--Draw current block
|
||||||
if P.cur and P.waiting==-1 then
|
if P.cur and P.waiting==-1 then
|
||||||
local curColor=P.cur.color
|
local C=P.cur
|
||||||
|
local curColor=C.color
|
||||||
|
|
||||||
local trans=P.lockDelay/ENV.lock
|
local trans=P.lockDelay/ENV.lock
|
||||||
local centerX=30*(P.curX+P.cur.sc[2])-15
|
local centerX=30*(P.curX+C.sc[2])-15
|
||||||
|
|
||||||
--Draw ghost & rotation center
|
--Draw ghost & rotation center
|
||||||
local centerDisp=ENV.center and P.RS.centerDisp[P.cur.id]
|
local centerDisp=ENV.center and P.RS.centerDisp[C.id]
|
||||||
if ENV.ghost then
|
if ENV.ghost then
|
||||||
drawGhost[ENV.ghostType](P,curColor,ENV.ghost)
|
drawGhost[ENV.ghostType](P,curColor,ENV.ghost)
|
||||||
if centerDisp then
|
if centerDisp then
|
||||||
gc_setColor(1,1,1,ENV.center)
|
gc_setColor(1,1,1,ENV.center)
|
||||||
gc_draw(spinCenterImg,centerX,-30*(P.ghoY+P.cur.sc[1])+15,nil,nil,nil,4,4)
|
gc_draw(spinCenterImg,centerX,-30*(P.ghoY+C.sc[1])+15,nil,nil,nil,4,4)
|
||||||
end
|
end
|
||||||
elseif GAME.replaying then
|
elseif GAME.replaying then
|
||||||
drawGhost.gray(P,nil,.15)
|
drawGhost.gray(P,nil,.15)
|
||||||
@@ -703,7 +705,7 @@ function draw.norm(P)
|
|||||||
drawBlock(P,curColor)
|
drawBlock(P,curColor)
|
||||||
if centerDisp then
|
if centerDisp then
|
||||||
gc_setColor(1,1,1,ENV.center)
|
gc_setColor(1,1,1,ENV.center)
|
||||||
gc_draw(spinCenterImg,centerX,-30*(P.curY+P.cur.sc[1])+15,nil,nil,nil,4,4)
|
gc_draw(spinCenterImg,centerX,-30*(P.curY+C.sc[1])+15,nil,nil,nil,4,4)
|
||||||
end
|
end
|
||||||
elseif GAME.replaying then
|
elseif GAME.replaying then
|
||||||
drawBlockShade(P,trans*.3)
|
drawBlockShade(P,trans*.3)
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ return STRING.split([=[
|
|||||||
代码:
|
代码:
|
||||||
重构WS模块,可能解决部分联网游戏中的概率thread error问题
|
重构WS模块,可能解决部分联网游戏中的概率thread error问题
|
||||||
升级BGM/IMG/SKIN模块,资源不再需要启动时加载好,提升加载速度节约资源占用
|
升级BGM/IMG/SKIN模块,资源不再需要启动时加载好,提升加载速度节约资源占用
|
||||||
|
优化游戏场景性能,移除回放按钮hideF函数
|
||||||
|
主循环略微优化
|
||||||
修复:
|
修复:
|
||||||
只有屏幕宽度异常时自动刷新窗口尺寸 #120
|
只有屏幕宽度异常时自动刷新窗口尺寸 #120
|
||||||
20G不会禁用各种软降n格键
|
20G不会禁用各种软降n格键
|
||||||
@@ -70,7 +72,7 @@ return STRING.split([=[
|
|||||||
触屏设置在窗口非默认长宽比时边缘网格缺失
|
触屏设置在窗口非默认长宽比时边缘网格缺失
|
||||||
有屏幕滚动的场景鼠标拖动时控件失焦
|
有屏幕滚动的场景鼠标拖动时控件失焦
|
||||||
导入设置(包括剪切板和云存档)时部分设置不生效
|
导入设置(包括剪切板和云存档)时部分设置不生效
|
||||||
小程序cubefield的碰撞判定移出draw,解决低绘制帧率导致漏判定的问题 #138
|
小程序cubefield的碰撞判定移出draw,解决低绘制帧率导致漏判定的问题 #138
|
||||||
序列和任务超长导致渲染开销太大卡死 #137
|
序列和任务超长导致渲染开销太大卡死 #137
|
||||||
|
|
||||||
0.15.6: 强化装甲 Reinforced Armor
|
0.15.6: 强化装甲 Reinforced Armor
|
||||||
|
|||||||
Reference in New Issue
Block a user