修正几处变量泄漏到全局,整理代码,main开头添加一点代码习惯说明
This commit is contained in:
@@ -95,7 +95,7 @@ do--function TABLE.dump(L,t)
|
|||||||
"\t\t\t\t",
|
"\t\t\t\t",
|
||||||
"\t\t\t\t\t",
|
"\t\t\t\t\t",
|
||||||
}
|
}
|
||||||
function dump(L,t)
|
local function dump(L,t)
|
||||||
local s
|
local s
|
||||||
if t then
|
if t then
|
||||||
s="{\n"
|
s="{\n"
|
||||||
|
|||||||
8
main.lua
8
main.lua
@@ -5,7 +5,13 @@
|
|||||||
/ / / __// /__ / / / // / / / / // // / / // /_/ /
|
/ / / __// /__ / / / // / / / / // // / / // /_/ /
|
||||||
/_/ \___/ \___//_/ /_//_/ /_/ /_//_//_/ /_/ \____/
|
/_/ \___/ \___//_/ /_//_/ /_/ /_//_//_/ /_/ \____/
|
||||||
Techmino is my first "huge project"
|
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";
|
||||||
]]--
|
]]--
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
16
parts/ai.lua
16
parts/ai.lua
@@ -101,17 +101,17 @@ local FCL={
|
|||||||
{{11,4},{11,3},{1,4},{4},{3},{2,3},{2,2,3},{12,4},{12,3}},
|
{{11,4},{11,3},{1,4},{4},{3},{2,3},{2,2,3},{12,4},{12,3}},
|
||||||
},
|
},
|
||||||
[3]={
|
[3]={
|
||||||
{{11},{11,2},{1},{},{2},{2,2},{12,1},{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},},
|
{{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,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,4},{11,2,4},{1,4},{4},{2,4},{2,2,4},{12,1,4},{12,4},{4,12}},
|
||||||
},
|
},
|
||||||
[6]={
|
[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]={
|
[7]={
|
||||||
{{11},{11,2},{1},{},{2},{12,1},{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},},
|
{{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]
|
}FCL[2],FCL[4],FCL[5]=FCL[1],FCL[3],FCL[3]
|
||||||
local LclearScore={[0]=0,-200,-120,-80,200}
|
local LclearScore={[0]=0,-200,-120,-80,200}
|
||||||
@@ -199,6 +199,8 @@ local function getScore(field,cb,cy)
|
|||||||
return score
|
return score
|
||||||
end
|
end
|
||||||
-------------------------------------------------
|
-------------------------------------------------
|
||||||
|
local BLOCKS=BLOCKS
|
||||||
|
local CC=CC
|
||||||
return{
|
return{
|
||||||
['9S']=function(P,keys)
|
['9S']=function(P,keys)
|
||||||
while true do
|
while true do
|
||||||
|
|||||||
@@ -374,11 +374,10 @@ do--function dumpBasicConfig()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
do--function resetGameData(args)
|
do--function resetGameData(args)
|
||||||
local yield=YIELD
|
|
||||||
local function tick_showMods()
|
local function tick_showMods()
|
||||||
local time=0
|
local time=0
|
||||||
while true do
|
while true do
|
||||||
yield()
|
YIELD()
|
||||||
time=time+1
|
time=time+1
|
||||||
if time%20==0 then
|
if time%20==0 then
|
||||||
local M=GAME.mod[time/20]
|
local M=GAME.mod[time/20]
|
||||||
|
|||||||
245
parts/list.lua
245
parts/list.lua
@@ -1,124 +1,125 @@
|
|||||||
title={
|
do--title
|
||||||
{
|
title={
|
||||||
53, 60,
|
{
|
||||||
1035, 0,
|
53, 60,
|
||||||
964, 218,
|
1035, 0,
|
||||||
660, 218,
|
964, 218,
|
||||||
391, 1300,
|
660, 218,
|
||||||
231, 1154,
|
391, 1300,
|
||||||
415, 218,
|
231, 1154,
|
||||||
0, 218,
|
415, 218,
|
||||||
},
|
0, 218,
|
||||||
{
|
},
|
||||||
716, 290,
|
{
|
||||||
1429, 290,
|
716, 290,
|
||||||
1312, 462,
|
1429, 290,
|
||||||
875, 489,
|
1312, 462,
|
||||||
821, 695,
|
875, 489,
|
||||||
1148, 712,
|
821, 695,
|
||||||
1017, 902,
|
1148, 712,
|
||||||
761, 924,
|
1017, 902,
|
||||||
707, 1127,
|
761, 924,
|
||||||
1106, 1101,
|
707, 1127,
|
||||||
1198, 1300,
|
1106, 1101,
|
||||||
465, 1300,
|
1198, 1300,
|
||||||
},
|
465, 1300,
|
||||||
{
|
},
|
||||||
1516, 287,
|
{
|
||||||
2102, 290,
|
1516, 287,
|
||||||
2036, 464,
|
2102, 290,
|
||||||
1598, 465,
|
2036, 464,
|
||||||
1322, 905,
|
1598, 465,
|
||||||
1395, 1102,
|
1322, 905,
|
||||||
1819, 1064,
|
1395, 1102,
|
||||||
1743, 1280,
|
1819, 1064,
|
||||||
1286, 1310,
|
1743, 1280,
|
||||||
1106, 902,
|
1286, 1310,
|
||||||
},
|
1106, 902,
|
||||||
{
|
},
|
||||||
2179, 290,
|
{
|
||||||
2411, 290,
|
2179, 290,
|
||||||
2272, 688,
|
2411, 290,
|
||||||
2674, 666,
|
2272, 688,
|
||||||
2801, 290,
|
2674, 666,
|
||||||
3041, 290,
|
2801, 290,
|
||||||
2693, 1280,
|
3041, 290,
|
||||||
2464, 1280,
|
2693, 1280,
|
||||||
2601, 879,
|
2464, 1280,
|
||||||
2199, 897,
|
2601, 879,
|
||||||
2056, 1280,
|
2199, 897,
|
||||||
1828, 1280,
|
2056, 1280,
|
||||||
},
|
1828, 1280,
|
||||||
{
|
},
|
||||||
3123, 290,
|
{
|
||||||
3480, 290,
|
3123, 290,
|
||||||
3496, 480,
|
3480, 290,
|
||||||
3664, 290,
|
3496, 480,
|
||||||
4017, 294,
|
3664, 290,
|
||||||
3682, 1280,
|
4017, 294,
|
||||||
3453, 1280,
|
3682, 1280,
|
||||||
3697, 578,
|
3453, 1280,
|
||||||
3458, 843,
|
3697, 578,
|
||||||
3304, 842,
|
3458, 843,
|
||||||
3251, 561,
|
3304, 842,
|
||||||
3001, 1280,
|
3251, 561,
|
||||||
2779, 1280,
|
3001, 1280,
|
||||||
},
|
2779, 1280,
|
||||||
{
|
},
|
||||||
4088, 290,
|
{
|
||||||
4677, 290,
|
4088, 290,
|
||||||
4599, 501,
|
4677, 290,
|
||||||
4426, 502,
|
4599, 501,
|
||||||
4219, 1069,
|
4426, 502,
|
||||||
4388, 1070,
|
4219, 1069,
|
||||||
4317, 1280,
|
4388, 1070,
|
||||||
3753, 1280,
|
4317, 1280,
|
||||||
3822, 1068,
|
3753, 1280,
|
||||||
3978, 1068,
|
3822, 1068,
|
||||||
4194, 504,
|
3978, 1068,
|
||||||
4016, 504,
|
4194, 504,
|
||||||
},
|
4016, 504,
|
||||||
{
|
},
|
||||||
4747, 290,
|
{
|
||||||
4978, 295,
|
4747, 290,
|
||||||
4921, 464,
|
4978, 295,
|
||||||
5186, 850,
|
4921, 464,
|
||||||
5366, 290,
|
5186, 850,
|
||||||
5599, 295,
|
5366, 290,
|
||||||
5288, 1280,
|
5599, 295,
|
||||||
5051, 1280,
|
5288, 1280,
|
||||||
5106, 1102,
|
5051, 1280,
|
||||||
4836, 709,
|
5106, 1102,
|
||||||
4641, 1280,
|
4836, 709,
|
||||||
4406, 1280,
|
4641, 1280,
|
||||||
},
|
4406, 1280,
|
||||||
{
|
},
|
||||||
5814, 290,
|
{
|
||||||
6370, 295,
|
5814, 290,
|
||||||
6471, 415,
|
6370, 295,
|
||||||
6238, 1156,
|
6471, 415,
|
||||||
6058, 1280,
|
6238, 1156,
|
||||||
5507, 1280,
|
6058, 1280,
|
||||||
5404, 1154,
|
5507, 1280,
|
||||||
5635, 416,
|
5404, 1154,
|
||||||
-- 5814, 290,
|
5635, 416,
|
||||||
-- 5878, 463,
|
-- 5814, 290,
|
||||||
5770, 542,
|
-- 5878, 463,
|
||||||
5617, 1030,
|
5770, 542,
|
||||||
5676, 1105,
|
5617, 1030,
|
||||||
5995, 1106,
|
5676, 1105,
|
||||||
6100, 1029,
|
5995, 1106,
|
||||||
6255, 541,
|
6100, 1029,
|
||||||
6199, 465,
|
6255, 541,
|
||||||
5878, 463,
|
6199, 465,
|
||||||
},
|
5878, 463,
|
||||||
}
|
},
|
||||||
for _,C in next,title do
|
}
|
||||||
for i=1,#C do
|
for _,C in next,title do
|
||||||
C[i]=C[i]*.1626
|
for i=1,#C do
|
||||||
|
C[i]=C[i]*.1626
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
do--title_fan
|
do--title_fan
|
||||||
title_fan={}
|
title_fan={}
|
||||||
local sin,cos=math.sin,math.cos
|
local sin,cos=math.sin,math.cos
|
||||||
@@ -136,7 +137,6 @@ do--title_fan
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
do--missionEnum
|
do--missionEnum
|
||||||
missionEnum={
|
missionEnum={
|
||||||
_1=01,_2=02,_3=03,_4=04,
|
_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,missionEnum do L[v]=k end
|
||||||
for k,v in next,L do missionEnum[k]=v end
|
for k,v in next,L do missionEnum[k]=v end
|
||||||
end
|
end
|
||||||
|
|
||||||
do--drawableText
|
do--drawableText
|
||||||
local function T(s,t)return love.graphics.newText(getFont(s),t)end
|
local function T(s,t)return love.graphics.newText(getFont(s),t)end
|
||||||
drawableText={
|
drawableText={
|
||||||
@@ -181,7 +180,6 @@ do--drawableText
|
|||||||
noScore=T(45),highScore=T(30),
|
noScore=T(45),highScore=T(30),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
do--BLOCKS
|
do--BLOCKS
|
||||||
local O,_=true,false
|
local O,_=true,false
|
||||||
BLOCKS={
|
BLOCKS={
|
||||||
@@ -244,7 +242,6 @@ do--BLOCKS
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
do--SCS(spinCenters)
|
do--SCS(spinCenters)
|
||||||
local N1,N2,N3,N4={0,1},{1,0},{1,1},{.5,.5}
|
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}
|
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
|
{[0]=D,D,D,D},--O1
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
rankColor={
|
rankColor={
|
||||||
{.6,.3,.3},
|
{.6,.3,.3},
|
||||||
{.7,.5,.3},
|
{.7,.5,.3},
|
||||||
@@ -301,7 +297,6 @@ rankColor={
|
|||||||
{.6,.9,1},
|
{.6,.9,1},
|
||||||
{.95,.95,.5},
|
{.95,.95,.5},
|
||||||
}
|
}
|
||||||
|
|
||||||
minoColor={
|
minoColor={
|
||||||
COLOR.R,COLOR.F,COLOR.O,COLOR.Y,COLOR.L,COLOR.J,COLOR.G,COLOR.A,
|
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,
|
COLOR.C,COLOR.N,COLOR.S,COLOR.B,COLOR.V,COLOR.P,COLOR.M,COLOR.W,
|
||||||
|
|||||||
@@ -203,7 +203,6 @@ function scene.sceneInit()
|
|||||||
shadePhase1=6.26*math.random()
|
shadePhase1=6.26*math.random()
|
||||||
shadePhase2=6.26*math.random()
|
shadePhase2=6.26*math.random()
|
||||||
skip=0--Skip time
|
skip=0--Skip time
|
||||||
consoleLaunchKey=0
|
|
||||||
light[6*3],light[26*3]=true,true
|
light[6*3],light[26*3]=true,true
|
||||||
kb.setKeyRepeat(false)
|
kb.setKeyRepeat(false)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user