local mt=love.math local gc=love.graphics local ms,kb,tc=love.mouse,love.keyboard,love.touch local max,min=math.max,math.min local int,abs=math.floor,math.abs local mapCam={ sel=false,--Selected mode ID xOy=mt.newTransform(0,0,0,1),--Transformation for map display keyCtrl=false,--If controlling with key --For auto zooming when enter/leave scene zoomMethod=false, zoomK=false, } local touchDist local scene={} function scene.sceneInit(org) BG.set() destroyPlayers() local cam=mapCam cam.zoomK=org=="main"and 5 or 1 end local function getK() return abs(mapCam.xOy:transformPoint(1,0)-mapCam.xOy:transformPoint(0,0)) end local function getPos() return mapCam.xOy:inverseTransformPoint(0,0) end local function onMode(x,y) x,y=x-640,y-360 x,y=mapCam.xOy:inverseTransformPoint(x,y) for name,M in next,MODES do if RANKS[name]and M.x then local s=M.size if M.shape==1 then if x>M.x-s and xM.y-s and y1300 and dx<0 or x<-1500 and dx>0 then dx=0 end if y>420 and dy<0 or y<-1900 and dy>0 then dy=0 end mapCam.xOy:translate(dx/k,dy/k) end function scene.wheelMoved(_,dy) mapCam.keyCtrl=false local k=getK() k=min(max(k+dy*.1,.3),1.6)/k mapCam.xOy:scale(k) local x,y=getPos() mapCam.xOy:translate(x*(1-k),y*(1-k)) end function scene.mouseMove(_,_,dx,dy) if ms.isDown(1)then moveMap(dx,dy) end mapCam.keyCtrl=false end function scene.mouseClick(x,y) local _=mapCam.sel if not _ or x<920 then local SEL=onMode(x,y) if _~=SEL then if SEL then mapCam.moving=true _=MODES[SEL] mapCam.sel=SEL SFX.play("click") else mapCam.sel=false end elseif _ then scene.keyDown("return") end end mapCam.keyCtrl=false end function scene.touchDown() touchDist=false end function scene.touchMove(x,y,dx,dy) local L=tc.getTouches() if not L[2]then moveMap(dx,dy) elseif not L[3]then x,y=SCR.xOy:inverseTransformPoint(tc.getPosition(L[1])) dx,dy=SCR.xOy:inverseTransformPoint(tc.getPosition(L[2]))--Not delta!!! local d=(x-dx)^2+(y-dy)^2 if d>100 then d=d^.5 if touchDist then scene.wheelMoved(nil,(d-touchDist)*.02) end touchDist=d end end mapCam.keyCtrl=false end function scene.touchClick(x,y) scene.mouseClick(x,y) end function scene.keyDown(key) if key=="return"then if mapCam.sel then mapCam.keyCtrl=false loadGame(mapCam.sel) end elseif key=="f1"then SCN.go("mod") elseif key=="escape"then if mapCam.sel then mapCam.sel=false else SCN.back() end end end function scene.update() local dx,dy=0,0 local F if not SCN.swapping then if kb.isDown("up", "w")then dy=dy+10 F=true end if kb.isDown("down","s")then dy=dy-10 F=true end if kb.isDown("left","a")then dx=dx+10 F=true end if kb.isDown("right","d")then dx=dx-10 F=true end local js1=joysticks[1] if js1 then local dir=js1:getAxis(1) if dir~="c"then if dir=="u"or dir=="ul"or dir=="ur"then dy=dy+10 F=true end if dir=="d"or dir=="dl"or dir=="dl"then dy=dy-10 F=true end if dir=="l"or dir=="ul"or dir=="dl"then dx=dx+10 F=true end if dir=="r"or dir=="ur"or dir=="dr"then dx=dx-10 F=true end end end end if F then mapCam.keyCtrl=true moveMap(dx,dy) local x,y=getPos() for name,M in next,MODES do if RANKS[name]and M.x then local SEL local s=M.size if M.shape==1 then if x>M.x-s and xM.y-s and y