piano小程序支持shift/ctrl升降半音,左右alt变调,补充更多键位
This commit is contained in:
@@ -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={
|
||||
|
||||
Reference in New Issue
Block a user