setZoom(false) ;add true to enable zooming or false to disable setZoomMin(0.25) ;Amount of zoom setZoomMax(1.0) ;Maximum amount of zoom setZoomSpeed(1.0) ;Speed at which the game zooms in and out
function animPosDraw(a, x, y) animSetPos(a, x, y) animDraw(a) end
function textImgPosDraw(ti, x, y) textImgSetPos(ti, x, y) textImgDraw(ti) end
function createTextImg(font, bank, aline, text, x, y) local ti = textImgNew() textImgSetFont(ti, font) textImgSetBank(ti, bank) textImgSetAlign(ti, aline) textImgSetText(ti, text) textImgSetPos(ti, x, y) return ti end
function btnPalNo(cmd) local s = 0 if commandGetState(cmd, 'holds') then s = 6 end if commandGetState(cmd, 'a') then return 1 + s end if commandGetState(cmd, 'b') then return 2 + s end if commandGetState(cmd, 'c') then return 3 + s end if commandGetState(cmd, 'x') then return 4 + s end if commandGetState(cmd, 'y') then return 5 + s end if commandGetState(cmd, 'z') then return 6 + s end return 0 end
function p1TmSub() if commandGetState(p1Cmd, 'u') then sndPlay(sysSnd, 100, 0) p1TeamMode = p1TeamMode - 1 if p1TeamMode < 0 then p1TeamMode = 2 end elseif commandGetState(p1Cmd, 'd') then sndPlay(sysSnd, 100, 0) p1TeamMode = p1TeamMode + 1 if p1TeamMode > 2 then p1TeamMode = 0 end elseif p1TeamMode == 2 then if commandGetState(p1Cmd, 'l') then sndPlay(sysSnd, 100, 0) p1NumTurns = p1NumTurns - 1 if p1NumTurns < 1 then p1NumTurns = 1 end elseif commandGetState(p1Cmd, 'r') then sndPlay(sysSnd, 100, 0) p1NumTurns = p1NumTurns + 1 if p1NumTurns > 4 then p1NumTurns = 4 end end end textImgDraw(p1SelTmTxt) textImgDraw(p1SingleTxt) textImgDraw(p1SimulTxt) textImgDraw(p1TurnsTxt) animUpdate(p1TmIcon) animPosDraw(p1TmIcon, 80, 66) animPosDraw(p1TmIcon, 86, 66) for i = 1, p1NumTurns do animPosDraw(p1TmIcon, 74 + i*6, 81) end animUpdate(p1TmCursor) animPosDraw(p1TmCursor, 10, 47 + p1TeamMode*15) if btnPalNo(p1Cmd) > 0 then sndPlay(sysSnd, 100, 1) setTeamMode(1, p1TeamMode, p1NumTurns) p1Selected = {} p1SelEnd = false p1Task = p1SelSub end end
function p2TmSub() if commandGetState(p2Cmd, 'u') then sndPlay(sysSnd, 100, 0) p2TeamMode = p2TeamMode - 1 if p2TeamMode < 0 then p2TeamMode = 2 end elseif commandGetState(p2Cmd, 'd') then sndPlay(sysSnd, 100, 0) p2TeamMode = p2TeamMode + 1 if p2TeamMode > 2 then p2TeamMode = 0 end elseif p2TeamMode == 2 then if commandGetState(p2Cmd, 'r') then sndPlay(sysSnd, 100, 0) p2NumTurns = p2NumTurns - 1 if p2NumTurns < 1 then p2NumTurns = 1 end elseif commandGetState(p2Cmd, 'l') then sndPlay(sysSnd, 100, 0) p2NumTurns = p2NumTurns + 1 if p2NumTurns > 4 then p2NumTurns = 4 end end end textImgDraw(p2SelTmTxt) textImgDraw(p2SingleTxt) textImgDraw(p2SimulTxt) textImgDraw(p2TurnsTxt) animUpdate(p2TmIcon) animPosDraw(p2TmIcon, 240, 66) animPosDraw(p2TmIcon, 234, 66) for i = 1, p2NumTurns do animPosDraw(p2TmIcon, 246 - i*6, 81) end animUpdate(p2TmCursor) animPosDraw(p2TmCursor, 310, 47 + p2TeamMode*15) if btnPalNo(p2Cmd) > 0 then sndPlay(sysSnd, 100, 1) setTeamMode(2, p2TeamMode, p2NumTurns) p2Selected = {} p2SelEnd = false p2Task = p2SelSub end end
------------------------------------------------------------ p1Cursor = animNew(sysSff, [[ 160,0, 0,0, -1 ;Cursor animation for player #1 ]]) animSetScale(p1Cursor, 5.0/selectColumns, 5.0/selectColumns)
function p1DrawSelectName() local y = 162 for i = 1, #p1Selected do textImgSetText(p1NameTxt, getCharName(p1Selected)) textImgPosDraw(p1NameTxt, 10, y) y = y + 7 end return y end
function p1SelSub() local n = p1SelOffset + p1SelX + selectColumns*p1SelY p1Portrait = n local y = p1DrawSelectName() if not p1SelEnd then if commandGetState(p1Cmd, 'su') then sndPlay(sysSnd, 100, 0) p1SelY = p1SelY - 20 elseif commandGetState(p1Cmd, 'sd') then sndPlay(sysSnd, 100, 0) p1SelY = p1SelY + 20 elseif commandGetState(p1Cmd, 'u') then sndPlay(sysSnd, 100, 0) p1SelY = p1SelY - 1 elseif commandGetState(p1Cmd, 'd') then sndPlay(sysSnd, 100, 0) p1SelY = p1SelY + 1 elseif commandGetState(p1Cmd, 'l') then sndPlay(sysSnd, 100, 0) p1SelX = p1SelX - 1 elseif commandGetState(p1Cmd, 'r') then sndPlay(sysSnd, 100, 0) p1SelX = p1SelX + 1 end if p1SelY < 0 then p1SelOffset = p1SelOffset + selectColumns*p1SelY p1SelY = 0 elseif p1SelY >= selectRows then p1SelOffset = p1SelOffset + selectColumns*(p1SelY - (selectRows - 1)) p1SelY = selectRows - 1 end if p1SelX < 0 then p1SelX = selectColumns - 1 elseif p1SelX >= selectColumns then p1SelX = 0 end animUpdate(p1Cursor) animPosDraw( p1Cursor, 10 + 29*p1SelX*5.0/selectColumns, 170 + 29*p1SelY*5.0/selectColumns) textImgSetText(p1NameTxt, getCharName(n)) textImgPosDraw(p1NameTxt, 10, y) local selval = selectChar(1, n, btnPalNo(p1Cmd)) if selval > 0 then sndPlay(sysSnd, 100, 1) p1Selected[#p1Selected+1] = n end if selval == 2 then p1SelEnd = true if p2In == 1 then p2Task = p2TmSub commandBufReset(p2Cmd, p2In) end end end end
------------------------------------------------------------ p2Cursor = animNew(sysSff, [[ 170,0, 0,0, -1 ;Cursor animation for player #1 ]]) animSetScale(p2Cursor, 5.0/selectColumns, 5.0/selectColumns)
function p2DrawSelectName() local y = 162 for i = 1, #p2Selected do textImgSetText(p2NameTxt, getCharName(p2Selected)) textImgPosDraw(p2NameTxt, 310, y) y = y + 7 end return y end
function p2SelSub() local n = p2SelOffset + p2SelX + selectColumns*p2SelY p2Portrait = n local y = p2DrawSelectName() if not p2SelEnd then if commandGetState(p2Cmd, 'su') then sndPlay(sysSnd, 100, 0) p2SelY = p2SelY - 20 elseif commandGetState(p2Cmd, 'sd') then sndPlay(sysSnd, 100, 0) p2SelY = p2SelY + 20 elseif commandGetState(p2Cmd, 'u') then sndPlay(sysSnd, 100, 0) p2SelY = p2SelY - 1 elseif commandGetState(p2Cmd, 'd') then sndPlay(sysSnd, 100, 0) p2SelY = p2SelY + 1 elseif commandGetState(p2Cmd, 'l') then sndPlay(sysSnd, 100, 0) p2SelX = p2SelX - 1 elseif commandGetState(p2Cmd, 'r') then sndPlay(sysSnd, 100, 0) p2SelX = p2SelX + 1 end if p2SelY < 0 then p2SelOffset = p2SelOffset + selectColumns*p2SelY p2SelY = 0 elseif p2SelY >= selectRows then p2SelOffset = p2SelOffset + selectColumns*(p2SelY - (selectRows - 1)) p2SelY = selectRows - 1 end if p2SelX < 0 then p2SelX = selectColumns - 1 elseif p2SelX >= selectColumns then p2SelX = 0 end animUpdate(p2Cursor) animPosDraw( p2Cursor, 169 + 29*p2SelX*5.0/selectColumns, 170 + 29*p2SelY*5.0/selectColumns) textImgSetText(p2NameTxt, getCharName(n)) textImgPosDraw(p2NameTxt, 310, y) local selval = selectChar(2, n, btnPalNo(p2Cmd)) if selval > 0 then sndPlay(sysSnd, 100, 1) p2Selected[#p2Selected+1] = n end if selval == 2 then p2SelEnd = true if p1In == 2 then p1Task = p1TmSub commandBufReset(p1Cmd, p1In) end end end end
function selStageSub() if commandGetState(p1Cmd, 'l') then sndPlay(sysSnd, 100, 0) stageNo = setStage(stageNo - 1) elseif commandGetState(p1Cmd, 'r') then sndPlay(sysSnd, 100, 0) stageNo = setStage(stageNo + 1) elseif commandGetState(p1Cmd, 'u') then sndPlay(sysSnd, 100, 0) stageNo = setStage(stageNo - 10) elseif commandGetState(p1Cmd, 'd') then sndPlay(sysSnd, 100, 0) stageNo = setStage(stageNo + 10) end textImgSetText( selStageTxt, 'Stage ' .. stageNo .. ': ' .. getStageName(stageNo)) textImgDraw(selStageTxt) if btnPalNo(p1Cmd) > 0 then selectStage(stageNo) selMode = false end end
------------------------------------------------------------ selBG = animNew(sysSff, [[ 100,0, 0,0, -1 ;Animation for background ]]) animSetTile(selBG, 1, 1) ;Tile for x and y axis animSetColorKey(selBG, -1) animSetScale(selBG, 0.5, 0.5) ;Scale x and y of the background
selBox = animNew(sysSff, [[ 100,1, 0,0, -1 ]]) animSetTile(selBox, 1, 0) ;Tile for x and y axis animSetColorKey(selBox, -1) animSetAlpha(selBox, 1, 255) ;Set alpha transparency animSetPos(selBox, 0, 166) ;Starting position of the animation animSetWindow(selBox, 5, 0, 151, 240) ;The visible area that's allowed. The first two numbers 5 and zero set the left and right box.
function bgSub() animAddPos(selBG, 1, 1) ;The x and y axis that the background will scroll animUpdate(selBG) animDraw(selBG) animAddPos(selBox, 0, -1) ;The x and y axis that the image will scroll animUpdate(selBox) animDraw(selBox) animAddPos(selBox2, 1, 0) ;The x and y axis that the image will scroll animUpdate(selBox2) animDraw(selBox2) end
function randSel(pno, winner) if pno == winner then return end setTeamMode(pno, math.random(0, 1)*2, math.random(1, 4)) while selectChar(pno, math.random(0, 100000000), math.random(1, 12)) < 2 do end end
------------------------------------------------------------ --メインループ ------------------------------------------------------------ while selMode do if esc() then return end bgSub() if p1Portrait then drawPortrait(p1Portrait, 18, 13, 1, 1) end if p2Portrait then drawPortrait(p2Portrait, 302, 13, -1, 1) end drawFace(10, 170, p1SelOffset) drawFace(169, 170, p2SelOffset) if p1SelEnd and p2SelEnd then selStageSub() end p2Task() p1Task() cmdInput() refresh() end for i = 1, 20 do animDraw(selBG) local k = 0 for j = 1, #p1Selected do local scl = 10000.0 / (10000.0 - k*i) local tmp = i*k / 20 drawPortrait(p1Selected[j], 18 - tmp, 13 + tmp/3, scl, scl) k = k + 48 end k = 0 for j = 1, #p2Selected do local scl = 10000.0 / (10000.0 - k*i) local tmp = i*k / 20 drawPortrait(p2Selected[j], 302 + tmp, 13 + tmp/3, -scl, scl) k = k + 48 end p1DrawSelectName() p2DrawSelectName() textImgDraw(loading) refresh() end while true do local winner = game() if true or winner < 0 or gameMode ~= 0 then break end randSel(1, winner) randSel(2, winner) loadStart() end playBGM(bgm) end end
function modeSel() while true do exitNetPlay() exitReplay()
while btnPalNo(p1Cmd) <= 0 do if commandGetState(p1Cmd, 'u') then sndPlay(sysSnd, 100, 0) gameMode = gameMode - 1 elseif commandGetState(p1Cmd, 'd') then sndPlay(sysSnd, 100, 0) gameMode = gameMode + 1 end if gameMode < 0 then gameMode = 6 elseif gameMode > 6 then gameMode = 0 end textImgDraw(watchMode) textImgDraw(p1VsComTxt) textImgDraw(p1VsP2) textImgDraw(netplay) textImgDraw(portChange) textImgDraw(replay) textImgDraw(comVsP1) animUpdate(p1TmCursor) animPosDraw(p1TmCursor, 95, 77 + 20*gameMode) cmdInput() refresh() end sndPlay(sysSnd, 100, 1)
local cancel = false
if gameMode == 0 then setAutoLevel(false) elseif gameMode == 1 then setCom(1, 0) elseif gameMode == 2 then p2In = 2 setCom(1, 0) setCom(2, 0) elseif gameMode == 3 then p2In = 2 setCom(1, 0) setCom(2, 0) inputDialogPopup(inputdia, 'Input Server') while not inputDialogIsDone(inputdia) do refresh() end textImgSetText( connecting, 'Now connecting.. ' .. inputDialogGetStr(inputdia) .. ' ' .. getListenPort()) enterNetPlay(inputDialogGetStr(inputdia)) while not connected() do if esc() then cancel = true break end textImgDraw(connecting) refresh() end if not cancel then init() synchronize() math.randomseed(sszRandom()) end elseif gameMode == 4 then inputDialogPopup(inputdia, 'Input Port') while not inputDialogIsDone(inputdia) do refresh() end setListenPort(inputDialogGetStr(inputdia)) cancel = true elseif gameMode == 5 then p2In = 2 setCom(1, 0) setCom(2, 0) enterReplay('replay/netplay.replay') init() synchronize() math.randomseed(sszRandom()) elseif gameMode == 6 then remapInput(1, 2) remapInput(2, 1) p1In = 2 p2In = 2 setCom(2, 0) end if not cancel then main() end end end