Skip to content

Commit e139c54

Browse files
committed
整理代码
1 parent eb0edaa commit e139c54

File tree

9 files changed

+28
-30
lines changed

9 files changed

+28
-30
lines changed

assets/game/acryPlayer.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ function AP:tickStep()
581581
end
582582
end
583583

584-
if love.keyboard.isDown('f4') then
584+
if IsKeyDown('f4') then
585585
local acry=F[1][1]
586586
if acry then
587587
print("--------------------------")

assets/game/exteriorMap.lua

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -297,9 +297,9 @@ end
297297
function map:update(dt)
298298
-- if selected then
299299
-- selected.pos={
300-
-- selected.pos[1]+.026*((love.keyboard.isDown('w') and 1 or 0)-(love.keyboard.isDown('s') and 1 or 0)),
301-
-- selected.pos[2]+.026*((love.keyboard.isDown('a') and 1 or 0)-(love.keyboard.isDown('d') and 1 or 0)),
302-
-- selected.pos[3]+.026*((love.keyboard.isDown('q') and 1 or 0)-(love.keyboard.isDown('e') and 1 or 0)),
300+
-- selected.pos[1]+.026*((IsKeyDown('w') and 1 or 0)-(IsKeyDown('s') and 1 or 0)),
301+
-- selected.pos[2]+.026*((IsKeyDown('a') and 1 or 0)-(IsKeyDown('d') and 1 or 0)),
302+
-- selected.pos[3]+.026*((IsKeyDown('q') and 1 or 0)-(IsKeyDown('e') and 1 or 0)),
303303
-- }
304304
-- selected.x=30*(selected.pos[1]-selected.pos[2])*(3^.5/2)
305305
-- selected.y=30*(selected.pos[3]-(selected.pos[1]+selected.pos[2])*.5)
@@ -330,19 +330,19 @@ function map:update(dt)
330330
end
331331
end
332332
if full then
333-
if love.keyboard.isDown('up','down','left','right') then
333+
if IsKeyDown('up','down','left','right') then
334334
self:showCursor()
335335
if IsCtrlDown() then
336-
if love.keyboard.isDown('up') then cam:scale(2.6^dt) end
337-
if love.keyboard.isDown('down') then cam:scale(1/2.6^dt) end
338-
if love.keyboard.isDown('right') then cam:rotate(dt*3.55) end
339-
if love.keyboard.isDown('left') then cam:rotate(-dt*3.55) end
336+
if IsKeyDown('up') then cam:scale(2.6^dt) end
337+
if IsKeyDown('down') then cam:scale(1/2.6^dt) end
338+
if IsKeyDown('right') then cam:rotate(dt*3.55) end
339+
if IsKeyDown('left') then cam:rotate(-dt*3.55) end
340340
else
341341
local dx,dy=0,0
342-
if love.keyboard.isDown('up') then dy=dy+dt*1260 end
343-
if love.keyboard.isDown('down') then dy=dy-dt*1260 end
344-
if love.keyboard.isDown('left') then dx=dx+dt*1260 end
345-
if love.keyboard.isDown('right') then dx=dx-dt*1260 end
342+
if IsKeyDown('up') then dy=dy+dt*1260 end
343+
if IsKeyDown('down') then dy=dy-dt*1260 end
344+
if IsKeyDown('left') then dx=dx+dt*1260 end
345+
if IsKeyDown('right') then dx=dx-dt*1260 end
346346
cam:move(dx,dy)
347347
end
348348
end

assets/game/init.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ function GAME.cursorMove(x,y,dx,dy,tid,id)
341341
x,y=GAME.camera.transform:inverseTransformPoint(SCR.xOy_m:inverseTransformPoint(SCR.xOy:transformPoint(x,y)))
342342
p:mouseMove(x,y,dx,dy,
343343
tid or
344-
love.mouse.isDown(1) and 1 or
345-
love.mouse.isDown(2) and 2 or
344+
IsMouseDown(1) and 1 or
345+
IsMouseDown(2) and 2 or
346346
3
347347
)
348348
elseif SETTINGS.system.touchControl then

assets/gamefunc.lua

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,9 @@ GetTouches=love.touch.getTouches
331331
IsMouseDown=love.mouse.isDown
332332
IsKeyDown=love.keyboard.isDown
333333
IsSCDown=love.keyboard.isScancodeDown
334-
local IsKeyDown=IsKeyDown
335334
function IsCtrlDown() return IsKeyDown('lctrl','rctrl') end
336335
function IsShiftDown() return IsKeyDown('lshift','rshift') end
337-
function isAltDown() return IsKeyDown('lalt','ralt') end
336+
function IsAltDown() return IsKeyDown('lalt','ralt') end
338337

339338
local function _getActMode(mode,key)
340339
local act=KEYMAP[mode]:getAction(key)

