diff --git a/LANG/lang_en.lua b/LANG/lang_en.lua index 2a38c818..fb5cddbf 100644 --- a/LANG/lang_en.lua +++ b/LANG/lang_en.lua @@ -531,6 +531,8 @@ return{ p15="15 Puzzle", schulte_G="Schulte Grid", pong="Pong", + AtoZ="A to Z", + UTTT="Ultimate Tic-Tac-Toe", }, p15={ reset="Shuffle", diff --git a/LANG/lang_fr.lua b/LANG/lang_fr.lua index 35ae7e91..64669419 100644 --- a/LANG/lang_fr.lua +++ b/LANG/lang_fr.lua @@ -530,6 +530,8 @@ return{ p15="15 Puzzle", schulte_G="Grille de Schulte", pong="Pong", + -- AtoZ="A to Z", + -- UTTT="Ultimate Tic-Tac-Toe", }, p15={ reset="Réinitialiser", diff --git a/LANG/lang_sp.lua b/LANG/lang_sp.lua index a3f79f34..8f80599d 100644 --- a/LANG/lang_sp.lua +++ b/LANG/lang_sp.lua @@ -535,6 +535,8 @@ return{ p15="Puzzle-15", schulte_G="Grilla Schulte", pong="Pong", + -- AtoZ="A to Z", + -- UTTT="Ultimate Tic-Tac-Toe", }, p15={ reset="Mezclar", diff --git a/LANG/lang_symbol.lua b/LANG/lang_symbol.lua index 2bdcdc15..52a4e2a7 100644 --- a/LANG/lang_symbol.lua +++ b/LANG/lang_symbol.lua @@ -463,11 +463,6 @@ return{ b3b="^^", pc="#<>#", }, - minigame={ - p15="15 Puzzle", - schulte_G="Schulte Grid", - pong="Pong", - }, p15={ reset="!@#$%", color="~~~", diff --git a/LANG/lang_zh.lua b/LANG/lang_zh.lua index 1a5b2ca5..6dcaac06 100644 --- a/LANG/lang_zh.lua +++ b/LANG/lang_zh.lua @@ -534,6 +534,7 @@ return{ schulte_G="舒尔特方格", pong="Pong", AtoZ="A to Z", + UTTT="战略井字棋", }, p15={ reset="打乱", @@ -558,6 +559,9 @@ return{ keyboard="键盘", reset="重置", }, + UTTT={ + reset="重置", + }, savedata={ exportUnlock="导出地图进度", exportData="导出统计数据", diff --git a/LANG/lang_zh2.lua b/LANG/lang_zh2.lua index 4a291881..66db655c 100644 --- a/LANG/lang_zh2.lua +++ b/LANG/lang_zh2.lua @@ -121,6 +121,8 @@ return{ p15="数字华容道", schulte_G="舒尔特方格", pong="弹球", + AtoZ="打字游戏", + UTTT="战略井字棋", }, }, modes={ diff --git a/parts/scenes/UTTT.lua b/parts/scenes/UTTT.lua new file mode 100644 index 00000000..c993810c --- /dev/null +++ b/parts/scenes/UTTT.lua @@ -0,0 +1,246 @@ +local gc=love.graphics +local int=math.floor +local Timer=love.timer.getTime + +local lines={ + {1,2,3}, + {4,5,6}, + {7,8,9}, + {1,4,7}, + {2,5,8}, + {3,6,9}, + {1,5,9}, + {3,5,7}, +} + +local board={{},{},{},{},{},{},{},{},{}} +local score={} + +local lastX,lastx +local curX,curx +local round +local target +local placeTime +local gameover + +local function restart() + lastX,lastx=false,false + curX,curx=nil + round=0 + target=false + placeTime=Timer() + gameover=false + for X=1,9 do + score[X]=false + for x=1,9 do + board[X][x]=false + end + end +end + +local function checkBoard(b,p) + for i=1,8 do + for j=1,3 do + if b[lines[i][j]]~=p then + goto nextLine + end + end + do return true end + ::nextLine:: + end +end + +local function place(X,x) + board[X][x]=round + lastX,lastx=X,x + curX,curx=nil + placeTime=Timer() + if checkBoard(board[X],round)then + score[X]=round + if checkBoard(score,round)then + gameover=round + return + else + for i=1,9 do + if not score[i]then + goto continueGame + end + end + gameover=true + do return end + ::continueGame:: + end + else + for i=1,9 do + if not board[X][i]then + goto continueGame + end + end + score[X]=true + ::continueGame:: + end + if score[x]then + target=false + else + target=x + end + round=1-round +end + +function sceneInit.UTTT() + restart() + BG.set("bg2") +end + + +function Pnt.UTTT() + gc.push("transform") + --origin pos:0,140; scale:4 + gc.translate(280,0) + gc.scale(8) + + --Draw board + gc.setColor(0,0,0,.4) + gc.rectangle("fill",0,0,90,90) + + --Draw target area + gc.setColor(1,1,1,math.sin((Timer()-placeTime)*5)/5+.2) + if target then + gc.rectangle("fill",(target-1)%3*30,int((target-1)/3)*30,30,30) + else + gc.rectangle("fill",0,0,90,90) + end + + --Draw cursor + if curX then + gc.setColor(1,1,1,.3) + gc.rectangle("fill",(curX-1)%3*30+(curx-1)%3*10-.5,int((curX-1)/3)*30+int((curx-1)/3)*10-.5,11,11) + end + + gc.setLineWidth(.8) + for X=1,9 do + if score[X]then + if score[X]==0 then + gc.setColor(.5,0,0) + elseif score[X]==1 then + gc.setColor(0,0,.5) + else + gc.setColor(.5,.5,.5) + end + gc.rectangle("fill",(X-1)%3*30,int((X-1)/3)*30,30,30) + end + for x=1,9 do + local c=board[X][x] + if c then + if c==0 then + gc.setColor(1,.2,.2) + gc.circle( + "line", + 5+(X-1)%3*30+(x-1)%3*10, + 5+int((X-1)/3)*30+int((x-1)/3)*10, + 3.5 + ) + else + gc.setColor(.3,.3,1) + gc.line( + 2+(X-1)%3*30+(x-1)%3*10, + 2+int((X-1)/3)*30+int((x-1)/3)*10, + 8+(X-1)%3*30+(x-1)%3*10, + 8+int((X-1)/3)*30+int((x-1)/3)*10 + ) + gc.line( + 2+(X-1)%3*30+(x-1)%3*10, + 8+int((X-1)/3)*30+int((x-1)/3)*10, + 8+(X-1)%3*30+(x-1)%3*10, + 2+int((X-1)/3)*30+int((x-1)/3)*10 + ) + end + end + end + end + + --Draw board line + gc.setLineWidth(.8) + for x=0,9 do + gc.setColor(1,1,1,x%3==0 and 1 or .3) + gc.line(10*x,0,10*x,90) + gc.line(0,10*x,90,10*x) + end + + --Draw last pos + if lastX then + gc.setColor(.5,1,.4,.8) + local r=.5+.5*math.sin(Timer()*6.26) + gc.rectangle("line",(lastX-1)%3*30+(lastx-1)%3*10-r,int((lastX-1)/3)*30+int((lastx-1)/3)*10-r,10+2*r,10+2*r) + end + gc.pop() + + if gameover then + --Draw result + setFont(60) + if gameover==0 then + gc.setColor(1,.6,.6) + mStr("RED\nWON",1140,200) + elseif gameover==1 then + gc.setColor(.6,.6,1) + mStr("BLUE\nWON",1140,200) + else + gc.setColor(.8,.8,.8) + mStr("TIE",1140,240) + end + else + --Draw current round mark + gc.setColor(.8,.8,.8,.8) + gc.rectangle("fill",80,80,160,160) + gc.setColor(1,1,1) + gc.setLineWidth(6) + gc.rectangle("line",80,80,160,160) + + gc.setLineWidth(10) + if round==0 then + gc.setColor(1,0,0) + gc.circle("line",160,160,50) + else + gc.setColor(0,0,1) + gc.line(160-45,160-45,160+45,160+45) + gc.line(160-45,160+45,160+45,160-45) + end + end +end + +function touchDown.UTTT(_,x,y) + mouseMove.UTTT(x,y) +end + +function touchMove.UTTT(_,x,y) + mouseMove.UTTT(x,y) +end + +function touchUp.UTTT(_,x,y) + mouseDown.UTTT(x,y) +end + +function mouseMove.UTTT(x,y) + x,y=int((x-280)/80),int(y/80) + curX,curx=int(x/3)+int(y/3)*3+1,x%3+y%3*3+1 + if + curX<1 or curX>9 or + curx<1 or curx>9 or + score[curX]or + not(target==curX or not target)or + board[curX][curx]or + gameover + then + curX,curx=nil + end +end + +function mouseDown.UTTT(x,y) + mouseMove.UTTT(x,y) + if curX then place(curX,curx)end +end + +WIDGET.init("UTTT",{ + WIDGET.newButton({name="reset",x=1140,y=540,w=170,h=80,font=40,color="lGreen",code=restart}), + WIDGET.newButton({name="back",x=1140,y=640,w=170,h=80,font=40,code=WIDGET.lnk_BACK}), +}) \ No newline at end of file diff --git a/parts/scenes/minigame.lua b/parts/scenes/minigame.lua index 200391d6..0e18c559 100644 --- a/parts/scenes/minigame.lua +++ b/parts/scenes/minigame.lua @@ -7,5 +7,6 @@ WIDGET.init("minigame",{ WIDGET.newButton({name="schulte_G", x=640, y=250,w=350,h=120,font=40,code=WIDGET.lnk_goScene("schulte_G")}), WIDGET.newButton({name="pong", x=1040, y=250,w=350,h=120,font=40,code=WIDGET.lnk_goScene("pong")}), WIDGET.newButton({name="AtoZ", x=240, y=400,w=350,h=120,font=40,code=WIDGET.lnk_goScene("AtoZ")}), + WIDGET.newButton({name="UTTT", x=640, y=400,w=350,h=120,font=30,code=WIDGET.lnk_goScene("UTTT")}), WIDGET.newButton({name="back", x=1140, y=640,w=170,h=80,font=40,code=WIDGET.lnk_BACK}), }) \ No newline at end of file