3D魔方游戏制作lua迷你世界

 

bbae52973b9f4aa3a8947649f85ce676.jpg

--3D魔方
--星空露珠工作室
--核心脚本来自负负

--1:xy 2:yx 3:xz 4:zx 5:yz 6:zy
--4000,0-3 3995-0,3
local trn={
{{5,2},{3,1},{1,2},{1,3},{4,0},{2,2}},
{{3,0},{5,3},{1,3},{1,2},{2,3},{4,1}},
{{4,2},{2,1},{1,1},{1,0},{3,3},{5,1}},
{{2,0},{4,3},{1,0},{1,1},{5,0},{3,2}},
{{6,0},{1,3},{2,2},{2,3},{5,2},{3,0}},
{{1,2},{6,1},{2,3},{2,2},{3,1},{5,3}},
{{5,1},{3,2},{2,1},{2,0},{1,0},{6,2}},
{{3,3},{5,0},{2,0},{2,1},{6,3},{1,1}},
{{6,2},{1,1},{3,2},{3,3},{2,0},{4,2}},
{{1,0},{6,3},{3,3},{3,2},{4,3},{2,1}},
{{2,2},{4,1},{3,1},{3,0},{1,3},{6,1}},
{{4,0},{2,3},{3,0},{3,1},{6,0},{1,2}},
{{5,0},{3,3},{4,2},{4,3},{6,2},{1,0}},
{{3,2},{5,1},{4,3},{4,2},{1,1},{6,3}},
{{6,1},{1,2},{4,1},{4,0},{3,0},{5,2}},
{{1,3},{6,0},{4,0},{4,1},{5,3},{3,1}},
{{2,3},{4,0},{5,2},{5,3},{6,1},{1,3}},
{{4,1},{2,2},{5,3},{5,2},{1,2},{6,0}},
{{6,3},{1,0},{5,1},{5,0},{4,2},{2,0}},
{{1,1},{6,2},{5,0},{5,1},{2,1},{4,3}},
{{4,3},{2,0},{6,2},{6,3},{5,1},{3,3}},
{{2,1},{4,2},{6,3},{6,2},{3,2},{5,0}},
{{5,3},{3,0},{6,1},{6,0},{2,2},{4,0}},
{{3,1},{5,2},{6,0},{6,1},{4,1},{2,3}}}

352410693eaf4f6f9f8d13685db6b0de.png

1.上面-黄

2.左面-绿

3.后面-红

4.右面-蓝

5.前面-橙

6.下面-白

模型快速制作,请阅读下一篇

local ids={4000,3999,3998,3997,3996,3995} 
local x0,y0,z0=0,9,0--起点坐标

--黄,绿,红,蓝,橙,白

 

--魔方数据
local cft={{
{{1,0},{1,0},{1,0}},
{{1,0},{1,0},{1,0}},
{{1,0},{1,0},{1,0}}}
,{
{{1,0},{1,0},{1,0}},
{{1,0},{1,0},{1,0}},
{{1,0},{1,0},{1,0}}}
,{
{{1,0},{1,0},{1,0}},
{{1,0},{1,0},{1,0}},
{{1,0},{1,0},{1,0}}}}

local x,y,z=0,0,0
--游戏开始,生成魔方
local function Go(e)
    for x=0,2 do
        for y=0,2 do
            for z=0,2 do
     Block:destroyBlock(Px0+x,y0+y,z0+z,false)
      Block:setBlockAll(x0+x,y0+y,z0+z,ids[1],0)
            end
        end
    end
end
ScriptSupportEvent:registerEvent([=[Game.Start]=],Go)

--刷新魔方
local function Re()
local str=''
    for x=1,3 do
  str=str..'\n'
        for y=1,3 do  
       str=str..'\n'
            for z=1,3 do
     str=str..'('..cft[x][4-y][z][1]..','.. cft[x][4-y][z][2]..'),'
    Block:setBlockAll(x0+z-1,y0+x-1,z0+y-1,ids[cft[x][4-y][z][1]],cft[x][4-y][z][2])
            end
        end
    end
