麻将小程序使用自制字符(有些小问题,等之后字体修改)
This commit is contained in:
@@ -7,13 +7,7 @@ local gc_print=gc.print
|
|||||||
local max,min=math.max,math.min
|
local max,min=math.max,math.min
|
||||||
local ins,rem=table.insert,table.remove
|
local ins,rem=table.insert,table.remove
|
||||||
|
|
||||||
local colorName={
|
|
||||||
m={'一','二','三','四','五','六','七','八','九'},
|
|
||||||
p={'①','②','③','④','⑤','⑥','⑦','⑧','⑨'},
|
|
||||||
s={'1','2','3','4','5','6','7','8','9'},
|
|
||||||
}
|
|
||||||
local deck0={}
|
local deck0={}
|
||||||
local cardText={}
|
|
||||||
for i=1,9 do
|
for i=1,9 do
|
||||||
for _=1,4 do
|
for _=1,4 do
|
||||||
ins(deck0,'m'..i)
|
ins(deck0,'m'..i)
|
||||||
@@ -21,9 +15,6 @@ for i=1,9 do
|
|||||||
ins(deck0,'s'..i)
|
ins(deck0,'s'..i)
|
||||||
if i<=7 then ins(deck0,'z'..i)end
|
if i<=7 then ins(deck0,'z'..i)end
|
||||||
end
|
end
|
||||||
cardText['m'..i]={COLOR.lF,colorName.m[i]}
|
|
||||||
cardText['p'..i]={COLOR.lB,colorName.p[i]}
|
|
||||||
cardText['s'..i]={COLOR.lG,colorName.s[i]}
|
|
||||||
end
|
end
|
||||||
-- deck0[TABLE.find(deck0,'m5')]='m0'
|
-- deck0[TABLE.find(deck0,'m5')]='m0'
|
||||||
-- deck0[TABLE.find(deck0,'p5')]='p0'
|
-- deck0[TABLE.find(deck0,'p5')]='p0'
|
||||||
@@ -32,13 +23,42 @@ end
|
|||||||
-- cardText['5p+']={COLOR.R,'⑤'}
|
-- cardText['5p+']={COLOR.R,'⑤'}
|
||||||
-- cardText['5s+']={COLOR.R,'5'}
|
-- cardText['5s+']={COLOR.R,'5'}
|
||||||
|
|
||||||
cardText['z1']={COLOR.Z,'東'}
|
local cardText={
|
||||||
cardText['z2']={COLOR.Z,'南'}
|
m1={COLOR.D,CHAR.mahjong.m1Base,COLOR.R,CHAR.mahjong.mComb},
|
||||||
cardText['z3']={COLOR.Z,'西'}
|
m2={COLOR.D,CHAR.mahjong.m2Base,COLOR.R,CHAR.mahjong.mComb},
|
||||||
cardText['z4']={COLOR.Z,'北'}
|
m3={COLOR.D,CHAR.mahjong.m3Base,COLOR.R,CHAR.mahjong.mComb},
|
||||||
cardText['z5']={COLOR.Z,' '}
|
m4={COLOR.D,CHAR.mahjong.m4Base,COLOR.R,CHAR.mahjong.mComb},
|
||||||
cardText['z6']={COLOR.G,'發'}
|
m5={COLOR.D,CHAR.mahjong.m5Base,COLOR.R,CHAR.mahjong.mComb},
|
||||||
cardText['z7']={COLOR.R,'中'}
|
m6={COLOR.D,CHAR.mahjong.m6Base,COLOR.R,CHAR.mahjong.mComb},
|
||||||
|
m7={COLOR.D,CHAR.mahjong.m7Base,COLOR.R,CHAR.mahjong.mComb},
|
||||||
|
m8={COLOR.D,CHAR.mahjong.m8Base,COLOR.R,CHAR.mahjong.mComb},
|
||||||
|
m9={COLOR.D,CHAR.mahjong.m9Base,COLOR.R,CHAR.mahjong.mComb},
|
||||||
|
p1={COLOR.D,CHAR.mahjong.p1},
|
||||||
|
p2={COLOR.D,CHAR.mahjong.p2Base,COLOR.D,CHAR.mahjong.p2Comb},
|
||||||
|
p3={COLOR.D,CHAR.mahjong.p3Base,COLOR.R,CHAR.mahjong.p3Comb1,COLOR.D,CHAR.mahjong.p3Comb2},
|
||||||
|
p4={COLOR.D,CHAR.mahjong.p4Base,COLOR.D,CHAR.mahjong.p4Comb},
|
||||||
|
p5={COLOR.D,CHAR.mahjong.p5Base,COLOR.D,CHAR.mahjong.p5Comb1,COLOR.R,CHAR.mahjong.p5Comb2},
|
||||||
|
p6={COLOR.D,CHAR.mahjong.p6Base,COLOR.R,CHAR.mahjong.p6Comb},
|
||||||
|
p7={COLOR.D,CHAR.mahjong.p7Base,COLOR.R,CHAR.mahjong.p7Comb},
|
||||||
|
p8={COLOR.D,CHAR.mahjong.p8},
|
||||||
|
p9={COLOR.D,CHAR.mahjong.p9Base,COLOR.R,CHAR.mahjong.p9Comb1,COLOR.D,CHAR.mahjong.p9Comb2},
|
||||||
|
s1={COLOR.G,CHAR.mahjong.s1Base,COLOR.R,CHAR.mahjong.s1Comb},
|
||||||
|
s2={COLOR.G,CHAR.mahjong.s2},
|
||||||
|
s3={COLOR.G,CHAR.mahjong.s3},
|
||||||
|
s4={COLOR.G,CHAR.mahjong.s4},
|
||||||
|
s5={COLOR.G,CHAR.mahjong.s5Base,COLOR.R,CHAR.mahjong.s5Comb},
|
||||||
|
s6={COLOR.G,CHAR.mahjong.s6},
|
||||||
|
s7={COLOR.G,CHAR.mahjong.s7Base,COLOR.R,CHAR.mahjong.s7Comb},
|
||||||
|
s8={COLOR.G,CHAR.mahjong.s8},
|
||||||
|
s9={COLOR.G,CHAR.mahjong.s9Base,COLOR.R,CHAR.mahjong.s9Comb},
|
||||||
|
z1={COLOR.D,CHAR.mahjong.ton},
|
||||||
|
z2={COLOR.D,CHAR.mahjong.nan},
|
||||||
|
z3={COLOR.D,CHAR.mahjong.sha},
|
||||||
|
z4={COLOR.D,CHAR.mahjong.pe},
|
||||||
|
z5={COLOR.D,CHAR.mahjong.haku},
|
||||||
|
z6={COLOR.G,CHAR.mahjong.hatsu},
|
||||||
|
z7={COLOR.R,CHAR.mahjong.chun},
|
||||||
|
}for _,v in next,cardText do ins(v,COLOR.D)ins(v,CHAR.mahjong.frameComb) end
|
||||||
|
|
||||||
local deck,hand,pool
|
local deck,hand,pool
|
||||||
local selected
|
local selected
|
||||||
@@ -48,13 +68,13 @@ local function _getPoolCardArea(i)
|
|||||||
local col=i-row*10
|
local col=i-row*10
|
||||||
return
|
return
|
||||||
240+70*col,45+95*row,
|
240+70*col,45+95*row,
|
||||||
65,90
|
60,84
|
||||||
end
|
end
|
||||||
|
|
||||||
local function _getHandCardArea(i)
|
local function _getHandCardArea(i)
|
||||||
return
|
return
|
||||||
20+70*i+(i==14 and 30 or 0),480,
|
20+70*i+(i==14 and 30 or 0),480,
|
||||||
65,90
|
60,84
|
||||||
end
|
end
|
||||||
|
|
||||||
local function _newGame()
|
local function _newGame()
|
||||||
@@ -67,7 +87,7 @@ end
|
|||||||
|
|
||||||
local function _checkWin()
|
local function _checkWin()
|
||||||
if #hand==14 then
|
if #hand==14 then
|
||||||
--???
|
MES.new('info',"Coming soon!")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -134,42 +154,44 @@ end
|
|||||||
|
|
||||||
function scene.draw()
|
function scene.draw()
|
||||||
setFont(35)
|
setFont(35)
|
||||||
gc_setColor(COLOR.Z)
|
gc_setColor(COLOR.D)
|
||||||
gc_print('余: '..#deck,1060,30)
|
gc_print('余 '..#deck,1060,30)
|
||||||
|
|
||||||
gc_setLineWidth(4)
|
gc_setLineWidth(4)
|
||||||
setFont(50)
|
setFont(85)
|
||||||
for i=1,#hand do
|
for i=1,#hand do
|
||||||
local c=hand[i]
|
local c=hand[i]
|
||||||
local x,y,w,h=_getHandCardArea(i)
|
local x,y,w,h=_getHandCardArea(i)
|
||||||
if i==selected then
|
if i==selected then
|
||||||
gc_translate(0,-10)
|
gc_translate(0,-10)
|
||||||
gc_setColor(1,1,1,.4)
|
|
||||||
gc_rectangle('fill',x,y,w,h,5)
|
|
||||||
end
|
end
|
||||||
gc_setColor(COLOR.Z)
|
gc_setColor(COLOR.Z)
|
||||||
gc_rectangle('line',x,y,w,h,5)
|
gc_rectangle('fill',x,y,w,h,12)
|
||||||
|
if i==selected then
|
||||||
|
gc_setColor(1,1,1,.4)
|
||||||
|
gc_rectangle('fill',x,y,w,h,12)
|
||||||
|
end
|
||||||
gc_setColor(1,1,1)
|
gc_setColor(1,1,1)
|
||||||
mStr(cardText[c],x+w/2,y+10)
|
mStr(cardText[c],x+w/2,y-17)
|
||||||
if i==selected then gc_translate(0,10)end
|
if i==selected then gc_translate(0,10)end
|
||||||
end
|
end
|
||||||
for i=1,#pool do
|
for i=1,#pool do
|
||||||
local c=pool[i]
|
local c=pool[i]
|
||||||
local x,y,w,h=_getPoolCardArea(i)
|
local x,y,w,h=_getPoolCardArea(i)
|
||||||
if selected and hand[selected]==c then
|
|
||||||
gc_setColor(1,1,1,.4)
|
|
||||||
gc_rectangle('fill',x,y,w,h,5)
|
|
||||||
end
|
|
||||||
gc_setColor(COLOR.Z)
|
gc_setColor(COLOR.Z)
|
||||||
gc_rectangle('line',x,y,w,h,5)
|
gc_rectangle('fill',x,y,w,h,12)
|
||||||
|
if selected and hand[selected]==c then
|
||||||
|
gc_setColor(1,.2,.2,.3)
|
||||||
|
gc_rectangle('fill',x,y,w,h,12)
|
||||||
|
end
|
||||||
gc_setColor(1,1,1)
|
gc_setColor(1,1,1)
|
||||||
mStr(cardText[c],x+w/2,y+10)
|
mStr(cardText[c],x+w/2,y-17)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scene.widgetList={
|
scene.widgetList={
|
||||||
WIDGET.newButton{name='reset',x=160, y=100,w=180,h=100,color='lG',font=50,fText=CHAR.icon.retry_spin,code=pressKey'r'},
|
WIDGET.newButton{name='reset',x=160, y=100,w=180,h=100,color='lR',font=50,fText=CHAR.icon.retry_spin,code=pressKey'r'},
|
||||||
WIDGET.newKey{name="hu", x=1150,y=370,w=140,h=80,font=50,sound=false,fText='自摸',code=pressKey'return'},
|
WIDGET.newKey{name="hu", x=1150,y=370,w=140,h=80,font=45,sound=false,fText='自摸',code=pressKey'return'},
|
||||||
WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
|
WIDGET.newButton{name="back", x=1140,y=640,w=170,h=80,sound='back',font=60,fText=CHAR.icon.back,code=backScene},
|
||||||
}
|
}
|
||||||
return scene
|
return scene
|
||||||
|
|||||||
Reference in New Issue
Block a user