Skip to content

Commit

Permalink
继续优化一大堆小程序的画面比例和帧率和音效
Browse files Browse the repository at this point in the history
框架跟进(SYSFX更新)
  • Loading branch information
MrZ626 committed May 16, 2024
1 parent b9a5d3a commit c89676b
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 109 deletions.
2 changes: 1 addition & 1 deletion Zenitha
2 changes: 1 addition & 1 deletion assets/progress.lua
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ function PROGRESS.setEnv(env)
elseif env=='exterior' then
PROGRESS.setExteriorBG()
PROGRESS.playExteriorBGM()
ZENITHA.setClickFX(function(x,y) SYSFX.new('glow',2,x,y,20) end)
ZENITHA.setClickFX(function(x,y) SYSFX.glow(.5,x,y,20) end)
function ZENITHA.globalEvent.drawCursor(_,x,y)
if not SETTINGS.system.sysCursor then
gc.setColor(1,1,1)
Expand Down
4 changes: 2 additions & 2 deletions assets/scene/app_15p.lua
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ local function tapBoard(x,y,key)
if state<2 then
if not key then
if pathVis then
SYSFX.new('rect',6,x-5,y-5,11,11,1,1,1)
SYSFX.rect(.16,x-5,y-5,11,11,1,1,1)
end
x,y=floor((x-SCR.w0/2)/160/scale)+3,floor((y-SCR.h0/2)/160/scale)+3
end
Expand Down Expand Up @@ -145,7 +145,7 @@ function scene.keyDown(key,isRep)
move,push=0,0
elseif key=='q' then
if state~=1 then
colorSelector:scroll(love.keyboard.isDown('lshift','rshift') and -1 or 1)
colorSelector:scroll(isKeyDown('lshift','rshift') and -1 or 1)
end
elseif key=='w' then
if state==0 then
Expand Down
2 changes: 1 addition & 1 deletion assets/scene/app_2048.lua
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ function scene.keyDown(key,isRep)
elseif key=='r' then reset()
elseif key=='q' then if state==0 then invis=not invis end
elseif key=='w' then if state==0 then tapControl=not tapControl end
elseif key=='1' or key=='2' then (love.keyboard.isDown('lshift','lctrl','lalt') and playRep or setFocus)(key=='1' and 1 or 2)
elseif key=='1' or key=='2' then (isKeyDown('lshift','lctrl','lalt') and playRep or setFocus)(key=='1' and 1 or 2)
elseif key=='c1' then playRep(1)
elseif key=='c2' then playRep(2)
elseif key=='return' then
Expand Down
5 changes: 2 additions & 3 deletions assets/scene/app_calc.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local gc=love.graphics
local kb=love.keyboard

---@type Zenitha.Scene
local scene={}
Expand All @@ -23,11 +22,11 @@ end

scene.mouseDown=NULL
function scene.keyDown(key)
if kb.isDown('lshift','rshift') then
if isKeyDown('lshift','rshift') then
if key=='=' then
scene.keyDown('+')
return true
elseif kb.isDown('lshift','rshift') and key=='8' then
elseif isKeyDown('lshift','rshift') and key=='8' then
scene.keyDown('*')
return true
end
Expand Down
8 changes: 4 additions & 4 deletions assets/scene/app_cubefield.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
local gc,kb,tc=love.graphics,love.keyboard,love.touch
local gc,tc=love.graphics,love.touch
local rnd,floor,abs=math.random,math.floor,math.abs
local max,min=math.max,math.min
local setFont,mStr=FONT.set,GC.mStr
Expand Down Expand Up @@ -71,7 +71,7 @@ function scene.touchDown(x)
end
function scene.touchUp(x)
if play then
local L=tc.getTouches()
local L=getTouches()
if x<640 then
for i=1,#L do
if tc.getPosition(L[i])>640 then
Expand Down Expand Up @@ -114,9 +114,9 @@ end
function scene.keyUp(key)
if play then
if key=='left' or key=='a' then
moveDir=kb.isDown('right','d') and 1 or 0
moveDir=isKeyDown('right','d') and 1 or 0
elseif key=='right' or key=='d' then
moveDir=kb.isDown('left','a') and -1 or 0
moveDir=isKeyDown('left','a') and -1 or 0
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions assets/scene/app_dtw.lua
Original file line number Diff line number Diff line change
Expand Up @@ -276,10 +276,10 @@ function scene.keyDown(key,isRep)
elseif state==0 then
if key=='tab' then
local mode1=mode
modeSelector:scroll(love.keyboard.isDown('lshift','rshift') and 1 or -1,0)
modeSelector:scroll(isShiftPressed() and 1 or -1,0)
if mode1~=mode then reset() end
elseif key=='q' then
colorSelector:scroll(love.keyboard.isDown('lshift','rshift') and 1 or -1,0)
colorSelector:scroll(isShiftPressed() and 1 or -1,0)
elseif key=='w' then
arcade=not arcade
end
Expand Down
8 changes: 3 additions & 5 deletions assets/scene/app_link.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
local ms=love.mouse
local msIsDown,kbIsDown=ms.isDown,love.keyboard.isDown
local gc=love.graphics
local gc_setColor,gc_rectangle,gc_draw=gc.setColor,gc.rectangle,gc.draw
local setFont,mStr=FONT.set,GC.mStr
Expand Down Expand Up @@ -98,7 +96,7 @@ local function resetBoard()

