From 88e23e32f5d35741c669f84d1541a92f2dd0c069 Mon Sep 17 00:00:00 2001 From: MrZ626 <1046101471@qq.com> Date: Mon, 15 Nov 2021 01:53:44 +0800 Subject: [PATCH] =?UTF-8?q?piano=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=94=AF?= =?UTF-8?q?=E6=8C=81shift/ctrl=E5=8D=87=E9=99=8D=E5=8D=8A=E9=9F=B3?= =?UTF-8?q?=EF=BC=8C=E5=B7=A6=E5=8F=B3alt=E5=8F=98=E8=B0=83=EF=BC=8C?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E6=9B=B4=E5=A4=9A=E9=94=AE=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- parts/scenes/app_piano.lua | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/parts/scenes/app_piano.lua b/parts/scenes/app_piano.lua index 46c26fb5..84158faa 100644 --- a/parts/scenes/app_piano.lua +++ b/parts/scenes/app_piano.lua @@ -3,17 +3,19 @@ local kb=love.keyboard local instList={'lead','bell','bass'} local keys={ - ['1']='C6',['2']='D6',['3']='E6',['4']='F6',['5']='G6',['6']='A6',['7']='B6',['8']='C7',['9']='D7',['0']='E7',['-']='F7',['=']='G7', - ['q']='C5',['w']='D5',['e']='E5',['r']='F5',['t']='G5',['y']='A5',['u']='B5',['i']='C6',['o']='D6',['p']='E6',['[']='F6',[']']='G6',['\\']='A6', - ['a']='C4',['s']='D4',['d']='E4',['f']='F4',['g']='G4',['h']='A4',['j']='B4',['k']='C5',['l']='D5',[';']='E5',["'"]='F5', - ['z']='C3',['x']='D3',['c']='E3',['v']='F3',['b']='G3',['n']='A3',['m']='B3',[',']='C4',['.']='D4',['/']='E4', + ['1']=61,['2']=63,['3']=65,['4']=66,['5']=68,['6']=70,['7']=72,['8']=73,['9']=75,['0']=77,['-']=78,['=']=80,['backspace']=82, + ['q']=49,['w']=51,['e']=53,['r']=54,['t']=56,['y']=58,['u']=60,['i']=61,['o']=63,['p']=65,['[']=66,[']']=68,['\\']=70, + ['a']=37,['s']=39,['d']=41,['f']=42,['g']=44,['h']=46,['j']=48,['k']=49,['l']=51,[';']=53,["'"]=54,['return']=56, + ['z']=25,['x']=27,['c']=29,['v']=30,['b']=32,['n']=34,['m']=36,[',']=37,['.']=39,['/']=41, } local inst +local offset local scene={} function scene.sceneInit() inst='lead' + offset=0 end function scene.touchDown(x,y,k) @@ -22,16 +24,20 @@ end scene.mouseDown=scene.touchDown function scene.keyDown(key,isRep) - if isRep then return end - if key=='tab'then + 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 + SFX.playSample(inst,note) + TEXT.show(SFX.getNoteName(note),math.random(150,1130),math.random(140,500),60,'score',.8) + elseif key=='tab'then inst=TABLE.next(instList,inst) - else - local note=keys[key] - if note then - if kb.isDown('lshift','rshift')then note=note:sub(1,1)..'#'..note:sub(2,2)end - SFX.playSample(inst,note) - TEXT.show(note,math.random(150,1130),math.random(140,500),60,'score',.8) - end + elseif key=='lalt'then + offset=math.max(offset-1,-12) + elseif key=='ralt'then + offset=math.min(offset+1,12) + elseif key=='escape'then + SCN.back() end end @@ -42,6 +48,7 @@ end function scene.draw() setFont(30) gc.print(inst,40,60) + gc.print(offset,40,100) end scene.widgetList={