整理代码

This commit is contained in:
MrZ626
2021-05-13 10:18:02 +08:00
parent e56391c347
commit 0f30a35ae3
5 changed files with 29 additions and 28 deletions

View File

@@ -49,7 +49,7 @@ local gc_push,gc_pop=gc.push,gc.pop
local gc_discard,gc_present=gc.discard,gc.present
local gc_setColor,gc_draw,gc_rectangle=gc.setColor,gc.draw,gc.rectangle
local gc_print=gc.print
local setFont=setFont
local setFont,mStr=setFont,mStr
local int,rnd,abs=math.floor,math.random,math.abs
local min,sin=math.min,math.sin
@@ -277,7 +277,7 @@ function love.textinput(texts)
end
function love.joystickadded(JS)
joysticks[#joysticks+1]=JS
ins(joysticks,JS)
end
function love.joystickremoved(JS)
local i=TABLE.find(joysticks,JS)
@@ -392,7 +392,7 @@ function love.errorhandler(msg)
if LOADED and #ERRDATA<3 then
BG.set('none')
local scn=SCN and SCN.cur or"NULL"
ERRDATA[#ERRDATA+1]={mes=err,scene=scn}
ins(ERRDATA,{mes=err,scene=scn})
--Write messages to log file
love.filesystem.append("conf/error.log",

View File

@@ -3,7 +3,7 @@ local setColor,setWidth=gc.setColor,gc.setLineWidth
local sin,cos=math.sin,math.cos
local max,min=math.max,math.min
local rnd=math.random
local rem=table.remove
local ins,rem=table.insert,table.remove
local fx={}
@@ -126,17 +126,17 @@ function SYSFX.draw()
end
function SYSFX.newBadge(x1,y1,x2,y2)
fx[#fx+1]={
ins(fx,{
update=FXupdate.badge,
draw=FXdraw.badge,
t=0,
x=x1,y=y1,
x1=x1,y1=y1,
x2=x2,y2=y2,
}
})
end
function SYSFX.newAttack(rate,x1,y1,x2,y2,wid,r,g,b,a)
fx[#fx+1]={
ins(fx,{
update=FXupdate.attack,
draw=FXdraw.attack,
t=0,
@@ -145,7 +145,7 @@ function SYSFX.newAttack(rate,x1,y1,x2,y2,wid,r,g,b,a)
x2=x2,y2=y2,--End pos
wid=wid,--Line width
r=r,g=g,b=b,a=a,
}
})
end
function SYSFX.newTap(rate,x,y)
local T=
@@ -162,38 +162,38 @@ function SYSFX.newTap(rate,x,y)
local ang=rnd()*6.2832
T.ptc[i]={x,y,x+d*cos(ang),y+d*sin(ang)}
end
fx[#fx+1]=T
ins(fx,T)
end
function SYSFX.newRipple(rate,x,y,r)
fx[#fx+1]={
ins(fx,{
update=FXupdate.ripple,
draw=FXdraw.ripple,
t=0,
rate=rate,
x=x,y=y,r=r,
}
})
end
function SYSFX.newRectRipple(rate,x,y,w,h)
fx[#fx+1]={
ins(fx,{
update=FXupdate.rectRipple,
draw=FXdraw.rectRipple,
t=0,
rate=rate,
x=x,y=y,w=w,h=h,
}
})
end
function SYSFX.newShade(rate,x,y,w,h,r,g,b)
fx[#fx+1]={
ins(fx,{
update=FXupdate.shade,
draw=FXdraw.shade,
t=0,
rate=rate,
x=x,y=y,w=w,h=h,
r=r or 1,g=g or 1,b=b or 1,
}
})
end
function SYSFX.newCell(rate,image,size,x,y,vx,vy,ax,ay)
fx[#fx+1]={
ins(fx,{
update=FXupdate.cell,
draw=FXdraw.cell,
t=0,
@@ -203,10 +203,10 @@ function SYSFX.newCell(rate,image,size,x,y,vx,vy,ax,ay)
x=x,y=y,
vx=vx,vy=vy,
ax=ax,ay=ay,
}
})
end
function SYSFX.newLine(rate,x1,y1,x2,y2,r,g,b,a)
fx[#fx+1]={
ins(fx,{
update=FXupdate.line,
draw=FXdraw.line,
t=0,
@@ -214,6 +214,6 @@ function SYSFX.newLine(rate,x1,y1,x2,y2,r,g,b,a)
x1=x1 or 0,y1=y1 or 0,
x2=x2 or x1 or 1280,y2=y2 or y1 or 720,
r=r or 1,g=g or 1,b=b or 1,a=a or 1,
}
})
end
return SYSFX

View File

@@ -1,8 +1,9 @@
local gc=love.graphics
local gc_getColor,gc_setColor,gc_push,gc_pop,gc_translate,gc_scale,gc_rotate,gc_shear
=gc.getColor,gc.setColor,gc.push,gc.pop,gc.translate,gc.scale,gc.rotate,gc.shear
local gc_getColor,gc_setColor,gc_push,gc_pop=gc.getColor,gc.setColor,gc.push,gc.pop
local gc_translate,gc_scale,gc_rotate,gc_shear=gc.translate,gc.scale,gc.rotate,gc.shear
local int,rnd,rem=math.floor,math.random,table.remove
local int,rnd=math.floor,math.random
local ins,rem=table.insert,table.remove
local setFont,mStr=setFont,mStr
local texts={}
@@ -77,7 +78,7 @@ function TEXT.clear()
texts={}
end
function TEXT.show(text,x,y,font,style,spd,stop)
texts[#texts+1]={
ins(texts,{
c=0, --Timer
text=text, --String
x=x or 0, --X
@@ -86,7 +87,7 @@ function TEXT.show(text,x,y,font,style,spd,stop)
spd=(spd or 1)/60, --Timing speed(1=last 1 sec)
stop=stop, --Stop time(sustained text)
draw=textFX[style or'appear']or error("unavailable type:"..style), --Draw method
}
})
end
function TEXT.getText(text,x,y,font,style,spd,stop)--Another version of TEXT.show(), but only return text object, need manual management
return{

View File

@@ -165,7 +165,7 @@ SFX.init((function()
local L={}
for _,v in next,fs.getDirectoryItems("media/SFX")do
if fs.getRealDirectory("media/SFX/"..v)~=SAVEDIR then
L[#L+1]=v:sub(1,-5)
table.insert(L,v:sub(1,-5))
else
LOG.print("Dangerous file : %SAVE%/media/SFX/"..v)
end
@@ -176,7 +176,7 @@ BGM.init((function()
local L={}
for _,v in next,fs.getDirectoryItems("media/BGM")do
if fs.getRealDirectory("media/BGM/"..v)~=SAVEDIR then
L[#L+1]=v:sub(1,-5)
table.insert(L,v:sub(1,-5))
else
LOG.print("Dangerous file : %SAVE%/media/BGM/"..v)
end

View File

@@ -125,11 +125,11 @@ function Player:newTask(code,...)
local thread=coroutine.create(code)
resume(thread,self,...)
if status(thread)~='dead'then
self.tasks[#self.tasks+1]={
ins(self.tasks,{
thread=thread,
code=code,
args={...},
}
})
end
end