修正几处变量泄漏到全局,整理代码,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]
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
title={
|
do--title
|
||||||
|
title={
|
||||||
{
|
{
|
||||||
53, 60,
|
53, 60,
|
||||||
1035, 0,
|
1035, 0,
|
||||||
@@ -112,13 +113,13 @@ title={
|
|||||||
6199, 465,
|
6199, 465,
|
||||||
5878, 463,
|
5878, 463,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
for _,C in next,title do
|
for _,C in next,title do
|
||||||
for i=1,#C do
|
for i=1,#C do
|
||||||
C[i]=C[i]*.1626
|
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