assets/progress.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,8 @@ function PROGRESS.applyEnv(env)
251251
gc.setColor(1,1,1)
252252
gc.setLineWidth(2)
253253
gc.translate(x,y)
254-
if love.mouse.isDown(1) then GC.mRect('fill',0,0,10,10) end
255-
if love.mouse.isDown(2) then GC.mRect('line',0,0,16,16) end
254+
if IsMouseDown(1) then GC.mRect('fill',0,0,10,10) end
255+
if IsMouseDown(2) then GC.mRect('line',0,0,16,16) end
256256
gc.setColor(1,1,1,.626)
257257
gc.setLineWidth(4)
258258
gc.line(0,-15,0,15)
@@ -329,7 +329,7 @@ function PROGRESS.applyEnv(env)
329329
end
330330
end
331331
function ZENITHA.globalEvent.mouseUp(x,y,k)
332-
if not love.mouse.isDown(1,2,3) then
332+
if not IsMouseDown(1,2,3) then
333333
TWEEN.tag_kill('cursor_anim')
334334
_wid1,_wid2=W,.55
335335
TWEEN.new(cursor_anim):setTag('cursor_anim'):setDuration(.0626):run()

assets/scene/dictionary.lua

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ local gc_stc_reset,gc_stc_rect,gc_stc_stop=GC.stc_reset,GC.stc_rect,GC.stc_stop
44
local gc_translate,gc_replaceTransform=GC.translate,GC.replaceTransform
55

66
local ins=table.insert
7-
local kbIsDown=love.keyboard.isDown
87
---@type Zenitha.Scene
98
local scene={}
109

@@ -349,7 +348,7 @@ function scene.keyDown(key,isRep)
349348
if WIDGET.isFocus(inputBox) and #key==1 then return true end
350349
local act=KEYMAP.sys:getAction(key)
351350
if act=='up' or act=='down' then
352-
if not (IsCtrlDown() or IsShiftDown() or isAltDown()) then
351+
if not (IsCtrlDown() or IsShiftDown() or IsAltDown()) then
353352
local sel=listBox:getItem()
354353
listBox:arrowKey(key)
355354
if listBox:getItem()~=sel then
@@ -396,7 +395,7 @@ local function scroll(dy)
396395
contents.scroll=MATH.clamp(contents.scroll-dy,0,contents.maxScroll)
397396
end
398397
function scene.mouseMove(x,y,_,dy)
399-
if not WIDGET.isFocus(listBox) and love.mouse.isDown(1) and x and y and inScreen(x,y) then
398+
if not WIDGET.isFocus(listBox) and IsMouseDown(1) and x and y and inScreen(x,y) then
400399
scroll(dy)
401400
end
402401
end
@@ -442,8 +441,8 @@ function scene.update(dt)
442441
end
443442
searchTimer=0
444443
end
445-
if kbIsDown('up','down') and (IsCtrlDown() or IsShiftDown() or isAltDown()) then
446-
scroll(260*dt*(kbIsDown('up') and 1 or -1))
444+
if IsKeyDown('up','down') and (IsCtrlDown() or IsShiftDown() or IsAltDown()) then
445+
scroll(260*dt*(IsKeyDown('up') and 1 or -1))
447446
end
448447
end
449448

@@ -501,7 +500,7 @@ function scene.draw()
501500
local fontH=FONT.get(selected.contentSize):getHeight()
502501
gc_translate(0,-mainH/2+5)
503502
for _,line in next,contents.texts do
504-
if love.keyboard.isDown('f1') then
503+
if IsKeyDown('f1') then
505504
gc_setLineWidth(1)
506505
gc_rectangle('line',15,0,mainW-25,line.height)
507506
end

assets/scene/game_out.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ function scene.mouseUp(x,y,button)
105105
end
106106

107107
function scene.update(dt)
108-
if love.keyboard.isDown('f1') then
108+
if IsKeyDown('f1') then
109109
dt=dt*.1
110-
elseif love.keyboard.isDown('f2') then
110+
elseif IsKeyDown('f2') then
111111
dt=dt*2.6
112112
else
113113
dt=dt*timeScale

assets/scene/mode_exterior.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ end
8181

8282
function scene.mouseMove(x,y,dx,dy)
8383
exMap:hideCursor()
84-
if love.mouse.isDown(1) then
84+
if IsMouseDown(1) then
8585
exMap:moveCam(dx,dy)
8686
else
8787
x,y=SCR.xOy:transformPoint(x,y)

assets/scene/musicroom.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ function scene.update(dt)
266266
end
267267
end
268268
end
269-
if WIDGET.sel~=progressBar or not love.mouse.isDown(1,2,3) and FMOD.music.getPlaying() then
269+
if WIDGET.sel~=progressBar or not IsMouseDown(1,2,3) and FMOD.music.getPlaying() then
270270
local v=FMOD.music.tell()/FMOD.music.getDuration()%1
271271
if _glitchProtect then
272272
if math.abs(fakeProgress-v)<.0026 then

0 commit comments

Comments
 (0)