整理代码
This commit is contained in:
@@ -49,7 +49,7 @@ local gc_push,gc_pop=gc.push,gc.pop
|
|||||||
local gc_discard,gc_present=gc.discard,gc.present
|
local gc_discard,gc_present=gc.discard,gc.present
|
||||||
local gc_setColor,gc_draw,gc_rectangle=gc.setColor,gc.draw,gc.rectangle
|
local gc_setColor,gc_draw,gc_rectangle=gc.setColor,gc.draw,gc.rectangle
|
||||||
local gc_print=gc.print
|
local gc_print=gc.print
|
||||||
local setFont=setFont
|
local setFont,mStr=setFont,mStr
|
||||||
|
|
||||||
local int,rnd,abs=math.floor,math.random,math.abs
|
local int,rnd,abs=math.floor,math.random,math.abs
|
||||||
local min,sin=math.min,math.sin
|
local min,sin=math.min,math.sin
|
||||||
@@ -277,7 +277,7 @@ function love.textinput(texts)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function love.joystickadded(JS)
|
function love.joystickadded(JS)
|
||||||
joysticks[#joysticks+1]=JS
|
ins(joysticks,JS)
|
||||||
end
|
end
|
||||||
function love.joystickremoved(JS)
|
function love.joystickremoved(JS)
|
||||||
local i=TABLE.find(joysticks,JS)
|
local i=TABLE.find(joysticks,JS)
|
||||||
@@ -392,7 +392,7 @@ function love.errorhandler(msg)
|
|||||||
if LOADED and #ERRDATA<3 then
|
if LOADED and #ERRDATA<3 then
|
||||||
BG.set('none')
|
BG.set('none')
|
||||||
local scn=SCN and SCN.cur or"NULL"
|
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
|
--Write messages to log file
|
||||||
love.filesystem.append("conf/error.log",
|
love.filesystem.append("conf/error.log",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ local setColor,setWidth=gc.setColor,gc.setLineWidth
|
|||||||
local sin,cos=math.sin,math.cos
|
local sin,cos=math.sin,math.cos
|
||||||
local max,min=math.max,math.min
|
local max,min=math.max,math.min
|
||||||
local rnd=math.random
|
local rnd=math.random
|
||||||
local rem=table.remove
|
local ins,rem=table.insert,table.remove
|
||||||
|
|
||||||
local fx={}
|
local fx={}
|
||||||
|
|
||||||
@@ -126,17 +126,17 @@ function SYSFX.draw()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function SYSFX.newBadge(x1,y1,x2,y2)
|
function SYSFX.newBadge(x1,y1,x2,y2)
|
||||||
fx[#fx+1]={
|
ins(fx,{
|
||||||
update=FXupdate.badge,
|
update=FXupdate.badge,
|
||||||
draw=FXdraw.badge,
|
draw=FXdraw.badge,
|
||||||
t=0,
|
t=0,
|
||||||
x=x1,y=y1,
|
x=x1,y=y1,
|
||||||
x1=x1,y1=y1,
|
x1=x1,y1=y1,
|
||||||
x2=x2,y2=y2,
|
x2=x2,y2=y2,
|
||||||
}
|
})
|
||||||
end
|
end
|
||||||
function SYSFX.newAttack(rate,x1,y1,x2,y2,wid,r,g,b,a)
|
function SYSFX.newAttack(rate,x1,y1,x2,y2,wid,r,g,b,a)
|
||||||
fx[#fx+1]={
|
ins(fx,{
|
||||||
update=FXupdate.attack,
|
update=FXupdate.attack,
|
||||||
draw=FXdraw.attack,
|
draw=FXdraw.attack,
|
||||||
t=0,
|
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
|
x2=x2,y2=y2,--End pos
|
||||||
wid=wid,--Line width
|
wid=wid,--Line width
|
||||||
r=r,g=g,b=b,a=a,
|
r=r,g=g,b=b,a=a,
|
||||||
}
|
})
|
||||||
end
|
end
|
||||||
function SYSFX.newTap(rate,x,y)
|
function SYSFX.newTap(rate,x,y)
|
||||||
local T=
|
local T=
|
||||||
@@ -162,38 +162,38 @@ function SYSFX.newTap(rate,x,y)
|
|||||||
local ang=rnd()*6.2832
|
local ang=rnd()*6.2832
|
||||||
T.ptc[i]={x,y,x+d*cos(ang),y+d*sin(ang)}
|
T.ptc[i]={x,y,x+d*cos(ang),y+d*sin(ang)}
|
||||||
end
|
end
|
||||||
fx[#fx+1]=T
|
ins(fx,T)
|
||||||
end
|
end
|
||||||
function SYSFX.newRipple(rate,x,y,r)
|
function SYSFX.newRipple(rate,x,y,r)
|
||||||
fx[#fx+1]={
|
ins(fx,{
|
||||||
update=FXupdate.ripple,
|
update=FXupdate.ripple,
|
||||||
draw=FXdraw.ripple,
|
draw=FXdraw.ripple,
|
||||||
t=0,
|
t=0,
|
||||||
rate=rate,
|
rate=rate,
|
||||||
x=x,y=y,r=r,
|
x=x,y=y,r=r,
|
||||||
}
|
})
|
||||||
end
|
end
|
||||||
function SYSFX.newRectRipple(rate,x,y,w,h)
|
function SYSFX.newRectRipple(rate,x,y,w,h)
|
||||||
fx[#fx+1]={
|
ins(fx,{
|
||||||
update=FXupdate.rectRipple,
|
update=FXupdate.rectRipple,
|
||||||
draw=FXdraw.rectRipple,
|
draw=FXdraw.rectRipple,
|
||||||
t=0,
|
t=0,
|
||||||
rate=rate,
|
rate=rate,
|
||||||
x=x,y=y,w=w,h=h,
|
x=x,y=y,w=w,h=h,
|
||||||
}
|
})
|
||||||
end
|
end
|
||||||
function SYSFX.newShade(rate,x,y,w,h,r,g,b)
|
function SYSFX.newShade(rate,x,y,w,h,r,g,b)
|
||||||
fx[#fx+1]={
|
ins(fx,{
|
||||||
update=FXupdate.shade,
|
update=FXupdate.shade,
|
||||||
draw=FXdraw.shade,
|
draw=FXdraw.shade,
|
||||||
t=0,
|
t=0,
|
||||||
rate=rate,
|
rate=rate,
|
||||||
x=x,y=y,w=w,h=h,
|
x=x,y=y,w=w,h=h,
|
||||||
r=r or 1,g=g or 1,b=b or 1,
|
r=r or 1,g=g or 1,b=b or 1,
|
||||||
}
|
})
|
||||||
end
|
end
|
||||||
function SYSFX.newCell(rate,image,size,x,y,vx,vy,ax,ay)
|
function SYSFX.newCell(rate,image,size,x,y,vx,vy,ax,ay)
|
||||||
fx[#fx+1]={
|
ins(fx,{
|
||||||
update=FXupdate.cell,
|
update=FXupdate.cell,
|
||||||
draw=FXdraw.cell,
|
draw=FXdraw.cell,
|
||||||
t=0,
|
t=0,
|
||||||
@@ -203,10 +203,10 @@ function SYSFX.newCell(rate,image,size,x,y,vx,vy,ax,ay)
|
|||||||
x=x,y=y,
|
x=x,y=y,
|
||||||
vx=vx,vy=vy,
|
vx=vx,vy=vy,
|
||||||
ax=ax,ay=ay,
|
ax=ax,ay=ay,
|
||||||
}
|
})
|
||||||
end
|
end
|
||||||
function SYSFX.newLine(rate,x1,y1,x2,y2,r,g,b,a)
|
function SYSFX.newLine(rate,x1,y1,x2,y2,r,g,b,a)
|
||||||
fx[#fx+1]={
|
ins(fx,{
|
||||||
update=FXupdate.line,
|
update=FXupdate.line,
|
||||||
draw=FXdraw.line,
|
draw=FXdraw.line,
|
||||||
t=0,
|
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,
|
x1=x1 or 0,y1=y1 or 0,
|
||||||
x2=x2 or x1 or 1280,y2=y2 or y1 or 720,
|
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,
|
r=r or 1,g=g or 1,b=b or 1,a=a or 1,
|
||||||
}
|
})
|
||||||
end
|
end
|
||||||
return SYSFX
|
return SYSFX
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
local gc=love.graphics
|
local gc=love.graphics
|
||||||
local 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
|
||||||
=gc.getColor,gc.setColor,gc.push,gc.pop,gc.translate,gc.scale,gc.rotate,gc.shear
|
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 setFont,mStr=setFont,mStr
|
||||||
|
|
||||||
local texts={}
|
local texts={}
|
||||||
@@ -77,7 +78,7 @@ function TEXT.clear()
|
|||||||
texts={}
|
texts={}
|
||||||
end
|
end
|
||||||
function TEXT.show(text,x,y,font,style,spd,stop)
|
function TEXT.show(text,x,y,font,style,spd,stop)
|
||||||
texts[#texts+1]={
|
ins(texts,{
|
||||||
c=0, --Timer
|
c=0, --Timer
|
||||||
text=text, --String
|
text=text, --String
|
||||||
x=x or 0, --X
|
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)
|
spd=(spd or 1)/60, --Timing speed(1=last 1 sec)
|
||||||
stop=stop, --Stop time(sustained text)
|
stop=stop, --Stop time(sustained text)
|
||||||
draw=textFX[style or'appear']or error("unavailable type:"..style), --Draw method
|
draw=textFX[style or'appear']or error("unavailable type:"..style), --Draw method
|
||||||
}
|
})
|
||||||
end
|
end
|
||||||
function TEXT.getText(text,x,y,font,style,spd,stop)--Another version of TEXT.show(), but only return text object, need manual management
|
function TEXT.getText(text,x,y,font,style,spd,stop)--Another version of TEXT.show(), but only return text object, need manual management
|
||||||
return{
|
return{
|
||||||
|
|||||||
4
main.lua
4
main.lua
@@ -165,7 +165,7 @@ SFX.init((function()
|
|||||||
local L={}
|
local L={}
|
||||||
for _,v in next,fs.getDirectoryItems("media/SFX")do
|
for _,v in next,fs.getDirectoryItems("media/SFX")do
|
||||||
if fs.getRealDirectory("media/SFX/"..v)~=SAVEDIR then
|
if fs.getRealDirectory("media/SFX/"..v)~=SAVEDIR then
|
||||||
L[#L+1]=v:sub(1,-5)
|
table.insert(L,v:sub(1,-5))
|
||||||
else
|
else
|
||||||
LOG.print("Dangerous file : %SAVE%/media/SFX/"..v)
|
LOG.print("Dangerous file : %SAVE%/media/SFX/"..v)
|
||||||
end
|
end
|
||||||
@@ -176,7 +176,7 @@ BGM.init((function()
|
|||||||
local L={}
|
local L={}
|
||||||
for _,v in next,fs.getDirectoryItems("media/BGM")do
|
for _,v in next,fs.getDirectoryItems("media/BGM")do
|
||||||
if fs.getRealDirectory("media/BGM/"..v)~=SAVEDIR then
|
if fs.getRealDirectory("media/BGM/"..v)~=SAVEDIR then
|
||||||
L[#L+1]=v:sub(1,-5)
|
table.insert(L,v:sub(1,-5))
|
||||||
else
|
else
|
||||||
LOG.print("Dangerous file : %SAVE%/media/BGM/"..v)
|
LOG.print("Dangerous file : %SAVE%/media/BGM/"..v)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -125,11 +125,11 @@ function Player:newTask(code,...)
|
|||||||
local thread=coroutine.create(code)
|
local thread=coroutine.create(code)
|
||||||
resume(thread,self,...)
|
resume(thread,self,...)
|
||||||
if status(thread)~='dead'then
|
if status(thread)~='dead'then
|
||||||
self.tasks[#self.tasks+1]={
|
ins(self.tasks,{
|
||||||
thread=thread,
|
thread=thread,
|
||||||
code=code,
|
code=code,
|
||||||
args={...},
|
args={...},
|
||||||
}
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user