diff --git a/BGM/32000Hz 86kbps b/BGM/32000Hz 86kbps new file mode 100644 index 00000000..e69de29b diff --git a/button.lua b/button.lua index 660c5adb..0bfeb332 100644 --- a/button.lua +++ b/button.lua @@ -34,8 +34,9 @@ Buttons={ end, up=4,down=7,left=6 }, - {x=435,y=250,w=320,h=60,rgb=color.white,t="Advanced settings",code=function()gotoScene("setting2")end,up=1,down=7,right=5}, - {x=640,y=590,w=180,h=60,rgb=color.white,t="Back",code=function()back()end,up=6}, + {x=435,y=220,w=320,h=60,rgb=color.green,t="Advanced settings",code=function()gotoScene("setting2")end,up=1,down=7,right=5}, + {x=435,y=300,w=320,h=60,rgb=color.yellow,t="Touch settings",code=function()gotoScene("setting3")end,up=6,down=8,right=5}, + {x=640,y=590,w=210,h=60,rgb=color.white,t="Save&Back",code=function()back()end,up=6}, }, setting2={ {x=290,y=70 ,w=160,h=45,rgb=color.white,t=function()return setting.key[1]end,code=function()keysetting,gamepadsetting=1 end,up=1,down=2,right=10}, @@ -52,7 +53,7 @@ Buttons={ {x=540,y=130,w=230,h=45,rgb=color.white,t=function()return setting.gamepad[2]end,code=function()gamepadsetting,keysetting=2 end,up=10,down=12,left=2,right=19}, {x=540,y=190,w=230,h=45,rgb=color.white,t=function()return setting.gamepad[3]end,code=function()gamepadsetting,keysetting=3 end,up=11,down=13,left=3,right=23}, {x=540,y=250,w=230,h=45,rgb=color.white,t=function()return setting.gamepad[4]end,code=function()gamepadsetting,keysetting=4 end,up=12,down=14,left=4,right=23}, - {x=540,y=310,w=230,h=45,rgb=color.white,t=function()return setting.gamepad[5]end,code=function()gamepadsetting,keysetting=5 end,up=13,down=15,left=5,right=28}, + {x=540,y=310,w=230,h=45,rgb=color.white,t=function()return setting.gamepad[5]end,code=function()gamepadsetting,keysetting=5 end,up=13,down=15,left=5,right=23}, {x=540,y=370,w=230,h=45,rgb=color.white,t=function()return setting.gamepad[6]end,code=function()gamepadsetting,keysetting=6 end,up=14,down=16,left=6,right=28}, {x=540,y=430,w=230,h=45,rgb=color.white,t=function()return setting.gamepad[7]end,code=function()gamepadsetting,keysetting=7 end,up=15,down=17,left=7,right=28}, {x=540,y=490,w=230,h=45,rgb=color.white,t=function()return setting.gamepad[8]end,code=function()gamepadsetting,keysetting=8 end,up=16,down=18,left=8,right=28}, @@ -69,9 +70,40 @@ Buttons={ {x=1125,y=150,w=40,h=40,rgb=color.white,t="+",code=function()setting.sdarr=(setting.sdarr+1)%4 end,up=22,down=28,left=25}, --23~26 {x=405,y=630,w=130,h=60,rgb=color.white,t="Reset",code=function()for i=1,#setting.key do setting.key[i]=gameEnv0.key[i] end end,up=9,right=28}, - {x=840,y=630,w=180,h=60,rgb=color.white,t="Back",code=function()keysetting=nil;back()end,up=9,left=27}, + {x=840,y=630,w=180,h=60,rgb=color.white,t="Back",code=function()keysetting=nil;back()end,up=24,left=27}, --27~28 }, + setting3={ + {x=500,y=310,w=120,h=80,rgb=color.white,t="Reset",code=function() + for K=1,#virtualkey do + local b,b0=virtualkey[K],gameEnv0.virtualkey[K] + b[1],b[2],b[3],b[4]=b0[1],b0[2],b0[3],b0[4] + end--Reset virtualkey + end,down=4,right=2}, + {x=640,y=310,w=120,h=80,rgb=color.white,t="Snap",code=function() + for K=1,#virtualkey do + local b=virtualkey[K] + b[1],b[2]=int(b[1]*.025+.5)*40,int(b[2]*.025+.5)*40 + end--Make virtualkey neat + end,down=5,left=1,right=3}, + {x=780,y=310,w=120,h=80,rgb=color.white,t=function()return percent0to5[setting.virtualkeyAlpha]end,code=function() + setting.virtualkeyAlpha=(setting.virtualkeyAlpha+1)%6 + --Adjust virtualkey alpha + end,down=6,left=2}, + {x=500,y=410,w=120,h=80,rgb=color.white,t="Icon",code=function() + setting.virtualkeyIcon=not setting.virtualkeyIcon + --Switch virtualkey icon + end,up=1,right=6}, + {x=640,y=410,w=120,h=80,rgb=color.white,t="Back",code=function()back()end,up=2,left=4,right=3}, + {x=780,y=410,w=120,h=80,rgb=color.white,t="Size",code=function() + for K=1,#virtualkey do + local b=virtualkey[K] + b[4]=b[4]+10 + if b[4]==150 then b[4]=40 end + b[3]=b[4]^2 + end + end,up=3,left=5}, + }, help={ {x=640,y=590,w=180,h=60,rgb=color.white,t="Back",code=function()back()end}, }, @@ -86,26 +118,19 @@ for k,v in pairs(Buttons)do end end -gamepad={ - {x=80,y=-80,r=80},--moveLeft - {x=240,y=-80,r=80},--moveRight - {x=-240,y=-80,r=80},--rotRight - {x=-400,y=-80,r=80},--rotLeft - {x=-240,y=-240,r=80},--rotFlip - {x=-80,y=-80,r=80},--hardDrop - {x=-80,y=-240,r=80},--softDrop - {x=-80,y=-400,r=80},--hold - {x=80,y=80,r=80},--restart -} ---[[ +virtualkey={ + {80,720-80,6400,80},--moveLeft + {240,720-80,6400,80},--moveRight + {1280-240,720-80,6400,80},--rotRight + {1280-400,720-80,6400,80},--rotLeft + {1280-240,720-240,6400,80},--rotFlip + {1280-80,720-80,6400,80},--hardDrop + {1280-80,720-240,6400,80},--softDrop + {1280-80,720-400,6400,80},--hold + {80,80,6400,80},--restart + --[[ {x=0,y=0,r=0},--toLeft {x=0,y=0,r=0},--toRight {x=0,y=0,r=0},--toDown -]] -for i=1,#gamepad do - gamepad[i].press=false - if gamepad[i].x<0 then gamepad[i].x=1280+gamepad[i].x end - if gamepad[i].y<0 then gamepad[i].y=720+gamepad[i].y end - gamepad[i].r0=gamepad[i].r - gamepad[i].r=gamepad[i].r0^2 -end \ No newline at end of file + ]] +} \ No newline at end of file diff --git a/conf.lua b/conf.lua index 07e32573..1da4cd02 100644 --- a/conf.lua +++ b/conf.lua @@ -5,11 +5,10 @@ function love.conf(t) t.version="11.1" t.console=X t.accelerometerjoystick=X--Enable the accelerometer on iOS and Android by exposing it as a Joystick (boolean) - t.externalstorage=X t.gammacorrect=true - -- t.audio.mixwithsystem=true--Keep background music playing when opening LOVE (boolean, iOS and Android only) + t.audio.mixwithsystem=true--Switch on to keep background music playing - t.window.title="Techmino V0.2" + t.window.title="Techmino V0.3" t.window.icon="/image/icon.png" t.window.width=1280 t.window.height=720 @@ -27,7 +26,7 @@ function love.conf(t) t.window.highdpi=X--Enable high-dpi mode for the window on a Retina display (boolean) t.window.x=nil t.window.y=nil - + t.modules.window=true t.modules.system=true t.modules.audio=true @@ -43,6 +42,7 @@ function love.conf(t) t.modules.sound=true t.modules.timer=true t.modules.touch=true + t.modules.physics=X t.modules.thread=X t.modules.video=X diff --git a/control.lua b/control.lua index 7c580a84..4f9a52aa 100644 --- a/control.lua +++ b/control.lua @@ -1,3 +1,18 @@ +function onVirtualkey(x,y) + local x,y=convert(x,y) + local d2,nearest,distance + for K=1,#virtualkey do + local b=virtualkey[K] + d2=(x-b[1])^2+(y-b[2])^2 + if d20 and 1 or i<0 and -1 or 0 end -function stringPack(s,v)return s..toS(v).."\r\n"end +function sgn(i)return i>0 and 1 or i<0 and -1 or 0 end--Row numbe is A-uth-or's id! +function stringPack(s,v)return s..toS(v)end function without(t,v) for i=1,#t do if t[i]==v then return nil end end return true end -function nextLanguage() - for i=1,#languages do - if setting.lang==languages[i]then return languages[i+1]or"eng"end - end -end function mStr(s,x,y)gc.printf(s,x-500,y,1000,"center")end function convert(x,y) return x*screenK,(y-screenM)*screenK @@ -689,13 +683,16 @@ function resetGameData() PTC.dust[i]=PTC.dust[0]:clone() PTC.dust[i]:start() end + for i=1,#virtualkey do + virtualkey[i].press=false + end stat.game=stat.game+1 freeRow={} + collectgarbage() for i=1,50*#players do freeRow[i]={0,0,0,0,0,0,0,0,0,0} end - collectgarbage() end function startGame(mode) --rec="" @@ -725,14 +722,22 @@ function loaddata() elseif t=="fullscreen"then setting.fullscreen=v=="true" love.window.setFullscreen(setting.fullscreen) - elseif t=="lang"then - if not Fonts[v]then v="eng"end - setting.lang=v - setFont=fontLib[v] elseif t=="keyset"then v=string.splitS(v) for i=#v+1,8 do v[i]="N/A"end setting.key=v + elseif t=="virtualkey"then + v=string.splitS(v,"/") + for i=1,9 do + virtualkey[i]=string.splitS(v[i],",") + for j=1,4 do + virtualkey[i][j]=toN(virtualkey[i][j]) + end + end + elseif t=="virtualkeyAlpha"then + setting.virtualkeyAlpha=int(abs(toN(v))) + elseif t=="virtualkeyIcon"then + setting.virtualkeyIcon=v=="true" --Settings elseif t=="das"or t=="arr"or t=="sddas"or t=="sdarr"then v=toN(v)if not v or v<0 then v=0 end @@ -748,27 +753,38 @@ function loaddata() end end function savedata() - local t="" - t=t..stringPack("sfx=",setting.sfx) - t=t..stringPack("bgm=",setting.bgm) - t=t..stringPack("fullscreen=",setting.fullscreen) - t=t..stringPack("lang=",setting.lang) + local vk={} + for i=1,9 do + for j=1,4 do + virtualkey[i][j]=int(virtualkey[i][j]+.5) + end--Saving a integer is better? + vk[i]=table.concat(virtualkey[i],",") + end--pre-pack virtualkey setting - t=t..stringPack("run=",stat.run) - t=t..stringPack("game=",stat.game) - t=t..stringPack("gametime=",stat.gametime) - t=t..stringPack("piece=",stat.piece) - t=t..stringPack("row=",stat.row) - t=t..stringPack("atk=",stat.atk) - t=t..stringPack("key=",stat.key) - t=t..stringPack("rotate=",stat.rotate) - t=t..stringPack("hold=",stat.hold) - t=t..stringPack("spin=",stat.spin) - t=t..stringPack("das=",setting.das) - t=t..stringPack("arr=",setting.arr) - t=t..stringPack("sddas=",setting.sddas) - t=t..stringPack("sdarr=",setting.sdarr) - t=t..stringPack("keyset=",string.concat(setting.key)) + local t=table.concat({ + stringPack("sfx=",setting.sfx), + stringPack("bgm=",setting.bgm), + stringPack("fullscreen=",setting.fullscreen), + + stringPack("run=",stat.run), + stringPack("game=",stat.game), + stringPack("gametime=",stat.gametime), + stringPack("piece=",stat.piece), + stringPack("row=",stat.row), + stringPack("atk=",stat.atk), + stringPack("key=",stat.key), + stringPack("rotate=",stat.rotate), + stringPack("hold=",stat.hold), + stringPack("spin=",stat.spin), + stringPack("das=",setting.das), + stringPack("arr=",setting.arr), + stringPack("sddas=",setting.sddas), + stringPack("sdarr=",setting.sdarr), + stringPack("keyset=",table.concat(setting.key,"/")), + stringPack("virtualkey=",table.concat(vk,"/")), + stringPack("virtualkeyAlpha=",setting.virtualkeyAlpha), + stringPack("virtualkeyIcon=",setting.virtualkeyIcon), + },"\r\n") --t=love.math.compress(t,"zlib"):getString() userdata:open("w") userdata:write(t) @@ -1059,7 +1075,7 @@ function drop() SFX("spin_"..cc) stat.spin=stat.spin+1 elseif #clearing<#field then - P.b2b=P.b2b-400 + P.b2b=P.b2b-300 showText(clearName[cc],"appear",50) csend=cc-1 sendTime=20+csend*20 @@ -1174,7 +1190,7 @@ function keyDown.play(key) local k=players[1].gameEnv.key for i=1,11 do if key==k[i]then - pressKey(i,players[1]) + pressKey(i) break end end @@ -1206,7 +1222,7 @@ function gamepadDown.play(key) local k=players[1].gameEnv.gamepad for i=1,11 do if key==k[i]then - pressKey(i,players[1]) + pressKey(i) break end end @@ -1278,7 +1294,7 @@ function love.update(dt) end --scene swapping & Timer end -function love.draw()print(mouseShow) +function love.draw() Pnt.BG[curBG]() gc.setColor(1,1,1,.3) for n=1,#BGblock do @@ -1308,9 +1324,6 @@ function love.draw()print(mouseShow) numFont(20)gc.setColor(1,1,1) gc.print(tm.getFPS(),0,700) gc.print(gcinfo(),0,680) - -- numFont(80) - -- gc.print(gcinfo(),400,370) - --if gcinfo()>500 then collectgarbage()end end function love.resize(x,y) @@ -1319,19 +1332,8 @@ function love.resize(x,y) gc.origin() gc.scale(1/screenK,1/screenK) gc.translate(0,screenM) -end -function love.focus(f) - focus=f - if f then - ms.setVisible(false) - if bgmPlaying then bgm[bgmPlaying]:play()end - else - ms.setVisible(true) - if bgmPlaying then bgm[bgmPlaying]:pause()end - end -end +end function love.run() - love.focus(true) local frameT=Timer() tm.step() love.resize(nil,gc.getHeight()) @@ -1340,19 +1342,35 @@ function love.run() return function() love.event.pump() for name,a,b,c,d,e,f in love.event.poll()do - if name=="quit"then - savedata() - return 0 - end + if name=="quit"then return 0 end love.handlers[name](a,b,c,d,e,f) end - -- if focus then + if focus then tm.step() love.update(tm.getDelta()) - gc.clear(1,1,1) + gc.clear() love.draw() gc.present() - -- end + if not wd.hasFocus()then + focus=false + ms.setVisible(true) + if bgmPlaying then bgm[bgmPlaying]:pause()end + if scene=="play"then + for i=1,#players[1].keyPressing do + if players[1].keyPressing[i]then + releaseKey(i) + end + end + end + end + else + tm.sleep(.1) + if wd.hasFocus()then + focus=true + ms.setVisible(false) + if bgmPlaying then bgm[bgmPlaying]:play()end + end + end while Timer()-frameT<1/60 do end frameT=Timer() end @@ -1360,30 +1378,22 @@ end --System callbacks do--Texture/Image - mouseIcon=gc.newImage("/image/mouseIcon.png") - local p=gc.newImage("/image/block.png") - local l={} - gc.setColor(1,1,1) - for i=1,13 do - l[i]=gc.newCanvas(30,30) - gc.setCanvas(l[i]) - gc.draw(p,30-30*i) - end - blockSkin=l - l={} - for i=1,1 do - local p=gc.newImage("/image/BG/"..i..".png") - l[i]=gc.newCanvas(1536,1536) - gc.setCanvas(l[i]) - gc.draw(p,nil,nil,nil,12,12) - end - background=l - gamepadIcon={} - for i=1,9 do - gamepadIcon[i]=gc.newImage("/image/gamepadIcon/"..(actName[i])..".png") - end titleImage=gc.newImage("/image/title.png") - gc.setCanvas() + mouseIcon=gc.newImage("/image/mouseIcon.png") + blockSkin={} + for i=1,13 do + blockSkin[i]=gc.newImage("/image/block/1/"..i..".png") + end + background={} + gc.setColor(1,1,1) + background={} + for i=1,2 do + background[i]=gc.newImage("/image/BG/"..i..".png") + end + virtualkeyIcon={} + for i=1,9 do + virtualkeyIcon[i]=gc.newImage("/image/virtualkey/"..(actName[i])..".png") + end end do--Particle PTC={dust={}}--Particle systems @@ -1420,11 +1430,10 @@ do--Particle gc.setCanvas() end c=nil + userdata=fs.newFile("userdata") if fs.getInfo("userdata")then loaddata() end -stat.run=stat.run+1 -setFont=fontLib[setting.lang] -Text=Texts[setting.lang] \ No newline at end of file +stat.run=stat.run+1 \ No newline at end of file diff --git a/paint.lua b/paint.lua index 1043ae85..0fe64d13 100644 --- a/paint.lua +++ b/paint.lua @@ -77,22 +77,48 @@ function drawPixel(y,x,id,alpha) gc.setColor(1,1,1,alpha) gc.draw(blockSkin[id],30*x-30,600-30*y) end +function drawVirtualkey() + gc.setLineWidth(10) + gc.setColor(1,1,1,setting.virtualkeyAlpha*.2) + for i=1,#virtualkey do + local b=virtualkey[i] + gc.circle("line",b[1],b[2],b[4]-5) + if setting.virtualkeyIcon then gc.draw(virtualkeyIcon[i],b[1],b[2],nil,2*b[4]*.0125,nil,18,18)end + end +end Pnt={BG={}} function Pnt.BG.none() - gc.clear(.1,.1,.1) + gc.clear(.2,.2,.2) +end +function Pnt.BG.glow() + local t=((sin(Timer()*.5)+sin(Timer()*.7)+sin(Timer()*.9+1)+sin(Timer()*1.5)+sin(Timer()*2+3))+5)*.05 + gc.clear(t,t,t) end function Pnt.BG.game1() gc.setColor(1,1,1) - gc.draw(background[1],640,360,Timer()*.15,nil,nil,768,768) + gc.draw(background[1],640,360,Timer()*.15,12,nil,64,64) end function Pnt.BG.game2() gc.setColor(1,.5,.5) - gc.draw(background[1],640,360,Timer()*.2,nil,nil,768,768) + gc.draw(background[1],640,360,Timer()*.2,12,nil,64,64) end function Pnt.BG.game3() gc.setColor(.6,.6,1) - gc.draw(background[1],640,360,Timer()*.25,nil,nil,768,768) + gc.draw(background[1],640,360,Timer()*.25,12,nil,64,64) +end +function Pnt.BG.rgb() + gc.clear( + sin(Timer()*1.2)*.15+.5, + sin(Timer()*1.5)*.15+.5, + sin(Timer()*1.9)*.15+.5 + ) +end +function Pnt.BG.strap() + gc.setColor(1,1,1) + local x=Timer()%32*40 + gc.draw(background[2],x,0,nil,10) + gc.draw(background[2],x-1280,0,nil,10) end function Pnt.load() @@ -109,7 +135,7 @@ end function Pnt.main() gc.setColor(1,1,1) setFont(30) - gc.print("Alpha V0.2",370,150) + gc.print("Alpha V0.3",370,150) if system==2 then gc.print("Android",530,110) end @@ -121,7 +147,7 @@ function Pnt.play() setmetatable(_G,P.index) gc.push("transform") gc.translate(x,y)gc.scale(size)--Scale - gc.setColor(0,0,0,.8)gc.rectangle("fill",0,0,600,690)--Black Background + gc.setColor(0,0,0,.7)gc.rectangle("fill",0,0,600,690)--Black Background gc.setLineWidth(3) gc.setColor(1,1,1)gc.rectangle("line",0,0,600,690)--Big frame gc.translate(150,70) @@ -247,19 +273,21 @@ function Pnt.play() bonus[i]:draw() end--Effects - gc.setColor(1,1,1) - setFont(40) - gc.print(format("%0.2f",time),-125,530)--Draw time - if mesDisp[gamemode]then mesDisp[gamemode]()end--Draw other message + if P.size>.3 then + gc.setColor(1,1,1) + setFont(40) + gc.print(format("%0.2f",time),-125,530)--Draw time + if mesDisp[gamemode]then mesDisp[gamemode]()end--Draw other message - setFont(15) - gc.setColor(1,1,1) - gc.print("BPM",380,490) - gc.print("KPM",335,580) - setFont(30) - drawDial(350,520,dropSpeed) - drawDial(400,570,keySpeed) - --Speed dials + setFont(15) + gc.setColor(1,1,1) + gc.print("BPM",380,490) + gc.print("KPM",335,580) + setFont(30) + drawDial(350,520,dropSpeed) + drawDial(400,570,keySpeed) + --Speed dials + end gc.pop() end--Draw players gc.setColor(1,1,1) @@ -268,13 +296,7 @@ function Pnt.play() end setmetatable(_G,nil) if system==2 then - gc.setColor(1,1,1,.8) - gc.setLineWidth(5) - for i=1,#gamepad do - local k=gamepad[i] - gc.circle("line",k.x,k.y,k.r0) - gc.draw(gamepadIcon[i],k.x,k.y,nil,3,nil,18,18) - end + drawVirtualkey() end end function Pnt.setting2() @@ -292,31 +314,42 @@ function Pnt.setting2() gc.print("<<",keysetting and 380 or 670,60*(keysetting or gamepadsetting)-10) end end +function Pnt.setting3() + drawVirtualkey() + gc.setLineWidth(3) + gc.setColor(1,1,1,sin(Timer()*4)*.1+.1) + for i=1,31 do + gc.line(40*i,0,40*i,720) + end + for i=1,17 do + gc.line(0,40*i,1280,40*i) + end +end function Pnt.help() setFont(32) gc.setColor(1,1,1) for i=1,11 do mStr(Text.help[i],640,15+43*i) end - gc.draw(img.title[setting.lang],180,600,.2,.7+.05*sin(Timer()*2),nil,140,100) + gc.draw(titleImage,180,600,.2,.7+.05*sin(Timer()*2),nil,140,100) end function Pnt.stat() setFont(30) gc.setColor(1,1,1) for i=1,10 do - gc.print(Text.stat[i],250,20+40*i) + gc.print(Text.stat[i],350,20+40*i) end - gc.print(stat.run,600,60) - gc.print(stat.game,600,100) - gc.print(format("%0.2f",stat.gametime).."s",600,140) - gc.print(stat.piece,600,180) - gc.print(stat.row,600,220) - gc.print(stat.atk,600,260) - gc.print(stat.key,600,300) - gc.print(stat.rotate,600,340) - gc.print(stat.hold,600,380) - gc.print(stat.spin,600,420) + gc.print(stat.run,650,60) + gc.print(stat.game,650,100) + gc.print(format("%0.2f",stat.gametime).."s",650,140) + gc.print(stat.piece,650,180) + gc.print(stat.row,650,220) + gc.print(stat.atk,650,260) + gc.print(stat.key,650,300) + gc.print(stat.rotate,650,340) + gc.print(stat.hold,650,380) + gc.print(stat.spin,650,420) - gc.draw(img.title[setting.lang],260,570,.2+.07*sin(Timer()*3),.8,nil,250,60) + gc.draw(titleImage,260,570,.2+.07*sin(Timer()*3),.8,nil,250,60) end \ No newline at end of file diff --git a/timer.lua b/timer.lua index d994b1b6..782adffc 100644 --- a/timer.lua +++ b/timer.lua @@ -56,23 +56,6 @@ function Tmr.play(dt) end -- Update attack beam - local list=tc.getTouches() - for K=1,#gamepad do - local b=gamepad[K] - local press=false - for k,v in ipairs(list)do - local x,y=convert(tc.getPosition(v)) - if (x-b.x)^2+(y-b.y)^2