2048游戏

基本逻辑

    -- move cell
    Matrix = {}
    if(touched) then
        --check direction
        if direction=left then
            i = curCell
            k =  index + 1
            if M[i] == M[j] then
                M[i] = M[i] + M[j]
                M[j] = 0
            else
                M[i] = idle
                M[j] = idle
            end
        end
    end

    -- init matrix with with fill cell with 0
    for i=1,4 do
        M[i] = {}
        for j=1,4 do
            M[i][j] = 0
        end
    end

    -- fill cell with random(2,4)