修正几处变量泄漏到全局,整理代码,main开头添加一点代码习惯说明

This commit is contained in:
MrZ626
2021-05-10 15:13:45 +08:00
parent 297ccf4496
commit 8571b020b9
6 changed files with 138 additions and 137 deletions

View File

@@ -95,7 +95,7 @@ do--function TABLE.dump(L,t)
"\t\t\t\t",
"\t\t\t\t\t",
}
function dump(L,t)
local function dump(L,t)
local s
if t then
s="{\n"

View File

@@ -5,7 +5,13 @@
/ / / __// /__ / / / // / / / / // // / / // /_/ /
/_/ \___/ \___//_/ /_//_/ /_/ /_//_//_/ /_/ \____/
Techmino is my first "huge project"
optimization is welcomed if you also love tetromino game
optimization is welcomed if you also love tetromino stacking game
Instructions:
1. I made a framework called Zframework, most code in Zframework are directly relevant to game;
2. "xxx" are texts for reading, 'xxx' are string values in program;
3. Some goto statement are used for better performance. All goto-labes have detailed names so don't afraid;
4. Except "gcinfo" function of lua, other "gc" are short for "graphics";
]]--

View File

@@ -101,17 +101,17 @@ local FCL={
{{11,4},{11,3},{1,4},{4},{3},{2,3},{2,2,3},{12,4},{12,3}},
},
[3]={
{{11},{11,2},{1},{},{2},{2,2},{12,1},{12},},
{{3,11},{11,3},{11,2,3},{1,3},{3},{2,3},{2,2,3},{12,1,3},{12,3},},
{{11,5},{11,2,5},{1,5},{5},{2,5},{2,2,5},{12,1,5},{12,5},},
{{11,4},{11,2,4},{1,4},{4},{2,4},{2,2,4},{12,1,4},{12,4},{4,12},},
{{11},{11,2},{1},{},{2},{2,2},{12,1},{12}},
{{3,11},{11,3},{11,2,3},{1,3},{3},{2,3},{2,2,3},{12,1,3},{12,3}},
{{11,5},{11,2,5},{1,5},{5},{2,5},{2,2,5},{12,1,5},{12,5}},
{{11,4},{11,2,4},{1,4},{4},{2,4},{2,2,4},{12,1,4},{12,4},{4,12}},
},
[6]={
{{11},{11,2},{1,1},{1},{},{2},{2,2},{12,1},{12},},
{{11},{11,2},{1,1},{1},{},{2},{2,2},{12,1},{12}},
},
[7]={
{{11},{11,2},{1},{},{2},{12,1},{12},},
{{4,11},{11,4},{11,3},{1,4},{4},{3},{2,3},{12,4},{12,3},{3,12},},
{{11},{11,2},{1},{},{2},{12,1},{12}},
{{4,11},{11,4},{11,3},{1,4},{4},{3},{2,3},{12,4},{12,3},{3,12}},
},
}FCL[2],FCL[4],FCL[5]=FCL[1],FCL[3],FCL[3]
local LclearScore={[0]=0,-200,-120,-80,200}
@@ -199,6 +199,8 @@ local function getScore(field,cb,cy)
return score
end
-------------------------------------------------
local BLOCKS=BLOCKS
local CC=CC
return{
['9S']=function(P,keys)
while true do

View File

@@ -374,11 +374,10 @@ do--function dumpBasicConfig()
end
end
do--function resetGameData(args)
local yield=YIELD
local function tick_showMods()
local time=0
while true do
yield()
YIELD()
time=time+1
if time%20==0 then
local M=GAME.mod[time/20]

View File

@@ -1,124 +1,125 @@
title={
{
53, 60,
1035, 0,
964, 218,
660, 218,
391, 1300,
231, 1154,
415, 218,
0, 218,
},
{
716, 290,
1429, 290,
1312, 462,
875, 489,
821, 695,
1148, 712,
1017, 902,
761, 924,
707, 1127,
1106, 1101,
1198, 1300,
465, 1300,
},
{
1516, 287,
2102, 290,
2036, 464,
1598, 465,
1322, 905,
1395, 1102,
1819, 1064,
1743, 1280,
1286, 1310,
1106, 902,
},
{
2179, 290,
2411, 290,
2272, 688,
2674, 666,
2801, 290,
3041, 290,
2693, 1280,
2464, 1280,
2601, 879,
2199, 897,
2056, 1280,
1828, 1280,
},
{
3123, 290,
3480, 290,
3496, 480,
3664, 290,
4017, 294,
3682, 1280,
3453, 1280,
3697, 578,
3458, 843,
3304, 842,
3251, 561,
3001, 1280,
2779, 1280,
},
{
4088, 290,
4677, 290,
4599, 501,
4426, 502,
4219, 1069,
4388, 1070,
4317, 1280,
3753, 1280,
3822, 1068,
3978, 1068,
4194, 504,
4016, 504,
},
{
4747, 290,
4978, 295,
4921, 464,
5186, 850,
5366, 290,
5599, 295,
5288, 1280,
5051, 1280,
5106, 1102,
4836, 709,
4641, 1280,
4406, 1280,
},
{
5814, 290,
6370, 295,
6471, 415,
6238, 1156,
6058, 1280,
5507, 1280,
5404, 1154,
5635, 416,
-- 5814, 290,
-- 5878, 463,
5770, 542,
5617, 1030,
5676, 1105,
5995, 1106,
6100, 1029,
6255, 541,
6199, 465,
5878, 463,
},
}
for _,C in next,title do
for i=1,#C do
C[i]=C[i]*.1626
do--title
title={
{
53, 60,
1035, 0,
964, 218,
660, 218,
391, 1300,
231, 1154,
415, 218,
0, 218,
},
{
716, 290,
1429, 290,
1312, 462,
875, 489,
821, 695,
1148, 712,
1017, 902,
761, 924,
707, 1127,
1106, 1101,
1198, 1300,
465, 1300,
},
{
1516, 287,
2102, 290,
2036, 464,
1598, 465,
1322, 905,
1395, 1102,
1819, 1064,
1743, 1280,
1286, 1310,
1106, 902,
},
{
2179, 290,
2411, 290,
2272, 688,
2674, 666,
2801, 290,
3041, 290,
2693, 1280,
2464, 1280,
2601, 879,
2199, 897,
2056, 1280,
1828, 1280,
},
{
3123, 290,
3480, 290,
3496, 480,
3664, 290,
4017, 294,
3682, 1280,
3453, 1280,
3697, 578,
3458, 843,
3304, 842,
3251, 561,
3001, 1280,
2779, 1280,
},
{
4088, 290,
4677, 290,
4599, 501,
4426, 502,
4219, 1069,
4388, 1070,
4317, 1280,
3753, 1280,
3822, 1068,
3978, 1068,
4194, 504,
4016, 504,
},
{
4747, 290,
4978, 295,
4921, 464,
5186, 850,
5366, 290,
5599, 295,
5288, 1280,
5051, 1280,
5106, 1102,
4836, 709,
4641, 1280,
4406, 1280,
},
{
5814, 290,
6370, 295,
6471, 415,
6238, 1156,
6058, 1280,
5507, 1280,
5404, 1154,
5635, 416,
-- 5814, 290,
-- 5878, 463,
5770, 542,
5617, 1030,
5676, 1105,
5995, 1106,
6100, 1029,
6255, 541,
6199, 465,
5878, 463,
},
}
for _,C in next,title do
for i=1,#C do
C[i]=C[i]*.1626
end
end
end
do--title_fan
title_fan={}
local sin,cos=math.sin,math.cos
@@ -136,7 +137,6 @@ do--title_fan
end
end
end
do--missionEnum
missionEnum={
_1=01,_2=02,_3=03,_4=04,
@@ -154,7 +154,6 @@ do--missionEnum
for k,v in next,missionEnum do L[v]=k end
for k,v in next,L do missionEnum[k]=v end
end
do--drawableText
local function T(s,t)return love.graphics.newText(getFont(s),t)end
drawableText={
@@ -181,7 +180,6 @@ do--drawableText
noScore=T(45),highScore=T(30),
}
end
do--BLOCKS
local O,_=true,false
BLOCKS={
@@ -244,7 +242,6 @@ do--BLOCKS
end
end
end
do--SCS(spinCenters)
local N1,N2,N3,N4={0,1},{1,0},{1,1},{.5,.5}
local I1,I2,I3,I4={-.5,1.5},{1.5,-.5},{.5,1.5},{1.5,.5}
@@ -293,7 +290,6 @@ do--SCS(spinCenters)
{[0]=D,D,D,D},--O1
}
end
rankColor={
{.6,.3,.3},
{.7,.5,.3},
@@ -301,7 +297,6 @@ rankColor={
{.6,.9,1},
{.95,.95,.5},
}
minoColor={
COLOR.R,COLOR.F,COLOR.O,COLOR.Y,COLOR.L,COLOR.J,COLOR.G,COLOR.A,
COLOR.C,COLOR.N,COLOR.S,COLOR.B,COLOR.V,COLOR.P,COLOR.M,COLOR.W,

View File

@@ -203,7 +203,6 @@ function scene.sceneInit()
shadePhase1=6.26*math.random()
shadePhase2=6.26*math.random()
skip=0--Skip time
consoleLaunchKey=0
light[6*3],light[26*3]=true,true
kb.setKeyRepeat(false)
end