fc2ブログ
Top Page › 未整理 › 【Luarida】オリジナルゲーム「覚えたか?」紹介

2011 · 02 · 28 (Mon) 00:54

【Luarida】オリジナルゲーム「覚えたか?」紹介

また、ゲーム作りました。
どこかでみたことあるようなゲームだと思いますが^^;
その前に、開発に役に立つページを。。というか必須です。

Luaridaの独自コマンドの説明はこちら

luaのリファレンスはこちら

はい、では「覚えたか?」の動画とソースを以下に。

【ゲーム説明】
3x3のマスのいずれかのマスが5回ひかります。
その順番を覚えて、画面に覚えたか?と表示されたら、
その順番通りにタッチします。
5つ正解すると次のレベルになり、速度があがります。
レベル5をクリアすると終わりです。
ミスも一回でゲームオーバー。



w,h = canvas.getviewSize()
bdw = w * 0.7
bdh = h * 0.9
selw = bdw / 3
selh = bdh / 3
mondaiX = {}
mondaiY = {}
tx,ty = 0,0
scene = 9
level = 1
tm = system.getSec()
tmtb = {}
tmtb[1] = 0.5
tmtb[2] = 0.25
tmtb[3] = 0.10
tmtb[4] = 0.05
tmtb[5] = 0
cnt = 1
sc = 0
function paintBord()
    canvas.putRect(0,32,bdw,bdh+32,color(255,255,255))
    for i=1,2 do
        canvas.putLine(selw * i,32,selw * i,bdh+32,color(255,255,255))
        canvas.putLine(0,selh*i+32,bdw,selh*i+32,color(255,255,255))
    end
        canvas.putText("LEVEL" .. level .. "    SCORE" .. sc,0,0,32,color(255,255,255))
end
function touchBord(x,y,b)
    mat = string.match((x/selw),"%w+")
    mat2 = string.match(((y-32)/selh),"%w+")
    
    if ((tonumber(mat) < 3) and (tonumber(mat2) < 3)) then
    if (b == 1) then
        canvas.putRect(mat*selw,(mat2*selh)+32,(mat+1)*selw,(mat2+1)*selh+32,color(255,255,255),1)
        --canvas.putText(mat .. mat2,0,0,32,color(255,255,255))
    end
    end
    return mat,mat2
end
function main()
--loop start--
while(true) do
canvas.putCls(color(0,0,0))
paintBord()
-- シーン
if scene == 1 then
    if cnt == 6 then 
         while(tm +1 > system.getSec())do end
         scene = 10
         cnt = 1
    else
    rnx = math.random(0,bdw) 
    rny = math.random(0,bdh+32)
    mondaiX[cnt],mondaiY[cnt] = touchBord(rnx,rny,1)
    canvas.putText(cnt,w/3,h/2,64,color(255,255,0))
   while(tm > system.getSec())do end
    tm = system.getSec() + tmtb[level]
    cnt = cnt + 1
    end
elseif scene == 2 then
        x,y,b = touch(3)
        tx,ty = touchBord(x,y,b)
        if (mondaiX[cnt] == tx) and (mondaiY[cnt] == ty) then
            -- toast("正解!",0)
                canvas.putText("覚えてた!",w/3,h/2,64,color(255,255,0)) 
                cnt = cnt + 1
                sc = sc + 10
        else
                canvas.putText("間違えた!",w/3,h/2,64,color(255,0,0))
                scene = 5
        end
        if cnt == 6 then
                dialog("level" .. level .. "クリア!","next level!!",1)
                level = level + 1
                if level == 6 then
                      dialog("ゲームクリア!","またな…",1)
                      system.exit()
                end 
                cnt = 1
                scene = 9
         end
      
elseif scene == 5 then
     yn = dialog("忘れてた!","またやる?",2)
     if yn == 1 then
          scene = 9
          cnt = 1
          level = 1
          sc = 0
     else
          system.exit()
     end
elseif scene == 9 then
    canvas.putText("覚えろ!",w/3,h/2,64,color(255,255,255)) 
    cnt = cnt + 1 
    while(tm > system.getSec())do end
    tm = system.getSec() + 0.5
    if cnt == 4 then
         cnt = 1
         scene = 1
    end
elseif scene == 10 then
    canvas.putText("覚えたか?!",w/3,h/2,64,color(255,255,255)) 
    cnt = cnt + 1 
    while(tm > system.getSec())do end
    tm = system.getSec() + 0.5
    if cnt == 2 then
         cnt = 1
         scene = 2
    end
end

canvas.putflush()
end
--loop end--
end
main()



最終更新日 : 2016-03-27

Comments







非公開コメント