整理代码,微优化
This commit is contained in:
@@ -5,10 +5,9 @@ local gameEnv0=require"parts.player.gameEnv0"
|
|||||||
local rnd,max=math.random,math.max
|
local rnd,max=math.random,math.max
|
||||||
local ins=table.insert
|
local ins=table.insert
|
||||||
|
|
||||||
local PLY={
|
local ply_draw=require"parts.player.draw"
|
||||||
update=require"parts.player.update",
|
local ply_update=require"parts.player.update"
|
||||||
draw=require"parts.player.draw",
|
local PLY={draw=ply_draw}
|
||||||
}
|
|
||||||
|
|
||||||
--------------------------<Libs>--------------------------
|
--------------------------<Libs>--------------------------
|
||||||
local modeDataMeta do
|
local modeDataMeta do
|
||||||
@@ -87,7 +86,7 @@ local function newEmptyPlayer(id,mini)
|
|||||||
P.pressKey=pressKey
|
P.pressKey=pressKey
|
||||||
P.releaseKey=releaseKey
|
P.releaseKey=releaseKey
|
||||||
end
|
end
|
||||||
P.update=PLY.update.alive
|
P.update=ply_update.alive
|
||||||
|
|
||||||
P.fieldOff={--Shake FX
|
P.fieldOff={--Shake FX
|
||||||
x=0,y=0,
|
x=0,y=0,
|
||||||
@@ -107,9 +106,9 @@ local function newEmptyPlayer(id,mini)
|
|||||||
if mini then
|
if mini then
|
||||||
P.canvas=love.graphics.newCanvas(60,120)
|
P.canvas=love.graphics.newCanvas(60,120)
|
||||||
P.frameWait=rnd(26,62)
|
P.frameWait=rnd(26,62)
|
||||||
P.draw=PLY.draw.small
|
P.draw=ply_draw.small
|
||||||
else
|
else
|
||||||
P.draw=PLY.draw.norm
|
P.draw=ply_draw.norm
|
||||||
end
|
end
|
||||||
|
|
||||||
P.randGen=love.math.newRandomGenerator(GAME.seed)
|
P.randGen=love.math.newRandomGenerator(GAME.seed)
|
||||||
@@ -136,9 +135,9 @@ local function newEmptyPlayer(id,mini)
|
|||||||
P.atker,P.atking,P.lastRecv={}
|
P.atker,P.atking,P.lastRecv={}
|
||||||
|
|
||||||
--Network-related
|
--Network-related
|
||||||
P.username='_'
|
P.username="_"
|
||||||
P.uid=-1
|
P.uid=false
|
||||||
P.sid=-1
|
P.sid=false
|
||||||
|
|
||||||
P.dropDelay,P.lockDelay=0,0
|
P.dropDelay,P.lockDelay=0,0
|
||||||
P.showTime=false
|
P.showTime=false
|
||||||
@@ -357,7 +356,7 @@ function PLY.newDemoPlayer(id)
|
|||||||
P.demo=true
|
P.demo=true
|
||||||
|
|
||||||
P.frameRun=180
|
P.frameRun=180
|
||||||
P.draw=PLY.draw.demo
|
P.draw=ply_draw.demo
|
||||||
P.control=true
|
P.control=true
|
||||||
GAME.modeEnv=DemoEnv
|
GAME.modeEnv=DemoEnv
|
||||||
loadGameEnv(P)
|
loadGameEnv(P)
|
||||||
@@ -376,9 +375,9 @@ end
|
|||||||
function PLY.newRemotePlayer(id,mini,ply)
|
function PLY.newRemotePlayer(id,mini,ply)
|
||||||
local P=newEmptyPlayer(id,mini)
|
local P=newEmptyPlayer(id,mini)
|
||||||
P.type='remote'
|
P.type='remote'
|
||||||
P.update=PLY.update.remote_alive
|
P.update=ply_update.remote_alive
|
||||||
|
|
||||||
P.draw=PLY.draw.norm_remote
|
P.draw=ply_draw.norm_remote
|
||||||
|
|
||||||
P.stream={}
|
P.stream={}
|
||||||
P.streamProgress=1
|
P.streamProgress=1
|
||||||
@@ -409,7 +408,6 @@ function PLY.newPlayer(id,mini)
|
|||||||
P.sound=true
|
P.sound=true
|
||||||
|
|
||||||
P.uid=USER.uid
|
P.uid=USER.uid
|
||||||
P.sid=-1
|
|
||||||
|
|
||||||
loadGameEnv(P)
|
loadGameEnv(P)
|
||||||
applyGameEnv(P)
|
applyGameEnv(P)
|
||||||
|
|||||||
@@ -7,12 +7,14 @@ local int,ceil,rnd=math.floor,math.ceil,math.random
|
|||||||
local max,min,modf=math.max,math.min,math.modf
|
local max,min,modf=math.max,math.min,math.modf
|
||||||
local ins,rem=table.insert,table.remove
|
local ins,rem=table.insert,table.remove
|
||||||
local resume,yield,status=coroutine.resume,coroutine.yield,coroutine.status
|
local resume,yield,status=coroutine.resume,coroutine.yield,coroutine.status
|
||||||
|
|
||||||
local SFX,BGM,VOC,VIB,SYSFX,SKIN=SFX,BGM,VOC,VIB,SYSFX,SKIN
|
local SFX,BGM,VOC,VIB,SYSFX,SKIN=SFX,BGM,VOC,VIB,SYSFX,SKIN
|
||||||
local FREEROW,TABLE,TEXT,NET,TASK=FREEROW,TABLE,TEXT,NET,TASK
|
local FREEROW,TABLE,TEXT,NET,TASK=FREEROW,TABLE,TEXT,NET,TASK
|
||||||
local PLAYERS,PLY_ALIVE,GAME=PLAYERS,PLY_ALIVE,GAME
|
local PLAYERS,PLY_ALIVE,GAME=PLAYERS,PLY_ALIVE,GAME
|
||||||
|
|
||||||
|
|
||||||
local kickList=require"parts.kickList"
|
local kickList=require"parts.kickList"
|
||||||
|
local ply_draw=require"parts.player.draw"
|
||||||
|
local ply_update=require"parts.player.update"
|
||||||
|
|
||||||
--------------------------<FX>--------------------------
|
--------------------------<FX>--------------------------
|
||||||
function Player:showText(text,dx,dy,font,style,spd,stop)
|
function Player:showText(text,dx,dy,font,style,spd,stop)
|
||||||
@@ -199,9 +201,9 @@ function Player:setNext(next,hidden)--Set next count (use hidden=true if set e
|
|||||||
if next==0 then
|
if next==0 then
|
||||||
self.drawNext=NULL
|
self.drawNext=NULL
|
||||||
elseif not hidden then
|
elseif not hidden then
|
||||||
self.drawNext=PLY.draw.drawNext_norm
|
self.drawNext=ply_draw.drawNext_norm
|
||||||
else
|
else
|
||||||
self.drawNext=PLY.draw.drawNext_hidden
|
self.drawNext=ply_draw.drawNext_hidden
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
function Player:setInvisible(time)--Time in frames
|
function Player:setInvisible(time)--Time in frames
|
||||||
@@ -1615,7 +1617,7 @@ function Player:die()--Called both when win/lose!
|
|||||||
self.alive=false
|
self.alive=false
|
||||||
self.timing=false
|
self.timing=false
|
||||||
self.control=false
|
self.control=false
|
||||||
self.update=PLY.update.dead
|
self.update=ply_update.dead
|
||||||
self.waiting=1e99
|
self.waiting=1e99
|
||||||
self.b2b=0
|
self.b2b=0
|
||||||
self.tasks={}
|
self.tasks={}
|
||||||
|
|||||||
Reference in New Issue
Block a user