noComboBreak=true
comboTime=comboTime+2
SYSFX.new('rect',2,field.x,field.y,field.w,field.h,.8,.8,.8)
SYSFX.rect(.5,field.x,field.y,field.w,field.h,.8,.8,.8)
end
local function newGame()
state=0
Expand Down Expand Up @@ -272,7 +270,7 @@ function scene.keyDown(key,isRep)
newGame()
end
elseif key=='z' or key=='x' then
love.mousepressed(ms.getPosition())
love.mousepressed(love.mouse.getPosition())
elseif key=='escape' then
if state~=1 then
if sureCheck('back') then SCN.back() end
Expand All @@ -290,7 +288,7 @@ local function touch(x,y)
tap(x,y)
end
function scene.mouseDown(x,y,k) if k==1 or k==2 or not k then touch(x,y) end end
function scene.mouseMove(x,y) if (msIsDown(1) or kbIsDown('z','x')) then touch(x,y) end end
function scene.mouseMove(x,y) if (isMouseDown(1) or isKeyDown('z','x')) then touch(x,y) end end
function scene.touchDown(x,y) touch(x,y) end
function scene.touchMove(x,y) touch(x,y) end

Expand Down
5 changes: 2 additions & 3 deletions assets/scene/app_piano.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
local gc=love.graphics
local kb=love.keyboard

