local gc=love.graphics local gc_setColor=gc.setColor local tc=love.touch local max,sin=math.max,math.sin local SCR=SCR local VK=virtualkey local onVirtualkey=onVirtualkey local pressVirtualkey=pressVirtualkey local updateVirtualkey=updateVirtualkey local noTouch,noKey=false,false local touchMoveLastFrame=false local scene={} function scene.sceneInit() love.keyboard.setKeyRepeat(false) if GAME.init then resetGameData() GAME.init=false end noKey=GAME.replaying noTouch=not SETTING.VKSwitch or noKey end scene.mouseDown=NULL local function restart() resetGameData(GAME.frame<240 and"q") noKey=GAME.replaying end function scene.touchDown(_,x,y) if noTouch then return end local t=onVirtualkey(x,y) if t then PLAYERS[1]:pressKey(t) pressVirtualkey(t,x,y) end end function scene.touchUp(_,x,y) if noTouch then return end local t=onVirtualkey(x,y) if t then PLAYERS[1]:releaseKey(t) end end function scene.touchMove() if noTouch or touchMoveLastFrame then return end touchMoveLastFrame=true local L=tc.getTouches() for i=#L,1,-1 do L[2*i-1],L[2*i]=SCR.xOy:inverseTransformPoint(tc.getPosition(L[i])) end for n=1,#VK do local B=VK[n] if B.ava then for i=1,#L,2 do if(L[i]-B.x)^2+(L[i+1]-B.y)^2<=B.r^2 then goto continue end end PLAYERS[1]:releaseKey(n) end ::continue:: end end function scene.keyDown(key) local k=keyMap.keyboard[key] if k then if k>0 then if noKey then return end PLAYERS[1]:pressKey(k) VK[k].isDown=true VK[k].pressTime=10 else restart() end elseif key=="escape"then pauseGame() end end function scene.keyUp(key) if noKey then return end local k=keyMap.keyboard[key] if k then if k>0 then PLAYERS[1]:releaseKey(k) VK[k].isDown=false end elseif key=="back"then pauseGame() end end function scene.gamepadDown(key) if noKey then return end local k=keyMap.joystick[key] if k then if k>0 then PLAYERS[1]:pressKey(k) VK[k].isDown=true VK[k].pressTime=10 else restart() end elseif key=="back"then pauseGame() end end function scene.gamepadUp(key) if noKey then return end local k=keyMap.joystick[key] if k then if k>0 then PLAYERS[1]:releaseKey(k) VK[k].isDown=false end elseif key=="back"then pauseGame() end end function scene.update(dt) local _ local P1=PLAYERS[1] local GAME=GAME GAME.frame=GAME.frame+1 touchMoveLastFrame=false --Update virtualkey animation updateVirtualkey() --Replay if GAME.replaying then _=GAME.replaying local L=GAME.rep while GAME.frame==L[_]do local key=L[_+1] if key==0 then--Just wait elseif key<=32 then--Press key P1:pressKey(key) pressVirtualkey(key) elseif key<=64 then--Release key P1:releaseKey(key-32) VK[key-32].isDown=false end _=_+2 end GAME.replaying=_ end --Counting,include pre-das,directy RETURN,or restart counting if GAME.frame<=180 then if GAME.frame==180 then gameStart() elseif GAME.frame==60 or GAME.frame==120 then SFX.play("ready") end for p=1,#PLAYERS do local P=PLAYERS[p] if P.movDir~=0 then if P.moving