Skip to content

Commit

Permalink
优化一大堆小程序的画面比例和帧率和音效
Browse files Browse the repository at this point in the history
整理代码 框架跟进
  • Loading branch information
MrZ626 committed May 15, 2024
1 parent 0cc4a39 commit 44eed47
Show file tree
Hide file tree
Showing 23 changed files with 481 additions and 445 deletions.
2 changes: 1 addition & 1 deletion Zenitha
Submodule Zenitha updated 1 files
+13 −6 gcExtend.lua
10 changes: 10 additions & 0 deletions assets/background/fixColor.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- Customizable grey background
local back={}
local r,g,b=.26,.26,.26
function back.draw()
GC.clear(r,g,b)
end
function back.event(_r,_g,_b)
r,g,b=_r,_g,_b
end
return back
5 changes: 4 additions & 1 deletion assets/gamefunc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,10 @@ function task_unloadGame()
collectgarbage()
end

local isKeyDown=love.keyboard.isDown
getTouches=love.touch.getTouches
isMouseDown=love.mouse.isDown
isKeyDown=love.keyboard.isDown
local isKeyDown=isKeyDown
function isCtrlPressed() return isKeyDown('lctrl','rctrl') end
function isShiftPressed() return isKeyDown('lshift','rshift') end
function isAltPressed() return isKeyDown('lalt','ralt') end
Expand Down
16 changes: 8 additions & 8 deletions assets/scene/app_15p.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ local function notGaming( ) return state~=1 end
local colorSelector=WIDGET.new{type='selector',pos={0,0},x=150,y=240,w=200,text="Color",labelPos='top',labelDistance=20,list={'color1','rainbow','color2','gray','black'},disp=function() return color end,code=function(v) if state~=1 then color=v end end,visibleTick=notGaming}

function scene.enter()
BG.set('rainbow2')
BG.set('space')
board={{1,2,3,4},{5,6,7,8},{9,10,11,12},{13,14,15,16}}
cx,cy=4,4
startTime=0
Expand Down Expand Up @@ -167,7 +167,7 @@ function scene.keyDown(key,isRep)
revKB=not revKB
end
elseif key=='escape' then
SCN.back()
if sureCheck('back') then SCN.back() end
end
return true
end
Expand Down Expand Up @@ -312,13 +312,13 @@ function scene.draw()
end

