整理代码
This commit is contained in:
@@ -29,7 +29,6 @@ local int,rnd,abs=math.floor,math.random,math.abs
|
||||
local min=math.min
|
||||
local ins,rem=table.insert,table.remove
|
||||
local SCR=SCR
|
||||
local setFont=setFont
|
||||
|
||||
local mx,my,mouseShow=-20,-20,false
|
||||
local touching=nil--First touching ID(userdata)
|
||||
@@ -418,7 +417,7 @@ function love.run()
|
||||
local SCN=SCN
|
||||
local SETTING=SETTING
|
||||
|
||||
local Timer=love.timer.getTime
|
||||
local TIME=love.timer.getTime
|
||||
local STEP,WAIT=love.timer.step,love.timer.sleep
|
||||
local MINI=love.window.isMinimized
|
||||
local PUMP,POLL=love.event.pump,love.event.poll
|
||||
@@ -427,7 +426,7 @@ function love.run()
|
||||
|
||||
local frameTimeList={}
|
||||
|
||||
local lastFrame=Timer()
|
||||
local lastFrame=TIME()
|
||||
local lastFreshPow=lastFrame
|
||||
local FCT=0--Framedraw counter, from 0~99
|
||||
|
||||
@@ -443,9 +442,9 @@ function love.run()
|
||||
return function()
|
||||
local _
|
||||
|
||||
local T=Timer()
|
||||
local dt=T-lastFrame
|
||||
lastFrame=T
|
||||
local t=TIME()
|
||||
local dt=t-lastFrame
|
||||
lastFrame=t
|
||||
|
||||
--EVENT
|
||||
PUMP()
|
||||
@@ -490,11 +489,11 @@ function love.run()
|
||||
|
||||
--Draw cursor
|
||||
if mouseShow then
|
||||
local r=T*.5
|
||||
local r=t*.5
|
||||
local R=int(r)%7+1
|
||||
_=SKIN.libColor[SETTING.skin[R]]
|
||||
gc.setColor(_[1],_[2],_[3],min(1-abs(1-r%1*2),.3))
|
||||
gc.draw(TEXTURE.miniBlock[R],mx,my,T%3.1416*4,20,20,spinCenters[R][0][2]+.5,#BLOCKS[R][0]-spinCenters[R][0][1]-.5)
|
||||
gc.draw(TEXTURE.miniBlock[R],mx,my,t%3.1416*4,20,20,spinCenters[R][0][2]+.5,#BLOCKS[R][0]-spinCenters[R][0][1]-.5)
|
||||
gc.setColor(1,1,1,.5)gc.circle("fill",mx,my,5)
|
||||
gc.setColor(1,1,1)gc.circle("fill",mx,my,3)
|
||||
end
|
||||
@@ -517,8 +516,8 @@ function love.run()
|
||||
--Draw network working
|
||||
if TASK.netTaskCount>0 then
|
||||
setFont(30)
|
||||
gc.setColor(COLOR.rainbow(T*5))
|
||||
gc.print("E",1250,0,.26+.355*math.sin(T*6.26))
|
||||
gc.setColor(COLOR.rainbow(t*5))
|
||||
gc.print("E",SCR.safeW-18,17,.26+.355*math.sin(t*6.26),nil,nil,8,20)
|
||||
end
|
||||
|
||||
--Draw FPS
|
||||
@@ -552,10 +551,10 @@ function love.run()
|
||||
end
|
||||
|
||||
--Fresh power info.
|
||||
if Timer()-lastFreshPow>2.6 then
|
||||
if TIME()-lastFreshPow>2.6 then
|
||||
if SETTING.powerInfo and LOADED then
|
||||
updatePowerInfo()
|
||||
lastFreshPow=Timer()
|
||||
lastFreshPow=TIME()
|
||||
end
|
||||
if gc.getWidth()~=SCR.w then
|
||||
love.resize(gc.getWidth(),gc.getHeight())
|
||||
@@ -563,8 +562,8 @@ function love.run()
|
||||
end
|
||||
|
||||
--Keep 60fps
|
||||
_=Timer()-lastFrame
|
||||
_=TIME()-lastFrame
|
||||
if _<.016 then WAIT(.016-_)end
|
||||
while Timer()-lastFrame<1/60-5e-6 do WAIT(0)end
|
||||
while TIME()-lastFrame<1/60-5e-6 do WAIT(0)end
|
||||
end
|
||||
end
|
||||
@@ -1,10 +1,9 @@
|
||||
local gc=love.graphics
|
||||
local kb=love.keyboard
|
||||
|
||||
local int,abs=math.floor,math.abs
|
||||
local max,min=math.max,math.min
|
||||
local sub,format=string.sub,string.format
|
||||
|
||||
local Timer=love.timer.getTime
|
||||
local setFont,mStr=setFont,mStr
|
||||
|
||||
local WIDGET={}
|
||||
@@ -463,8 +462,8 @@ function slider:drag(x)
|
||||
if p~=P then
|
||||
self.code(P)
|
||||
end
|
||||
if self.change and Timer()-self.lastTime>.18 then
|
||||
self.lastTime=Timer()
|
||||
if self.change and TIME()-self.lastTime>.18 then
|
||||
self.lastTime=TIME()
|
||||
self.change()
|
||||
end
|
||||
end
|
||||
@@ -478,8 +477,8 @@ function slider:arrowKey(isLeft)
|
||||
local P=isLeft and max(p-u,0)or min(p+u,self.unit)
|
||||
if p==P or not P then return end
|
||||
self.code(P)
|
||||
if self.change and Timer()-self.lastTime>.18 then
|
||||
self.lastTime=Timer()
|
||||
if self.change and TIME()-self.lastTime>.18 then
|
||||
self.lastTime=TIME()
|
||||
self.change()
|
||||
end
|
||||
end
|
||||
@@ -584,7 +583,7 @@ function selector:draw()
|
||||
gc.rectangle("line",x,y,w,60)
|
||||
|
||||
gc.setColor(1,1,1,.2+ATV*.1)
|
||||
local t=(Timer()%.5)^.5
|
||||
local t=(TIME()%.5)^.5
|
||||
if self.select>1 then
|
||||
gc.draw(drawableText.small,x+6,y+20)
|
||||
if ATV>0 then
|
||||
@@ -946,8 +945,8 @@ function WIDGET.gamepadPressed(i)
|
||||
local P=i=="left"and(p>0 and p-1)or p<W.unit and p+1
|
||||
if p==P or not P then return end
|
||||
W.code(P)
|
||||
if W.change and Timer()-W.lastTime>.18 then
|
||||
W.lastTime=Timer()
|
||||
if W.change and TIME()-W.lastTime>.18 then
|
||||
W.lastTime=TIME()
|
||||
W.change()
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user