整理代码,略微提升部分小程序的性能
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
local gc=love.graphics
|
||||
|
||||
local int,rnd=math.floor,math.random
|
||||
local mStr=mStr
|
||||
local mStr=GC.mStr
|
||||
|
||||
local scene={}
|
||||
|
||||
@@ -258,7 +258,7 @@ local backColor={
|
||||
},--Black
|
||||
}
|
||||
function scene.draw()
|
||||
setFont(40)
|
||||
FONT.get(40)
|
||||
gc.setColor(COLOR.Z)
|
||||
gc.print(("%.3f"):format(time),1026,80)
|
||||
gc.setColor(1,.8,.8)
|
||||
@@ -282,7 +282,7 @@ function scene.draw()
|
||||
|
||||
gc.setLineWidth(4)
|
||||
local mono=invis and state==1
|
||||
setFont(80)
|
||||
FONT.get(80)
|
||||
for i=1,4 do
|
||||
for j=1,4 do
|
||||
if cx~=j or cy~=i then
|
||||
|
||||
@@ -4,8 +4,8 @@ local setColor,rectangle=gc.setColor,gc.rectangle
|
||||
local int,abs=math.floor,math.abs
|
||||
local rnd,min=math.random,math.min
|
||||
local ins=table.insert
|
||||
local setFont=setFont
|
||||
local mStr=mStr
|
||||
local setFont=FONT.get
|
||||
local mStr=GC.mStr
|
||||
|
||||
local scene={}
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
local gc=love.graphics
|
||||
local rnd=math.random
|
||||
local mStr=mStr
|
||||
|
||||
local levels={
|
||||
A_Z="ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
||||
@@ -83,7 +82,7 @@ function scene.update()
|
||||
end
|
||||
|
||||
function scene.draw()
|
||||
setFont(40)
|
||||
FONT.get(40)
|
||||
gc.setColor(COLOR.Z)
|
||||
gc.print(("%.3f"):format(time),1026,80)
|
||||
gc.print(mistake,1026,150)
|
||||
@@ -100,15 +99,15 @@ function scene.draw()
|
||||
gc.setColor(.2,.8,.2)--ready
|
||||
end
|
||||
|
||||
setFont(100)
|
||||
mStr(state==1 and #targetString-progress+1 or state==0 and"Ready"or state==2 and"Win",640,200)
|
||||
FONT.get(100)
|
||||
GC.mStr(state==1 and #targetString-progress+1 or state==0 and"Ready"or state==2 and"Win",640,200)
|
||||
|
||||
gc.setColor(COLOR.Z)
|
||||
gc.print(targetString:sub(progress,progress),120,280,0,2)
|
||||
gc.print(targetString:sub(progress+1),310,380)
|
||||
|
||||
gc.setColor(1,1,1,.7)
|
||||
setFont(40)
|
||||
FONT.get(40)
|
||||
gc.print(targetString,120,520)
|
||||
end
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ function scene.draw()
|
||||
|
||||
if gameover then
|
||||
--Draw result
|
||||
setFont(60)
|
||||
FONT.get(60)
|
||||
if gameover==0 then
|
||||
gc.setColor(1,.6,.6)
|
||||
mStr("RED\nWON",1140,200)
|
||||
|
||||
@@ -189,17 +189,17 @@ function scene.update(dt)
|
||||
end
|
||||
end
|
||||
function scene.draw()
|
||||
setFont(35)
|
||||
FONT.get(35)
|
||||
gc.setColor(COLOR.Z)
|
||||
mStr("["..level.."]",640,30)
|
||||
GC.mStr("["..level.."]",640,30)
|
||||
|
||||
setFont(100)
|
||||
FONT.get(100)
|
||||
if type(question)=='table'then gc.setColor(1,1,1)end
|
||||
mStr(question,640,60)
|
||||
GC.mStr(question,640,60)
|
||||
|
||||
setFont(80)
|
||||
FONT.get(80)
|
||||
gc.setColor(1,1,1,inputTime)
|
||||
mStr(input,640,160)
|
||||
GC.mStr(input,640,160)
|
||||
end
|
||||
|
||||
scene.widgetList={
|
||||
|
||||
@@ -114,10 +114,10 @@ function scene.draw()
|
||||
gc.setColor(COLOR.Z)
|
||||
gc.setLineWidth(2)
|
||||
gc.rectangle('line',100,80,650,150,5)
|
||||
setFont(45)
|
||||
FONT.get(45)
|
||||
if reg then gc.printf(reg,0,100,720,'right')end
|
||||
if val then gc.printf(val,0,150,720,'right')end
|
||||
if sym then setFont(50)gc.print(sym,126,150)end
|
||||
if sym then FONT.get(50)gc.print(sym,126,150)end
|
||||
end
|
||||
|
||||
scene.widgetList={
|
||||
|
||||
@@ -103,7 +103,7 @@ function scene.draw()
|
||||
end
|
||||
|
||||
--Info
|
||||
setFont(40)
|
||||
FONT.get(40)
|
||||
if combo>1 then
|
||||
gc.setColor(1,1,.6)
|
||||
gc.print("x"..combo,300,80)
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
local gc=love.graphics
|
||||
local kb=love.keyboard
|
||||
local tc=love.touch
|
||||
|
||||
local gc,kb,tc=love.graphics,love.keyboard,love.touch
|
||||
local rnd,int,abs=math.random,math.floor,math.abs
|
||||
local max,min=math.max,math.min
|
||||
local setFont=setFont
|
||||
local setFont,mStr=FONT.get,GC.mStr
|
||||
|
||||
local cubeColor={
|
||||
{.88,.75,.00},
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
local gc=love.graphics
|
||||
local rnd=math.random
|
||||
local int,max=math.floor,math.max
|
||||
local rnd,int,max=math.random,math.floor,math.max
|
||||
local setFont,mStr=FONT.get,GC.mStr
|
||||
|
||||
--This mini-game is written for TI-nSpire CX CAS many years ago.
|
||||
--Deliberately, some grammar mistakes and typos in the 'great' list remained.
|
||||
--So no need to correct them.
|
||||
|
||||
local perfect={"Perfect!","Excellent!","Nice!","Good!","Great!","Just!","300"}
|
||||
local great={"Pay attention!","Be carefully!","Teacher behind you!","Feel tired?","You are in danger!","Do your homework!","A good game!","Minecraft!","y=ax^2+bx+c!","No music?","Internet unavailable.","It's raining!","Too hard!","Shorter?","Higher!","English messages!","Hi!","^_^","Drop!","Colorful!",":)","100$","~~~wave~~~","★★★","中文!","NOW!!!!!","Also try the TEN!","I'm a programer!","Also try minesweeperZ!","This si Dropper!","Hold your calculatoor!","Look! UFO!","Bonjour!","[string]","Author:MrZ","Boom!","PvZ!","China!","TI-nspire!","I love LUA!"}
|
||||
local miss={"Oops!","Uh-oh","Ouch!","Oh no."}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
local gc=love.graphics
|
||||
local setFont,mStr=FONT.get,GC.mStr
|
||||
|
||||
local int,rnd=math.floor,math.random
|
||||
local ins,rem=table.insert,table.remove
|
||||
|
||||
@@ -2,7 +2,7 @@ local ms=love.mouse
|
||||
local msIsDown,kbIsDown=ms.isDown,love.keyboard.isDown
|
||||
local gc=love.graphics
|
||||
local gc_setColor,gc_rectangle,gc_draw=gc.setColor,gc.rectangle,gc.draw
|
||||
local setFont=setFont
|
||||
local setFont,mStr=FONT.get,GC.mStr
|
||||
|
||||
local int,rnd,abs=math.floor,math.random,math.abs
|
||||
local max,min=math.max,math.min
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
local gc=love.graphics
|
||||
local rnd,sin,cos=math.random,math.sin,math.cos
|
||||
local setFont,mStr=FONT.get,GC.mStr
|
||||
|
||||
local tau=math.pi*2
|
||||
|
||||
local state
|
||||
|
||||
@@ -151,10 +151,10 @@ end
|
||||
|
||||
function scene.draw()
|
||||
--Draw score
|
||||
setFont(100)
|
||||
gc.setColor(.4,.4,.4)
|
||||
mStr(p1.score,470,20)
|
||||
mStr(p2.score,810,20)
|
||||
FONT.get(100)
|
||||
GC.mStr(p1.score,470,20)
|
||||
GC.mStr(p2.score,810,20)
|
||||
|
||||
--Draw boundary
|
||||
gc.setColor(COLOR.Z)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
local gc=love.graphics
|
||||
local rnd=math.random
|
||||
local setFont,mStr=FONT.get,GC.mStr
|
||||
|
||||
local scene={}
|
||||
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
local gc=love.graphics
|
||||
local ms=love.mouse
|
||||
|
||||
local gc,ms=love.graphics,love.mouse
|
||||
local int,rnd=math.floor,math.random
|
||||
local rem=table.remove
|
||||
local setFont=setFont
|
||||
local mStr=mStr
|
||||
local setFont,mStr=FONT.get,GC.mStr
|
||||
|
||||
local scene={}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
local gc=love.graphics
|
||||
local max=math.max
|
||||
local ins=table.insert
|
||||
local mStr=mStr
|
||||
local setFont,mStr=FONT.get,GC.mStr
|
||||
|
||||
local scene={}
|
||||
|
||||
|
||||
@@ -4,11 +4,12 @@ local setColor,rectangle=gc.setColor,gc.rectangle
|
||||
|
||||
local int,rnd=math.floor,math.random
|
||||
local ins,rem=table.insert,table.remove
|
||||
local mStr=mStr
|
||||
local setFont,mStr=FONT.get,GC.mStr
|
||||
|
||||
local scene={}
|
||||
|
||||
local previewX={245,186,129,78,35}
|
||||
local previewY={435,442,449,456,463}
|
||||
local tileColor={
|
||||
{.39, 1.0, .39},
|
||||
{.39, .39, 1.0},
|
||||
@@ -246,7 +247,7 @@ function scene.draw()
|
||||
for i=1,5 do
|
||||
setFont(85-10*i)
|
||||
gc.setColor(tileColor[preview[i]])
|
||||
gc.print(preview[i],previewX[i],428+i*7)
|
||||
gc.print(preview[i],previewX[i],previewY[i])
|
||||
end
|
||||
end
|
||||
|
||||
@@ -257,8 +258,8 @@ function scene.draw()
|
||||
end
|
||||
gc.setLineWidth(10)
|
||||
setColor(COLOR[
|
||||
state==0 and'G'or
|
||||
state==1 and(fast and'R'or'W')or
|
||||
state==0 and'G'or
|
||||
state==2 and'Y'
|
||||
])
|
||||
rectangle('line',315,35,650,650)
|
||||
|
||||
Reference in New Issue
Block a user