整理代码,Zframework添加数学扩展模块
This commit is contained in:
@@ -4,6 +4,7 @@ LOADED=false
|
|||||||
ERRDATA={}
|
ERRDATA={}
|
||||||
|
|
||||||
--Pure lua modules (basic)
|
--Pure lua modules (basic)
|
||||||
|
MATH= require'Zframework.mathExtend'
|
||||||
COLOR= require'Zframework.color'
|
COLOR= require'Zframework.color'
|
||||||
TABLE= require'Zframework.tableExtend'
|
TABLE= require'Zframework.tableExtend'
|
||||||
STRING= require'Zframework.stringExtend'
|
STRING= require'Zframework.stringExtend'
|
||||||
|
|||||||
19
Zframework/mathExtend.lua
Normal file
19
Zframework/mathExtend.lua
Normal file
@@ -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
|
||||||
@@ -231,13 +231,6 @@ end
|
|||||||
function getItem(itemName,amount)
|
function getItem(itemName,amount)
|
||||||
STAT.item[itemName]=STAT.item[itemName]+(amount or 1)
|
STAT.item[itemName]=STAT.item[itemName]+(amount or 1)
|
||||||
end
|
end
|
||||||
function coin(a,b)
|
|
||||||
if rnd()<.5 then
|
|
||||||
return a
|
|
||||||
else
|
|
||||||
return b
|
|
||||||
end
|
|
||||||
end
|
|
||||||
function generateLine(hole)
|
function generateLine(hole)
|
||||||
return 1023-2^(hole-1)
|
return 1023-2^(hole-1)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ local setFont,mStr=FONT.set,GC.mStr
|
|||||||
local int,rnd,abs=math.floor,math.random,math.abs
|
local int,rnd,abs=math.floor,math.random,math.abs
|
||||||
local max,min=math.max,math.min
|
local max,min=math.max,math.min
|
||||||
local ins,rem=table.insert,table.remove
|
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={
|
local levels={
|
||||||
{c=6,r=3,color=3},
|
{c=6,r=3,color=3},
|
||||||
@@ -289,7 +288,7 @@ function scene.update(dt)
|
|||||||
if state==1 then
|
if state==1 then
|
||||||
time=TIME()-startTime
|
time=TIME()-startTime
|
||||||
comboTime=max(comboTime-dt,0)
|
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
|
end
|
||||||
|
|
||||||
if sure>0 then sure=sure-dt end
|
if sure>0 then sure=sure-dt end
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ function scene.sceneInit()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function scene.touchDown(x,y,k)
|
function scene.touchDown(x,y,k)
|
||||||
|
--TODO
|
||||||
end
|
end
|
||||||
scene.mouseDown=scene.touchDown
|
scene.mouseDown=scene.touchDown
|
||||||
|
|
||||||
@@ -41,10 +41,6 @@ function scene.keyDown(key,isRep)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function scene.update(dt)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function scene.draw()
|
function scene.draw()
|
||||||
setFont(30)
|
setFont(30)
|
||||||
gc.print(inst,40,60)
|
gc.print(inst,40,60)
|
||||||
@@ -52,6 +48,6 @@ function scene.draw()
|
|||||||
end
|
end
|
||||||
|
|
||||||
scene.widgetList={
|
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
|
return scene
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ local widgetX0={
|
|||||||
}
|
}
|
||||||
local enterConsole=coroutine.wrap(function()
|
local enterConsole=coroutine.wrap(function()
|
||||||
while true do
|
while true do
|
||||||
Snd('bell',.6,'A4',.7,'E5',1,coin('A5','B5'))YIELD()
|
Snd('bell',.6,'A4',.7,'E5',1,MATH.coin('A5','B5'))YIELD()
|
||||||
Snd('bell',.6,'A4',.7,'F5',1,coin('C6','D6'))YIELD()
|
Snd('bell',.6,'A4',.7,'F5',1,MATH.coin('C6','D6'))YIELD()
|
||||||
Snd('bell',.6,'A4',.7,'G5',1,coin('E6','G6'))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()
|
Snd('bell',.6,'A4',.7,'A5',1,'A6')SFX.play('ren_mega')SCN.go('app_console')YIELD()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user