修正几处变量泄漏到全局,整理代码,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",
|
||||
}
|
||||
function dump(L,t)
|
||||
local function dump(L,t)
|
||||
local s
|
||||
if t then
|
||||
s="{\n"
|
||||
|
||||
8
main.lua
8
main.lua
@@ -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";
|
||||
]]--
|
||||
|
||||
|
||||
|
||||
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}},
|
||||
},
|
||||
[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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
do--title
|
||||
title={
|
||||
{
|
||||
53, 60,
|
||||
@@ -118,7 +119,7 @@ for _,C in next,title 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,
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user