From fa0bc3805f0ac1a846e65541ada231ea49d6fb0e Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Mon, 15 Nov 2021 15:46:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81=EF=BC=8CZf?= =?UTF-8?q?ramework=E6=B7=BB=E5=8A=A0=E6=95=B0=E5=AD=A6=E6=89=A9=E5=B1=95?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Zframework/init.lua | 1 + Zframework/mathExtend.lua | 19 +++++++++++++++++++ parts/gameFuncs.lua | 7 ------- parts/scenes/app_link.lua | 3 +-- parts/scenes/app_piano.lua | 8 ++------ parts/scenes/main.lua | 6 +++--- 6 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 Zframework/mathExtend.lua diff --git a/Zframework/init.lua b/Zframework/init.lua index d4e9dd82..23b1726e 100644 --- a/Zframework/init.lua +++ b/Zframework/init.lua @@ -4,6 +4,7 @@ LOADED=false ERRDATA={} --Pure lua modules (basic) +MATH= require'Zframework.mathExtend' COLOR= require'Zframework.color' TABLE= require'Zframework.tableExtend' STRING= require'Zframework.stringExtend' diff --git a/Zframework/mathExtend.lua b/Zframework/mathExtend.lua new file mode 100644 index 00000000..e7d278a0 --- /dev/null +++ b/Zframework/mathExtend.lua @@ -0,0 +1,19 @@ +local MATH={}for k,v in next,math do MATH[k]=v end + +local rnd=math.random + +MATH.tau=2*math.pi + +function MATH.sign(a) + return a>0 and 1 or a<0 and -1 or 0 +end + +function MATH.coin(a,b) + if rnd()<.5 then + return a + else + return b + end +end + +return MATH \ No newline at end of file diff --git a/parts/gameFuncs.lua b/parts/gameFuncs.lua index ce3c1a4a..60e5f268 100644 --- a/parts/gameFuncs.lua +++ b/parts/gameFuncs.lua @@ -231,13 +231,6 @@ end function getItem(itemName,amount) STAT.item[itemName]=STAT.item[itemName]+(amount or 1) end -function coin(a,b) - if rnd()<.5 then - return a - else - return b - end -end function generateLine(hole) return 1023-2^(hole-1) end diff --git a/parts/scenes/app_link.lua b/parts/scenes/app_link.lua index f1a7ff8d..9d7c4608 100644 --- a/parts/scenes/app_link.lua +++ b/parts/scenes/app_link.lua @@ -7,7 +7,6 @@ local setFont,mStr=FONT.set,GC.mStr local int,rnd,abs=math.floor,math.random,math.abs local max,min=math.max,math.min local ins,rem=table.insert,table.remove -local function sign(a)return a>0 and 1 or a<0 and -1 or 0 end local levels={ {c=6,r=3,color=3}, @@ -289,7 +288,7 @@ function scene.update(dt) if state==1 then time=TIME()-startTime comboTime=max(comboTime-dt,0) - score1=score1+sign(score-score1)+int((score-score1)*.1+.5) + score1=score1+MATH.sign(score-score1)+int((score-score1)*.1+.5) end if sure>0 then sure=sure-dt end diff --git a/parts/scenes/app_piano.lua b/parts/scenes/app_piano.lua index 84158faa..460eb247 100644 --- a/parts/scenes/app_piano.lua +++ b/parts/scenes/app_piano.lua @@ -19,7 +19,7 @@ function scene.sceneInit() end function scene.touchDown(x,y,k) - + --TODO end scene.mouseDown=scene.touchDown @@ -41,10 +41,6 @@ function scene.keyDown(key,isRep) end end -function scene.update(dt) - -end - function scene.draw() setFont(30) gc.print(inst,40,60) @@ -52,6 +48,6 @@ function scene.draw() end scene.widgetList={ - WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,fText=CHAR.icon.back,code=backScene}, + WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,font=60,fText=CHAR.icon.back,code=backScene}, } return scene diff --git a/parts/scenes/main.lua b/parts/scenes/main.lua index 45e93b08..6cbc690e 100644 --- a/parts/scenes/main.lua +++ b/parts/scenes/main.lua @@ -14,9 +14,9 @@ local widgetX0={ } local enterConsole=coroutine.wrap(function() while true do - Snd('bell',.6,'A4',.7,'E5',1,coin('A5','B5'))YIELD() - Snd('bell',.6,'A4',.7,'F5',1,coin('C6','D6'))YIELD() - Snd('bell',.6,'A4',.7,'G5',1,coin('E6','G6'))YIELD() + Snd('bell',.6,'A4',.7,'E5',1,MATH.coin('A5','B5'))YIELD() + Snd('bell',.6,'A4',.7,'F5',1,MATH.coin('C6','D6'))YIELD() + Snd('bell',.6,'A4',.7,'G5',1,MATH.coin('E6','G6'))YIELD() Snd('bell',.6,'A4',.7,'A5',1,'A6')SFX.play('ren_mega')SCN.go('app_console')YIELD() end end)