print("打印\n"..str)
end
--旋转
local rc={1,0}
local function Ton(a,e,b)
        rc[1]=cft[a[1]][a[2]][a[3]][1]
        rc[2]=cft[a[1]][a[2]][a[3]][2]
        cft[a[1]][a[2]][a[3]][1]=trn[cft[a[4]][a[5]][a[6]][1]*4+cft[a[4]][a[5]][a[6]][2]-3][b][1]
        cft[a[1]][a[2]][a[3]][2]=trn[cft[a[4]][a[5]][a[6]][1]*4+cft[a[4]][a[5]][a[6]][2]-3][b][2]
        cft[a[4]][a[5]][a[6]][1]=trn[cft[a[7]][a[8]][a[9]][1]*4+cft[a[7]][a[8]][a[9]][2]-3][b][1]
        cft[a[4]][a[5]][a[6]][2]=trn[cft[a[7]][a[8]][a[9]][1]*4+cft[a[7]][a[8]][a[9]][2]-3][b][2]
        cft[a[7]][a[8]][a[9]][1]=trn[cft[a[10]][a[11]][a[12]][1]*4+cft[a[10]][a[11]][a[12]][2]-3][b][1]
        cft[a[7]][a[8]][a[9]][2]=trn[cft[a[10]][a[11]][a[12]][1]*4+cft[a[10]][a[11]][a[12]][2]-3][b][2]
        cft[a[10]][a[11]][a[12]][1]=trn[rc[1]*4+rc[2]-3][b][1]
        cft[a[10]][a[11]][a[12]][2]=trn[rc[1]*4+rc[2]-3][b][2]
        ------
        rc[1]=cft[e[1]][e[2]][e[3]][1]
        rc[2]=cft[e[1]][e[2]][e[3]][2]
        cft[e[1]][e[2]][e[3]][1]=trn[cft[e[4]][e[5]][e[6]][1]*4+cft[e[4]][e[5]][e[6]][2]-3][b][1]
        cft[e[1]][e[2]][e[3]][2]=trn[cft[e[4]][e[5]][e[6]][1]*4+cft[e[4]][e[5]][e[6]][2]-3][b][2]
        cft[e[4]][e[5]][e[6]][1]=trn[cft[e[7]][e[8]][e[9]][1]*4+cft[e[7]][e[8]][e[9]][2]-3][b][1]
        cft[e[4]][e[5]][e[6]][2]=trn[cft[e[7]][e[8]][e[9]][1]*4+cft[e[7]][e[8]][e[9]][2]-3][b][2]
        cft[e[7]][e[8]][e[9]][1]=trn[cft[e[10]][e[11]][e[12]][1]*4+cft[e[10]][e[11]][e[12]][2]-3][b][1]
        cft[e[7]][e[8]][e[9]][2]=trn[cft[e[10]][e[11]][e[12]][1]*4+cft[e[10]][e[11]][e[12]][2]-3][b][2]
        cft[e[10]][e[11]][e[12]][1]=trn[rc[1]*4+rc[2]-3][b][1]
        cft[e[10]][e[11]][e[12]][2]=trn[rc[1]*4+rc[2]-3][b][2]
end
--d m: 0左中右 1上中下 2前中后
--m: 0顺时针 1逆时针 从左后下方
local function Re0(d,i,m)
    if (d==0)and(m==0) then
        Ton({1,3,1+i,3,3,1+i,3,1,1+i,1,1,1+i},{1,2,1+i,2,3,1+i,3,2,1+i,2,1,1+i},6)
    elseif (d==0)and(m==1) then
        Ton({1,1,1+i,3,1,1+i,3,3,1+i,1,3,1+i},{2,1,1+i,3,2,1+i,2,3,1+i,1,2,1+i},5)
    elseif (d==1)and(m==0) then
        Ton({3-i,3,1,3-i,3,3,3-i,1,3,3-i,1,1},{3-i,2,1,3-i,3,2,3-i,2,3,3-i,1,2},4)
    elseif (d==1)and(m==1) then
        Ton({3-i,1,1,3-i,1,3,3-i,3,3,3-i,3,1},{3-i,1,2,3-i,2,3,3-i,3,2,3-i,2,1},3)
    elseif (d==2)and(m==0) then
        Ton({1,3-i,1,1,3-i,3,3,3-i,3,3,3-i,1},{1,3-i,2,2,3-i,3,3,3-i,2,2,3-i,1},2)
    else
        Ton({3,3-i,1,3,3-i,3,1,3-i,3,1,3-i,1},{2,3-i,1,3,3-i,2,2,3-i,3,1,3-i,2},1)
    end
    Re()
end
--d m: 0左中右 1上中下 2前中后
--m: 0顺时针 1逆时针 从左后下方
local function input(e)
if e.content=="0" then Go(e) --复原
elseif e.content=="1" then Re0(1,0,0) --上
elseif e.content=="2" then Re0(1,2,0) --下
elseif e.content=="3" then Re0(0,0,0) --前
elseif e.content=="4" then Re0(0,2,0) --后
elseif e.content=="5" then Re0(2,2,0) --左
elseif e.content=="6" then Re0(2,0,0) --右

elseif e.content=="7" then Re0(1,0,1) --上
elseif e.content=="8" then Re0(1,2,1) --下
elseif e.content=="9" then Re0(0,0,1) --前
elseif e.content=="10" then Re0(0,2,1) --后
elseif e.content=="11" then Re0(2,2,1)--左
elseif e.content=="12" then Re0(2,0,1) --右

elseif e.content=="13" then Re0(0,1,0)   --中_前后
elseif e.content=="14" then Re0(1,1,0) --中_上下
elseif e.content=="15" then Re0(2,1,0) --中_左右

elseif e.content=="16" then Re0(0,1,1) --中_前后
elseif e.content=="17" then Re0(1,1,1) --中_上下
elseif e.content=="18" then Re0(2,1,1) --中_左右
end
end
ScriptSupportEvent:registerEvent([=[Player.InputContent]=], input)

 

  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值