PRINT改为独立模块log.lua,增加显示动画,增加使用样例
This commit is contained in:
@@ -52,7 +52,10 @@ function BGM.play(s)
|
|||||||
BGM.playing=BGM.list[s]
|
BGM.playing=BGM.list[s]
|
||||||
BGM.suspend,BGM.nowPlay=s
|
BGM.suspend,BGM.nowPlay=s
|
||||||
return
|
return
|
||||||
elseif not s or not BGM.list[s]then
|
elseif not s then
|
||||||
|
return
|
||||||
|
elseif not BGM.list[s]then
|
||||||
|
LOG.print("Cannot find BGM: "..s,color.lRed)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if BGM.nowPlay~=s then
|
if BGM.nowPlay~=s then
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ WIDGET= require("Zframework/widget")
|
|||||||
Widgets=require("Zframework/widgetList")
|
Widgets=require("Zframework/widgetList")
|
||||||
LIGHT= require("Zframework/light")
|
LIGHT= require("Zframework/light")
|
||||||
SCN= require("Zframework/scene")
|
SCN= require("Zframework/scene")
|
||||||
|
LOG= require("Zframework/log")
|
||||||
|
|
||||||
local ms=love.mouse
|
local ms=love.mouse
|
||||||
local gc=love.graphics
|
local gc=love.graphics
|
||||||
@@ -190,6 +191,8 @@ function love.keypressed(i)
|
|||||||
if devMode then
|
if devMode then
|
||||||
if i=="f5"then
|
if i=="f5"then
|
||||||
DBP("DEBUG:")
|
DBP("DEBUG:")
|
||||||
|
elseif i=="f3"then
|
||||||
|
LOG.print("挂了.gif")
|
||||||
elseif i=="f8"then devMode=nil TEXT.show("DEBUG OFF",640,360,80,"fly",.8)
|
elseif i=="f8"then devMode=nil TEXT.show("DEBUG OFF",640,360,80,"fly",.8)
|
||||||
elseif i=="f9"then devMode=1 TEXT.show("DEBUG 1",640,360,80,"fly",.8)
|
elseif i=="f9"then devMode=1 TEXT.show("DEBUG 1",640,360,80,"fly",.8)
|
||||||
elseif i=="f10"then devMode=2 TEXT.show("DEBUG 2",640,360,80,"fly",.8)
|
elseif i=="f10"then devMode=2 TEXT.show("DEBUG 2",640,360,80,"fly",.8)
|
||||||
@@ -257,6 +260,7 @@ function love.joystickremoved(JS)
|
|||||||
for i=1,#joysticks do
|
for i=1,#joysticks do
|
||||||
if joysticks[i]==JS then
|
if joysticks[i]==JS then
|
||||||
rem(joysticks,i)
|
rem(joysticks,i)
|
||||||
|
LOG.print("Joystick removed")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -418,14 +422,7 @@ function love.run()
|
|||||||
|
|
||||||
local waitTime=1/60
|
local waitTime=1/60
|
||||||
local frameTimeList={}
|
local frameTimeList={}
|
||||||
local debugMesList={}
|
|
||||||
local debugMesFloat=0
|
|
||||||
function PRINT(text,clr,time)--use this for print for debug in-game
|
|
||||||
if not clr then clr=color.white end
|
|
||||||
ins(debugMesList,{text=text,r=clr[1],g=clr[2],b=clr[3],time=time or 180})
|
|
||||||
ins(debugMesHistory,SCN.cur..": "..tostring(text))
|
|
||||||
end
|
|
||||||
|
|
||||||
local lastFrame=Timer()
|
local lastFrame=Timer()
|
||||||
local lastFreshPow=lastFrame
|
local lastFreshPow=lastFrame
|
||||||
local FCT=0--Framedraw counter
|
local FCT=0--Framedraw counter
|
||||||
@@ -461,6 +458,7 @@ function love.run()
|
|||||||
_=Tmr[SCN.cur]if _ then _(dt)end--Scene Updater
|
_=Tmr[SCN.cur]if _ then _(dt)end--Scene Updater
|
||||||
if SCN.swapping then SCN.swapUpdate()end--Scene swapping animation
|
if SCN.swapping then SCN.swapUpdate()end--Scene swapping animation
|
||||||
WIDGET.update()--Widgets animation
|
WIDGET.update()--Widgets animation
|
||||||
|
LOG.update()
|
||||||
|
|
||||||
--DRAW
|
--DRAW
|
||||||
if not mini()then
|
if not mini()then
|
||||||
@@ -527,27 +525,7 @@ function love.run()
|
|||||||
elseif devMode==4 then WAIT(.5)
|
elseif devMode==4 then WAIT(.5)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if debugMesList[1]then
|
LOG.draw()
|
||||||
setFont(20)
|
|
||||||
if debugMesFloat>0 then
|
|
||||||
debugMesFloat=int(debugMesFloat*.9)
|
|
||||||
end
|
|
||||||
for i=#debugMesList,1,-1 do
|
|
||||||
local M=debugMesList[i]
|
|
||||||
M.time=M.time-1
|
|
||||||
if M.time<=0 then
|
|
||||||
rem(debugMesList,i)
|
|
||||||
if not debugMesList[1]then
|
|
||||||
debugMesFloat=0
|
|
||||||
else
|
|
||||||
debugMesFloat=debugMesFloat+25
|
|
||||||
end
|
|
||||||
else
|
|
||||||
gc.setColor(M.r,M.g,M.b,min(M.time/26,1))
|
|
||||||
gc.print(M.text,10+(15-min(M.time,15))^1.5/3,25*i+debugMesFloat)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
gc.present()
|
gc.present()
|
||||||
end
|
end
|
||||||
|
|||||||
43
Zframework/log.lua
Normal file
43
Zframework/log.lua
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
local gc=love.graphics
|
||||||
|
local int,min=math.floor,math.min
|
||||||
|
local ins,rem=table.insert,table.remove
|
||||||
|
|
||||||
|
local debugMesList={}
|
||||||
|
local debugMesFloat=0
|
||||||
|
local LOG={}
|
||||||
|
function LOG.print(text,clr)--use this for print for debug in-game
|
||||||
|
if not clr then clr=color.white end
|
||||||
|
ins(debugMesList,{text=text,r=clr[1],g=clr[2],b=clr[3],time=240})
|
||||||
|
ins(debugMesHistory,SCN.cur..": "..tostring(text))
|
||||||
|
end
|
||||||
|
function LOG.update()
|
||||||
|
if debugMesList[1]then
|
||||||
|
for i=#debugMesList,1,-1 do
|
||||||
|
local M=debugMesList[i]
|
||||||
|
M.time=M.time-1
|
||||||
|
if i==1 and M.time==0 then
|
||||||
|
rem(debugMesList,i)
|
||||||
|
if not debugMesList[1]then
|
||||||
|
debugMesFloat=0
|
||||||
|
else
|
||||||
|
debugMesFloat=debugMesFloat+25
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if debugMesFloat>0 then
|
||||||
|
debugMesFloat=int(debugMesFloat*.9)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function LOG.draw()
|
||||||
|
if debugMesList[1]then
|
||||||
|
setFont(20)
|
||||||
|
for i=1,#debugMesList do
|
||||||
|
local M=debugMesList[i]
|
||||||
|
local t=M.time
|
||||||
|
gc.setColor(M.r,M.g,M.b,t>200 and int(t/3)%2 or min(t/26,1))
|
||||||
|
gc.print(M.text,10+(20-min(t,20))^1.5/4,25*i+debugMesFloat)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return LOG
|
||||||
@@ -39,8 +39,10 @@ local function loadCC()
|
|||||||
end
|
end
|
||||||
if not f then
|
if not f then
|
||||||
CCloader_filename[system]=nil
|
CCloader_filename[system]=nil
|
||||||
|
LOG.print("failed to load CC")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
LOG.print("CC load successfully")
|
||||||
f()
|
f()
|
||||||
BOT={
|
BOT={
|
||||||
getConf= cc.get_default_config ,--()options,weights
|
getConf= cc.get_default_config ,--()options,weights
|
||||||
|
|||||||
@@ -252,6 +252,15 @@ do--p15
|
|||||||
if checkBoard(b)then
|
if checkBoard(b)then
|
||||||
S.state=2
|
S.state=2
|
||||||
S.time=Timer()-S.startTime
|
S.time=Timer()-S.startTime
|
||||||
|
if S.time<1 then LOG.print("不是人")
|
||||||
|
elseif S.time<2 then LOG.print("还是人")
|
||||||
|
elseif S.time<3 then LOG.print("神仙")
|
||||||
|
elseif S.time<5 then LOG.print("太强了")
|
||||||
|
elseif S.time<7.5 then LOG.print("很强")
|
||||||
|
elseif S.time<10 then LOG.print("可以的")
|
||||||
|
elseif S.time<20 then LOG.print("再接再厉")
|
||||||
|
elseif S.time<30 then LOG.print("多加练习")
|
||||||
|
end
|
||||||
SFX.play("win")
|
SFX.play("win")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user