scene.widgetList={
WIDGET.new{type='button', pos={0,0},x=160, y=100,w=180,h=100,color='lG',fontSize=60,text=CHAR.icon.retry,code=WIDGET.c_pressKey'space'},
WIDGET.new{type='button_fill',pos={0,0},x=160, y=100,w=180,h=100,color='lG',fontSize=60,text=CHAR.icon.retry,code=WIDGET.c_pressKey'space'},
colorSelector,
WIDGET.new{type='checkBox',pos={0,.5},x=240, y=-150,text="Invis",widthLimit=200,fontSize=40,disp=function() return invis end, code=WIDGET.c_pressKey'w',visibleTick=notGaming},
WIDGET.new{type='checkBox',pos={0,.5},x=240, y=-50, text="Slide",widthLimit=200,fontSize=40,disp=function() return slide end, code=WIDGET.c_pressKey'e',visibleTick=notGaming},
WIDGET.new{type='checkBox',pos={0,.5},x=240, y=50, text="Path", widthLimit=200,fontSize=40,disp=function() return pathVis end,code=WIDGET.c_pressKey'r',visibleTick=function() return state~=1 and slide end},
WIDGET.new{type='checkBox',pos={0,.5},x=240, y=150, text="RevKB",widthLimit=200,fontSize=40,disp=function() return revKB end, code=WIDGET.c_pressKey't',visibleTick=notGaming},
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='checkBox', pos={0,.5},x=240, y=-150,text="Invis",widthLimit=200,fontSize=40,disp=function() return invis end, code=WIDGET.c_pressKey'w',visibleTick=notGaming},
WIDGET.new{type='checkBox', pos={0,.5},x=240, y=-50, text="Slide",widthLimit=200,fontSize=40,disp=function() return slide end, code=WIDGET.c_pressKey'e',visibleTick=notGaming},
WIDGET.new{type='checkBox', pos={0,.5},x=240, y=50, text="Path", widthLimit=200,fontSize=40,disp=function() return pathVis end,code=WIDGET.c_pressKey'r',visibleTick=function() return state~=1 and slide end},
WIDGET.new{type='checkBox', pos={0,.5},x=240, y=150, text="RevKB",widthLimit=200,fontSize=40,disp=function() return revKB end, code=WIDGET.c_pressKey't',visibleTick=notGaming},
WIDGET.new{type='button_fill',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
97 changes: 49 additions & 48 deletions assets/scene/app_2048.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
local gc=love.graphics
local setColor,rectangle=gc.setColor,gc.rectangle
local gc_setColor,gc_rectangle=gc.setColor,gc.rectangle

local floor,abs=math.floor,math.abs
local rnd,min=math.random,math.min
Expand Down Expand Up @@ -127,7 +127,7 @@ local function freshMaxTile()
if maxTile==12 then
skipper.cd=0
end
FMOD.effect('reach')
FMOD.effect('beep_notice')
table.insert(progress,("%s - %.3fs"):format(tileName[maxTile],love.timer.getTime()-startTime))
end
local function squash(L)
Expand Down Expand Up @@ -224,7 +224,7 @@ local function skip()
newTile()
FMOD.effect('hold')
else
FMOD.effect('finesseError')
FMOD.effect('beep_down')
end
end
end
Expand All @@ -233,7 +233,7 @@ function scene.enter()
for i=1,#tileName do
tileText[i]=gc.newText(FONT.get(80,'_norm'),tileName[i])
end
BG.set('cubes')
BG.set('space')

invis=false
tapControl=false
Expand Down Expand Up @@ -361,13 +361,13 @@ function scene.draw()
-- Field
gc.setLineWidth(10)
if state==2 then
setColor(.9,.9,0)-- win
gc_setColor(.9,.9,0)-- win
elseif state==1 then
setColor(.9,.9,.9)-- game
gc_setColor(.9,.9,.9)-- game
elseif state==0 then
setColor(.2,.8,.2)-- ready
gc_setColor(.2,.8,.2)-- ready
end
rectangle('line',field.x-10,field.y-10,field.w+20,field.w+20,25)
gc_rectangle('line',field.x-10,field.y-10,field.w+20,field.w+20,25)

for i=1,16 do
if field[i] then
Expand All @@ -377,22 +377,22 @@ function scene.draw()
local textScale=min(field.r/tileText[N]:getWidth(),field.r/tileText[N]:getHeight())/1.26
if i~=prevPos or prevSpawnTime==1 then
if not invis or i==prevPos then
setColor(tileColor[N] or COLOR.D)
rectangle('fill',x,y,r-6,r-6,15)
gc_setColor(tileColor[N] or COLOR.D)
gc_rectangle('fill',x,y,r-6,r-6,15)
if N>=0 then
setColor(N<3 and COLOR.D or COLOR.L)
gc_setColor(N<3 and COLOR.D or COLOR.L)
GC.mDraw(tileText[N],x+r/2,y+r/2,nil,textScale)
end
else
setColor(COLOR.DL)
rectangle('fill',x,y,r-6,r-6,15)
gc_setColor(COLOR.DL)
gc_rectangle('fill',x,y,r-6,r-6,15)
end
else
local c=tileColor[N]
setColor(c[1],c[2],c[3],prevSpawnTime)
rectangle('fill',x,y,r-6,r-6,15)
gc_setColor(c[1],c[2],c[3],prevSpawnTime)
gc_rectangle('fill',x,y,r-6,r-6,15)
c=N<3 and 0 or 1
setColor(c,c,c,prevSpawnTime)
gc_setColor(c,c,c,prevSpawnTime)
GC.mDraw(tileText[N],x+r/2,y+r/2,nil,textScale)
end
end
Expand All @@ -401,38 +401,38 @@ function scene.draw()
-- New tile position
local x,y=1+(prevPos-1)%4,floor((prevPos+3)/4)
gc.setLineWidth(8)
setColor(.2,.8,0,prevSpawnTime)
gc_setColor(.2,.8,0,prevSpawnTime)
local d=25-prevSpawnTime*25
rectangle('line',field.x+field.r*(x-1)+3-d,field.y+field.r*(y-1)+3-d,field.r-6+2*d,field.r-6+2*d,15)
gc_rectangle('line',field.x+field.r*(x-1)+3-d,field.y+field.r*(y-1)+3-d,field.r-6+2*d,field.r-6+2*d,15)

-- Time and moves
FONT.set(50)
setColor(1,1,1)
gc_setColor(COLOR.L)
gc.print(("%.3f"):format(time),1300,10)
gc.print(move,1300,60)

-- Progress time list
FONT.set(20)
setColor(.6,.6,.6)
gc_setColor(.6,.6,.6)
for i=1,#progress do
gc.print(progress[i],1300,120+20*i)
end

-- Score
FONT.set(40)
setColor(1,.7,.7)
gc_setColor(1,.7,.7)
GC.mStr(score,field.x+field.w+180,700)

-- Touch control border line
if tapControl then
gc.setLineWidth(6)
setColor(1,1,1,.2)
gc_setColor(1,1,1,.2)
local r=field.w*.4
gc.line(field.x,field.y,field.x+r,field.y+r)
gc.line(field.x+field.w,field.y,field.x+field.w-r,field.y+r)
gc.line(field.x,field.y+field.w,field.x+r,field.y+field.w-r)
gc.line(field.x+field.w,field.y+field.w,field.x+field.w-r,field.y+field.w-r)
rectangle('line',field.x+r,field.y+r,field.w*.2,field.w*.2,10)
gc_rectangle('line',field.x+r,field.y+r,field.w*.2,field.w*.2,10)
end

-- Skip mark
Expand All @@ -442,7 +442,7 @@ function scene.draw()

-- Skip cooldown
gc.replaceTransform(SCR.xOy_dl)
setColor(1,1,.5)
gc_setColor(1,1,.5)
if skipper.cd and skipper.cd>0 then
FONT.set(50)
GC.mStr(skipper.cd,180,-420)
Expand All @@ -453,57 +453,58 @@ function scene.draw()
gc.setLineWidth(6)
FONT.set(30)
for i=1,2 do
setColor(COLOR[
gc_setColor(
repeater.focus==i and (
love.timer.getTime()%.5>.25 and
'R' or 'Y'
COLOR.R or COLOR.Y
) or (
repeater.seq[i]==repeater.last[i] and
'DL' or 'L'
COLOR.DL or COLOR.L
)
])
rectangle('line',-265,-115+60*i,250,50,5)
)
gc_rectangle('line',-265,-115+60*i,250,50,5)
gc.print(repeater.seq[i],-260,-150+100*i)
end

-- Next & Next indicator
gc.replaceTransform(SCR.xOy_l)
FONT.set(60)
gc_setColor(COLOR.L)
gc.print("Next",50,-35)
if nextTile>1 then setColor(1,.5,.4) end
if nextTile>1 then gc_setColor(1,.5,.4) end
FONT.set(100)
GC.mStr(tileName[nextTile],270,-65)

if nextCD<=12 then
setColor(1,1,1)
gc_setColor(COLOR.L)
for i=1,nextCD do
rectangle('fill',130+i*20-nextCD*8,-70,16,16)
gc_rectangle('fill',130+i*20-nextCD*8,-70,16,16)
end
end

-- Draw no-setting area
gc.replaceTransform(SCR.xOy_ul)
if state==2 then
setColor(1,0,0,.3)
rectangle('fill',30,190,300,140)
gc_setColor(1,0,0,.3)
gc_rectangle('fill',30,190,300,140)
end
end

local function visFunc1() return not tapControl end
scene.widgetList={
WIDGET.new{type='button', pos={0,0},x=160,y=100,w=180,h=100,color='lG',fontSize=60,text=CHAR.icon.retry,code=WIDGET.c_pressKey'r'},
WIDGET.new{type='checkBox',pos={0,0},x=300,y=220,text="Invis",widthLimit=270,fontSize=40,disp=function() return invis end,code=WIDGET.c_pressKey'q',visibleTick=function() return state~=1 end},
WIDGET.new{type='checkBox',pos={0,0},x=300,y=300,text="Tap",widthLimit=270,fontSize=40,disp=function() return tapControl end,code=WIDGET.c_pressKey'w',visibleTick=function() return state~=1 end},

WIDGET.new{type='button', pos={0,1},x=180,y=-280,w=100,text="",fontSize=50,color='Y',code=WIDGET.c_pressKey'up', visibleTick=visFunc1},
WIDGET.new{type='button', pos={0,1},x=180,y=-80, w=100,text="",fontSize=50,color='Y',code=WIDGET.c_pressKey'down', visibleTick=visFunc1},
WIDGET.new{type='button', pos={0,1},x=80, y=-180,w=100,text="",fontSize=50,color='Y',code=WIDGET.c_pressKey'left', visibleTick=visFunc1},
WIDGET.new{type='button', pos={0,1},x=280,y=-180,w=100,text="",fontSize=50,color='Y',code=WIDGET.c_pressKey'right',visibleTick=visFunc1},
WIDGET.new{type='button', pos={0,1},x=180,y=-390,w=100,text="S",fontSize=50,color='Y',code=WIDGET.c_pressKey'space',visibleTick=function() return state==1 and skipper.cd==0 end},
WIDGET.new{type='button', pos={1,.5},x=-140,y=-30,w=250,h=50, color='lX',code=WIDGET.c_pressKey'1', visibleTick=function() return state~=2 end},
WIDGET.new{type='button', pos={1,.5},x=-140,y=30,w=250,h=50, color='lX',code=WIDGET.c_pressKey'2', visibleTick=function() return state~=2 end},
WIDGET.new{type='button', pos={1,.5},x=-300,y=-30,w=50,text=">",fontSize=50,color='R',code=WIDGET.c_pressKey'c1', visibleTick=function() return state~=2 and #repeater.seq[1]~=0 end},
WIDGET.new{type='button', pos={1,.5},x=-300,y=30,w=50, text=">",fontSize=50,color='R',code=WIDGET.c_pressKey'c2', visibleTick=function() return state~=2 and #repeater.seq[2]~=0 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', pos={0,0}, x=160, y=100,w=180,h=100,color='lG',fontSize=60,text=CHAR.icon.retry,code=WIDGET.c_pressKey'r'},
WIDGET.new{type='checkBox',pos={0,0}, x=300, y=220,text="Invis",widthLimit=270,fontSize=40,disp=function() return invis end, code=WIDGET.c_pressKey'q',visibleTick=function() return state~=1 end},
WIDGET.new{type='checkBox',pos={0,0}, x=300, y=300,text="Tap", widthLimit=270,fontSize=40,disp=function() return tapControl end,code=WIDGET.c_pressKey'w',visibleTick=function() return state~=1 end},

WIDGET.new{type='button', pos={0,1}, x=180, y=-280,w=100, sound_trigger=false,text="",fontSize=50,color='Y', code=WIDGET.c_pressKey'up', visibleTick=visFunc1},
WIDGET.new{type='button', pos={0,1}, x=180, y=-80, w=100, sound_trigger=false,text="",fontSize=50,color='Y', code=WIDGET.c_pressKey'down', visibleTick=visFunc1},
WIDGET.new{type='button', pos={0,1}, x=80, y=-180,w=100, sound_trigger=false,text="",fontSize=50,color='Y', code=WIDGET.c_pressKey'left', visibleTick=visFunc1},
WIDGET.new{type='button', pos={0,1}, x=280, y=-180,w=100, sound_trigger=false,text="",fontSize=50,color='Y', code=WIDGET.c_pressKey'right',visibleTick=visFunc1},
WIDGET.new{type='button', pos={0,1}, x=180, y=-390,w=100, sound_trigger=false,text="S",fontSize=50,color='Y', code=WIDGET.c_pressKey'space',visibleTick=function() return state==1 and skipper.cd==0 end},
WIDGET.new{type='button', pos={1,.5},x=-140,y=-30, w=250,h=50,sound_trigger=false, color='lX',code=WIDGET.c_pressKey'1', visibleTick=function() return state~=2 end},
WIDGET.new{type='button', pos={1,.5},x=-140,y=30, w=250,h=50,sound_trigger=false, color='lX',code=WIDGET.c_pressKey'2', visibleTick=function() return state~=2 end},
WIDGET.new{type='button', pos={1,.5},x=-300,y=-30, w=50, sound_trigger=false,text=">",fontSize=50,color='R', code=WIDGET.c_pressKey'c1', visibleTick=function() return state~=2 and #repeater.seq[1]~=0 end},
WIDGET.new{type='button', pos={1,.5},x=-300,y=30, w=50, sound_trigger=false,text=">",fontSize=50,color='R', code=WIDGET.c_pressKey'c2', visibleTick=function() return state~=2 and #repeater.seq[2]~=0 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()},
}
return scene
14 changes: 7 additions & 7 deletions assets/scene/app_AtoZ.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ local state,progress=0
local frameKeyCount,mistake

function scene.enter()
BG.set('rgb')
BG.set('space')
levelName="A_Z"
targetString=levels.A_Z
progress=1
Expand All @@ -58,31 +58,31 @@ function scene.keyDown(key,isRep)
style='score',
duration=.4,
}
FMOD.effect('touch')
FMOD.effect('inputbox_input')
if progress==2 then
state=1
startTime=love.timer.getTime()
elseif progress>#targetString then
time=love.timer.getTime()-startTime
state=2
FMOD.effect('reach')
FMOD.effect('beep_rise')
end
elseif progress>1 then
mistake=mistake+1
FMOD.effect('finesseError')
FMOD.effect('rotate_failed')
end
end
elseif key=='left' or key=='right' then
if state==0 then
scene.widgetList.level:scroll(key=='left' and 1 or -1,0)
scene.widgetList.level:arrowKey(key)
end
elseif key=='space' then
progress=1
mistake=0
time=0
state=0
elseif key=='escape' then
SCN.back()
if sureCheck('back') then SCN.back() end
end
return true
end
Expand Down Expand Up @@ -117,7 +117,7 @@ function scene.draw()

gc.setColor(COLOR.L)
gc.print(targetString:sub(progress,progress),120,280,0,2)
gc.print(targetString:sub(progress+1),310,380)
gc.print(targetString:sub(progress+1),300,380)

gc.setColor(1,1,1,.7)
FONT.set(40)
Expand Down
4 changes: 2 additions & 2 deletions assets/scene/app_UTTT.lua
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ local function place(X,x)
return
end
end
FMOD.effect('reach')
FMOD.effect('beep_rise')
else
if full(board[X]) then
FMOD.effect('emit')
Expand All @@ -98,7 +98,7 @@ local scene={}

function scene.enter()
restart()
BG.set('rainbow')
BG.set('space')
end

function scene.mouseMove(x,y)
Expand Down
Loading

0 comments on commit 44eed47

Please sign in to comment.