From 8571b020b9d36a4d6875c00c921ebffde4e163b3 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Mon, 10 May 2021 15:13:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E5=87=A0=E5=A4=84=E5=8F=98?= =?UTF-8?q?=E9=87=8F=E6=B3=84=E6=BC=8F=E5=88=B0=E5=85=A8=E5=B1=80=EF=BC=8C?= =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81=EF=BC=8Cmain=E5=BC=80?= =?UTF-8?q?=E5=A4=B4=E6=B7=BB=E5=8A=A0=E4=B8=80=E7=82=B9=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E4=B9=A0=E6=83=AF=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/tableExtend.lua | 2 +- main.lua | 8 +- parts/ai.lua | 16 +-- parts/gametoolfunc.lua | 3 +- parts/list.lua | 245 ++++++++++++++++++------------------- parts/scenes/load.lua | 1 - 6 files changed, 138 insertions(+), 137 deletions(-) diff --git a/Zframework/tableExtend.lua b/Zframework/tableExtend.lua index bcc1f7f8..0c876ab0 100644 --- a/Zframework/tableExtend.lua +++ b/Zframework/tableExtend.lua @@ -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" diff --git a/main.lua b/main.lua index 0cc540c7..2cff4615 100644 --- a/main.lua +++ b/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"; ]]-- diff --git a/parts/ai.lua b/parts/ai.lua index 1db6fe6b..b8d56dd2 100644 --- a/parts/ai.lua +++ b/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 diff --git a/parts/gametoolfunc.lua b/parts/gametoolfunc.lua index 102de98a..6a662cf6 100644 --- a/parts/gametoolfunc.lua +++ b/parts/gametoolfunc.lua @@ -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] diff --git a/parts/list.lua b/parts/list.lua index 6aef2e18..6ef68435 100644 --- a/parts/list.lua +++ b/parts/list.lua @@ -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, diff --git a/parts/scenes/load.lua b/parts/scenes/load.lua index 80385e09..bf6d525b 100644 --- a/parts/scenes/load.lua +++ b/parts/scenes/load.lua @@ -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