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 sin,cos=math.sin,math.cos 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 y0 then gc.setColor(.95,.95,.95) for j=1,4 do local t=TIME()*3+1.57*j gc.draw(icon,M.x+2.6*cos(t),M.y+2.6*sin(t),nil,k,nil,length,length) end gc.setColor(rankColor[R[M.name]]) else gc.setColor(.6,.6,.6) end gc.draw(icon,M.x,M.y,nil,k,nil,length,length) end --Rank name=text.ranks[R[M.name]] if name then gc.setColor(0,0,0,.8) mStr(name,M.x+M.size*.7,M.y-50-M.size*.7) gc.setColor(.9,.9,.9) mStr(name,M.x+M.size*.7+4,M.y-50-M.size*.7-4) end end end gc.pop() --Score board if sel then local M=MODES[sel] gc.setColor(.7,.7,.7,.5) gc.rectangle("fill",920,0,360,720)--Info board gc.setColor(M.color) setFont(40)mStr(text.modes[sel][1],1100,5) setFont(30)mStr(text.modes[sel][2],1100,50) gc.setColor(1,1,1) setFont(25)gc.printf(text.modes[sel][3],920,110,360,"center") if M.slowMark then gc.draw(IMG.ctrlSpeedLimit,1230,50,nil,.4) end if M.score then mText(drawableText.highScore,1100,240) gc.setColor(.4,.4,.4,.8) gc.rectangle("fill",940,290,320,280)--Highscore board local L=M.records gc.setColor(1,1,1) if L[1]then for i=1,#L do local t=M.scoreDisp(L[i]) local s=#t local f=int((30-s*.4)/5)*5 setFont(f) gc.print(t,955,275+25*i+17-f*.7) setFont(10) _=L[i].date if _ then gc.print(_,1155,284+25*i)end end else mText(drawableText.noScore,1100,370) end end end if mapCam.keyCtrl then gc.setColor(1,1,1) gc.draw(TEXTURE.mapCross,640-20,360-20) end end scene.widgetList={ WIDGET.newKey{name="mod", x=140,y=655,w=220,h=80,font=35,code=goScene"mod"}, WIDGET.newButton{name="start", x=1040,y=655,w=180,h=80,font=40,code=pressKey"return",hide=function()return not mapCam.sel end}, WIDGET.newButton{name="back", x=1200,y=655,w=120,h=80,font=40,code=backScene}, } return scene