freeRow模块改名line模块并暂时在“行”的管理上不再那么节约地使用内存
This commit is contained in:
@@ -622,9 +622,8 @@ function love.run()
|
||||
--Left-down infos
|
||||
gc_setColor(devColor[devMode])
|
||||
gc_print("MEM "..gcinfo(),safeX+5,-40)
|
||||
gc_print("Lines "..FREEROW.getCount(),safeX+5,-60)
|
||||
gc_print("Tasks "..TASK.getCount(),safeX+5,-80)
|
||||
gc_print("Voices "..VOC.getQueueCount(),safeX+5,-100)
|
||||
gc_print("Tasks "..TASK.getCount(),safeX+5,-60)
|
||||
gc_print("Voices "..VOC.getQueueCount(),safeX+5,-80)
|
||||
|
||||
--Update & draw frame time
|
||||
table.insert(frameTimeList,1,dt)table.remove(frameTimeList,126)
|
||||
|
||||
2
main.lua
2
main.lua
@@ -90,7 +90,7 @@ for _,v in next,fs.getDirectoryItems('parts/shaders')do
|
||||
end
|
||||
end
|
||||
|
||||
FREEROW= require'parts.freeRow'
|
||||
LINE= require'parts.line'
|
||||
DATA= require'parts.data'
|
||||
|
||||
TEXTURE= require'parts.texture'
|
||||
|
||||
@@ -44,8 +44,7 @@ local function _ifoverlapAI(f,bk,x,y)
|
||||
end
|
||||
end end
|
||||
end
|
||||
local discardRow=FREEROW.discard
|
||||
local getRow=FREEROW.get
|
||||
local getRow,discardRow=LINE.new,LINE.discard
|
||||
local function _resetField(f0,f,start)
|
||||
for _=#f,start,-1 do
|
||||
discardRow(f[_])
|
||||
|
||||
@@ -11,8 +11,8 @@ return{
|
||||
task=function(P)
|
||||
local F=P.field
|
||||
for i=1,24 do
|
||||
F[i]=FREEROW.get(20)
|
||||
P.visTime[i]=FREEROW.get(20)
|
||||
F[i]=LINE.new(20)
|
||||
P.visTime[i]=LINE.new(20)
|
||||
for x=4,7 do F[i][x]=0 end
|
||||
end
|
||||
if P.holeRND:random()<.6 then
|
||||
|
||||
@@ -3,8 +3,8 @@ return{
|
||||
if P.lastPiece.row>0 then
|
||||
for _=1,#P.clearedRow do
|
||||
local h=#P.field
|
||||
P.field[h+1]=FREEROW.get(20)
|
||||
P.visTime[h+1]=FREEROW.get(20)
|
||||
P.field[h+1]=LINE.new(20)
|
||||
P.visTime[h+1]=LINE.new(20)
|
||||
for i=4,7 do P.field[h+1][i]=0 end
|
||||
end
|
||||
if P.combo>P.modeData.maxCombo then
|
||||
|
||||
@@ -5,8 +5,8 @@ return{
|
||||
else
|
||||
for _=1,P.lastPiece.row do
|
||||
local h=#P.field
|
||||
P.field[h+1]=FREEROW.get(20)
|
||||
P.visTime[h+1]=FREEROW.get(20)
|
||||
P.field[h+1]=LINE.new(20)
|
||||
P.visTime[h+1]=LINE.new(20)
|
||||
for i=4,7 do P.field[h+1][i]=0 end
|
||||
end
|
||||
if P.combo>P.modeData.maxCombo then
|
||||
|
||||
@@ -6,8 +6,6 @@ return{
|
||||
if FIELD[D.finished+1]then
|
||||
P.waiting=26
|
||||
for i=#P.field,1,-1 do
|
||||
FREEROW.discard(P.field[i])
|
||||
FREEROW.discard(P.visTime[i])
|
||||
P.field[i],P.visTime[i]=nil
|
||||
end
|
||||
setField(P,D.finished+1)
|
||||
|
||||
@@ -55,8 +55,8 @@ return
|
||||
P.field[i][P.holeRND:random(10)]=0
|
||||
end
|
||||
else
|
||||
P.field[i]=FREEROW.get(0)
|
||||
P.visTime[i]=FREEROW.get(30)
|
||||
P.field[i]=LINE.new(0)
|
||||
P.visTime[i]=LINE.new(30)
|
||||
for j=1,10 do
|
||||
if P.holeRND:random()>.9 then
|
||||
P.field[i][j]=P.holeRND:random(16)
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
local FREEROW={}
|
||||
local L={}--Storage
|
||||
local len=0--Length
|
||||
function FREEROW.reset(num)
|
||||
if num<len then
|
||||
for i=len,num+1,-1 do
|
||||
L[i]=nil
|
||||
end
|
||||
elseif num>len then
|
||||
for i=len+1,num do
|
||||
L[i]={0,0,0,0,0,0,0,0,0,0,garbage=false}
|
||||
end
|
||||
end
|
||||
len=num
|
||||
end
|
||||
function FREEROW.get(val,ifGarbage)
|
||||
if len==0 then
|
||||
for i=1,10 do
|
||||
L[i]={0,0,0,0,0,0,0,0,0,0,garbage=false}
|
||||
end
|
||||
len=len+10
|
||||
end
|
||||
local t=L[len]
|
||||
for i=1,10 do t[i]=val end
|
||||
t.garbage=ifGarbage==true
|
||||
L[len]=nil
|
||||
len=len-1
|
||||
return t
|
||||
end
|
||||
function FREEROW.discard(t)
|
||||
len=len+1
|
||||
L[len]=t
|
||||
end
|
||||
function FREEROW.getCount()
|
||||
return len
|
||||
end
|
||||
return FREEROW
|
||||
@@ -257,8 +257,8 @@ function setField(P,page)
|
||||
local t=P.showTime*3
|
||||
for y=1,height do
|
||||
local notEmpty=notEmptyLine(F[y])
|
||||
P.field[y]=FREEROW.get(0,notEmpty)
|
||||
P.visTime[y]=FREEROW.get(t)
|
||||
P.field[y]=LINE.new(0,notEmpty)
|
||||
P.visTime[y]=LINE.new(t)
|
||||
if notEmpty then
|
||||
for x=1,10 do
|
||||
P.field[y][x]=F[y][x]
|
||||
@@ -331,8 +331,8 @@ function destroyPlayers()--Destroy all player objects, restore freerows and free
|
||||
P.canvas:release()
|
||||
end
|
||||
while P.field[1]do
|
||||
FREEROW.discard(rem(P.field))
|
||||
FREEROW.discard(rem(P.visTime))
|
||||
rem(P.field)
|
||||
rem(P.visTime)
|
||||
end
|
||||
end
|
||||
TABLE.cut(PLAYERS)
|
||||
@@ -668,7 +668,6 @@ do--function resetGameData(args)
|
||||
GAME.secDangerous=false
|
||||
GAME.stage=1
|
||||
end
|
||||
FREEROW.reset(30*#PLAYERS)
|
||||
TASK.removeTask_code(task_showMods)
|
||||
if GAME.setting.allowMod then
|
||||
TASK.new(task_showMods)
|
||||
|
||||
22
parts/line.lua
Normal file
22
parts/line.lua
Normal file
@@ -0,0 +1,22 @@
|
||||
local LINE={}
|
||||
local L={}--Storage
|
||||
local len=0--Length
|
||||
function LINE.new(val,isGarbage)
|
||||
if len==0 then
|
||||
for i=1,10 do
|
||||
L[i]={0,0,0,0,0,0,0,0,0,0,garbage=false}
|
||||
end
|
||||
len=len+10
|
||||
end
|
||||
local t=L[len]
|
||||
for i=1,10 do t[i]=val end
|
||||
t.garbage=isGarbage==true
|
||||
L[len]=nil
|
||||
len=len-1
|
||||
return t
|
||||
end
|
||||
function LINE.discard(t)
|
||||
len=len+1
|
||||
L[len]=t
|
||||
end
|
||||
return LINE
|
||||
@@ -24,8 +24,6 @@ return{
|
||||
if FIELD[D.finished+1]then
|
||||
P.waiting=26
|
||||
for _=#P.field,1,-1 do
|
||||
FREEROW.discard(P.field[_])
|
||||
FREEROW.discard(P.visTime[_])
|
||||
P.field[_],P.visTime[_]=nil
|
||||
end
|
||||
SYSFX.newShade(1.4,P.absFieldX,P.absFieldY,300*P.size,610*P.size,.3,1,.3)
|
||||
|
||||
@@ -8,7 +8,7 @@ return{
|
||||
while true do
|
||||
YIELD()
|
||||
if not P.nextQueue[1]then
|
||||
local height=FREEROW.get(0)
|
||||
local height=TABLE.new(0,10)
|
||||
local max=#P.field
|
||||
if max>0 then
|
||||
--Get heights
|
||||
@@ -69,8 +69,6 @@ return{
|
||||
for _=1,4 do ins(wei,5)end
|
||||
end
|
||||
end
|
||||
|
||||
FREEROW.discard(height)
|
||||
P:getNext(wei[P.seqRND:random(#wei)])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -10,7 +10,7 @@ local assert,ins,rem=assert,table.insert,table.remove
|
||||
local resume,yield,status=coroutine.resume,coroutine.yield,coroutine.status
|
||||
|
||||
local SFX,BGM,VOC,VIB,SYSFX=SFX,BGM,VOC,VIB,SYSFX
|
||||
local FREEROW,TABLE,TEXT,TASK=FREEROW,TABLE,TEXT,TASK
|
||||
local FREEROW,TABLE,TEXT,TASK=LINE,TABLE,TEXT,TASK
|
||||
local PLAYERS,PLY_ALIVE,GAME=PLAYERS,PLY_ALIVE,GAME
|
||||
|
||||
local SETTING=SETTING
|
||||
@@ -354,8 +354,8 @@ function Player:garbageRise(color,amount,line)--Release n-lines garbage to field
|
||||
local _
|
||||
local t=self.showTime*2
|
||||
for _=1,amount do
|
||||
ins(self.field,1,FREEROW.get(0,true))
|
||||
ins(self.visTime,1,FREEROW.get(t))
|
||||
ins(self.field,1,FREEROW.new(0,true))
|
||||
ins(self.visTime,1,FREEROW.new(t))
|
||||
for i=1,10 do
|
||||
self.field[1][i]=bit.rshift(line,i-1)%2==1 and color or 0
|
||||
end
|
||||
@@ -388,7 +388,7 @@ function Player:pushLineList(L,mir)--Push some lines to field
|
||||
local l=#L
|
||||
local S=self.gameEnv.skin
|
||||
for i=1,l do
|
||||
local r=FREEROW.get(0)
|
||||
local r=FREEROW.new(0)
|
||||
if not mir then
|
||||
for j=1,10 do
|
||||
r[j]=S[L[i][j]]or 0
|
||||
@@ -399,7 +399,7 @@ function Player:pushLineList(L,mir)--Push some lines to field
|
||||
end
|
||||
end
|
||||
ins(self.field,1,r)
|
||||
ins(self.visTime,1,FREEROW.get(20))
|
||||
ins(self.visTime,1,FREEROW.new(20))
|
||||
end
|
||||
self.fieldBeneath=self.fieldBeneath+30*l
|
||||
self.curY=self.curY+l
|
||||
@@ -636,8 +636,8 @@ function Player:lock()
|
||||
for i=1,#CB do
|
||||
local y=self.curY+i-1
|
||||
if not self.field[y]then
|
||||
self.field[y]=FREEROW.get(0)
|
||||
self.visTime[y]=FREEROW.get(0)
|
||||
self.field[y]=FREEROW.new(0)
|
||||
self.visTime[y]=FREEROW.new(0)
|
||||
end
|
||||
for j=1,#CB[1]do
|
||||
if CB[i][j]then
|
||||
|
||||
Reference in New Issue
Block a user