local instList={'square_wave','triangle_wave','sine_wave'}
local keys={
Expand Down Expand Up @@ -30,8 +29,8 @@ scene.mouseDown=scene.touchDown
function scene.keyDown(key,isRep)
if not isRep and keys[key] then
local note=keys[key]+offset
if kb.isDown('lshift','rshift') then note=note+1 end
if kb.isDown('lctrl','rctrl') then note=note-1 end
if isShiftPressed() then note=note+1 end
if isCtrlPressed() then note=note-1 end
activeEventMap[key]=FMOD.effect(inst,{
tune=note-21,
volume=1,
Expand Down
128 changes: 69 additions & 59 deletions assets/scene/app_schulteG.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
local gc,ms=love.graphics,love.mouse
local floor,rnd=math.floor,math.random
local rem=table.remove
local setFont,mStr=FONT.set,GC.mStr
local gc=love.graphics

---@type Zenitha.Scene
local scene={}
Expand All @@ -12,6 +9,24 @@ local startTime,time
local state,progress=0
local tapFX,mistake

local area={
x=350,y=50,
w=900,h=900,
}
local fontSizes={
[3]=100,
[4]=100,
[5]=90,
[6]=80,
}

local function setState(v)
state=v
scene.widgetList.rank._visible=state==0
scene.widgetList.invis._visible=state~=1
scene.widgetList.disappear._visible=state~=1
scene.widgetList.tapFX._visible=state~=1
end
function scene.enter()
BG.set('space')
board={}
Expand All @@ -23,8 +38,8 @@ function scene.enter()
startTime=0
time=0
mistake=0
state=0
progress=0
setState(0)
end

local function newBoard()
Expand All @@ -33,80 +48,75 @@ local function newBoard()
L[i]=i
end
for i=1,rank^2 do
board[i]=rem(L,rnd(#L))
board[i]=table.remove(L,math.random(#L))
end
end
local function tapBoard(x,y)
local R=rank
if x>320 and x<960 and y>40 and y<680 then
if MATH.between(x,area.x,area.x+area.w) and MATH.between(y,area.y,area.y+area.h) then
if state==0 then
newBoard()
state=1
setState(1)
startTime=love.timer.getTime()
progress=0
elseif state==1 then
local X=floor((x-320)/640*R)
local Y=floor((y-40)/640*R)
local R=rank
local X=math.floor((x-area.x)/area.w*R)
local Y=math.floor((y-area.y)/area.h*R)
x=R*Y+X+1
if board[x]==progress+1 then
progress=progress+1
if progress<R^2 then
FMOD.effect('lock')
FMOD.effect('touch')
else
time=love.timer.getTime()-startTime+mistake
state=2
setState(2)
FMOD.effect('beep_rise')
end
if tapFX then
SYSFX.newShade(3,320+640/R*X,40+640/R*Y,640/R,640/R,.6,.8,1)
SYSFX.rect(.26,area.x+area.w/R*X,area.y+area.h/R*Y,area.w/R,area.h/R,.6,.8,1)
end
else
mistake=mistake+1
if tapFX then
SYSFX.newShade(2,320+640/R*X,40+640/R*Y,640/R,640/R,1,.4,.5)
SYSFX.rect(.5,area.x+area.w/R*X,area.y+area.h/R*Y,area.w/R,area.h/R,1,.4,.5)
end
FMOD.effect('rotate_failed')
FMOD.effect('move_failed')
end
end
end
end

function scene.mouseDown(x,y)
tapBoard(x,y)
if state~=0 then tapBoard(x,y) end
end
function scene.touchDown(x,y)
tapBoard(x,y)
if state~=0 then tapBoard(x,y) end
end
function scene.keyDown(key,isRep)
if isRep then return true end
if key=='z' or key=='x' then
love.mousepressed(ms.getPosition())
local x,y=love.mouse.getPosition()
love.mousepressed(x,y,1)
elseif key=='space' then
if state>0 then
board={}
time=0
mistake=0
state=0
setState(0)
progress=0
end
elseif key=='q' then
if state==0 then
invis=not invis
end
elseif key=='w' then
if state==0 then
disappear=not disappear
end
elseif key=='e' then
if state==0 then
tapFX=not tapFX
end
elseif key=='3' or key=='4' or key=='5' or key=='6' then
if state==0 then
rank=tonumber(key)
end
elseif key=='escape' then
if sureCheck('back') then SCN.back() end
elseif state==0 then
if key=='q' then
invis=not invis
elseif key=='w' then
disappear=not disappear
elseif key=='e' then
tapFX=not tapFX
elseif key=='3' or key=='4' or key=='5' or key=='6' then
rank=tonumber(key)
end
end
return true
end
Expand All @@ -118,16 +128,16 @@ function scene.update()
end

function scene.draw()
setFont(40)
FONT.set(40)
gc.setColor(COLOR.L)
gc.print(("%.3f"):format(time),1026,80)
gc.print(mistake,1026,150)
gc.print(("%.3f"):format(time),1350,80)
gc.print(mistake,1350,150)

setFont(70)
mStr(state==1 and progress or state==0 and "Ready" or state==2 and "Win",1130,300)
FONT.set(70)
GC.mStr(state==1 and progress or state==0 and "Ready" or state==2 and "Win",1400,300)

gc.setColor(COLOR.dX)
gc.rectangle('fill',310,30,660,660)
gc.rectangle('fill',area.x-10,area.y-10,area.w+20,area.h+20)
if state==2 then
gc.setColor(.9,.9,0)-- win
elseif state==1 then
Expand All @@ -136,47 +146,47 @@ function scene.draw()
gc.setColor(.2,.8,.2)-- ready
end
gc.setLineWidth(10)
gc.rectangle('line',310,30,660,660)
gc.rectangle('line',area.x-10,area.y-10,area.w+20,area.h+20)

-- Draw no-setting area
if state==2 then
gc.setColor(1,0,0,.3)
gc.rectangle('fill',15,295,285,250)
gc.rectangle('fill',35,295,285,250)
end

local width=640/rank
local width=area.w/rank
local mono=state==0 or invis and state==1 and progress>0
gc.setLineWidth(4)
local f=180-rank*20
setFont(f)
local f=fontSizes[rank]
FONT.set(f)
for i=1,rank do
for j=1,rank do
local N=board[rank*(i-1)+j]
if not (state==1 and disappear and N<=progress) then
gc.setColor(.4,.5,.6)
gc.rectangle('fill',320+(j-1)*width,(i-1)*width+40,width,width)
gc.rectangle('fill',area.x+(j-1)*width,area.y+(i-1)*width,width,width)
gc.setColor(COLOR.L)
gc.rectangle('line',320+(j-1)*width,(i-1)*width+40,width,width)
gc.rectangle('line',area.x+(j-1)*width,area.y+(i-1)*width,width,width)
if not mono then
local x,y=320+(j-.5)*width,40+(i-.5)*width-f*.67
local x,y=area.x+(j-.5)*width,area.y+(i-.5)*width-f*.67
gc.setColor(.1,.1,.1)
mStr(N,x-3,y-1)
mStr(N,x-1,y-3)
GC.mStr(N,x-3,y-1)
GC.mStr(N,x-1,y-3)
gc.setColor(COLOR.L)
mStr(N,x,y)
GC.mStr(N,x,y)
end
end
end
end
end

scene.widgetList={
WIDGET.new{type='button', x=160,y=100,w=180,h=100,color='lG',fontSize=60,text=CHAR.icon.retry,code=WIDGET.c_pressKey'space',visibleTick=function() return state~=0 end},
WIDGET.new{type='slider', x=130,y=250,widthLimit=105,w=150,axis={3,6,1},valueShow=false,fontSize=40,disp=function() return rank end,code=function(v) rank=v end,visibleTick=function() return state==0 end},
WIDGET.new{type='checkBox',x=240,y=330,widthLimit=200,fontSize=40,disp=function() return invis end,code=WIDGET.c_pressKey'q',visibleTick=function() return state~=1 end},
WIDGET.new{type='checkBox',x=240,y=420,widthLimit=200,fontSize=40,disp=function() return disappear end,code=WIDGET.c_pressKey'w',visibleTick=function() return state~=1 end},
WIDGET.new{type='checkBox',x=240,y=510,widthLimit=200,fontSize=40,disp=function() return tapFX end,code=WIDGET.c_pressKey'e',visibleTick=function() return state~=1 end},
WIDGET.new{type='button', pos={1,1},x=-120,y=-80,w=160,h=80,sound_trigger='button_back',fontSize=60,text=CHAR.icon.back,code=WIDGET.c_backScn()},
WIDGET.new{type='button', x=180,y=100,w=180,h=100,color='lG',fontSize=60,text=CHAR.icon.retry,code=WIDGET.c_pressKey'space',visibleTick=function() return state~=0 end},
WIDGET.new{type='slider' ,name='rank', text="Rank", x=150,y=250,widthLimit=105,w=150,axis={3,6,1},valueShow=false,fontSize=40,disp=function() return rank end,code=function(v) rank=v end},
WIDGET.new{type='checkBox',name='invis', text="Invisible",x=280,y=330,widthLimit=200,fontSize=40,disp=function() return invis end,code=WIDGET.c_pressKey'q'},
WIDGET.new{type='checkBox',name='disappear',text="Disappear",x=280,y=420,widthLimit=200,fontSize=40,disp=function() return disappear end,code=WIDGET.c_pressKey'w'},
WIDGET.new{type='checkBox',name='tapFX', text="TapEffect",x=280,y=510,widthLimit=200,fontSize=40,disp=function() return tapFX end,code=WIDGET.c_pressKey'e'},
WIDGET.new{type='button',pos={1,1},x=-120,y=-80,w=160,h=80,sound_trigger='button_back',fontSize=60,text=CHAR.icon.back,code=WIDGET.c_backScn()},
}

return scene
Loading

0 comments on commit c89676b

Please sign in to comment.