📄 main.gml
字号:
<sys sethotkey=ctrl_shift_s,{<: game.showfireline=(game.showfireline-1)>}>
<sys sethotkey=ctrl_w,{<: !win;game.eve=sentStop,win>}>
<sys sethotkey=ctrl_l,{<: !lost;game.eve=sentStop,lost>}>
<: myno=3;bkimg=color(#003300);OnClick=null;OnSize={<: enumsub={<: eve=size>}>};>
<style>
//--table define
.tableinit{
size=638,340;
pos=(pid.width-width)/2+1,101;
OnSize={<: pos=(pid.width-width)/2+1,101;>};
zorder=0;
firespeed=350;
class=MyTableInit;
// eve=size;
// showstatic=1;
snd=0,$.\sound\pocket.gsm;
snd=1,$.\sound\bigbreak.gsm;
snd=2,$.\sound\cue2ball.adm;
snd=3,$.\sound\click.gsm;
snd=4,$.\sound\cush.adm;
holeshowpos=20,358;
ganimg=$.\imgs\gan.ale;
// hideball=0,1,2,3,4,5,6,7,8,9;
}
//player class--------------------------------------------------------
.CanFireClass{
canfire=1;
OnLButtonDown={<: beginfire=$[mousepos];>};
OnLButtonUp={<: paramctrl#timer=null;canfire=0;paramctrl#showgan=null;
pid.mid.eve=ballstatus,$[allballstatus];
pid.mid.eve=fire,$[fireForword],$[firespeed];>};
OnRButtonDown=null;
OnRButtonUp=null;
lefttime=30;
paramctrl#timer=loopcmd(lefttime+1,1000,1000,{<: lefttime=(lefttime-1);
&promtext.eve=ptm,剩余时间$[lefttime];>},AutoFire);
paramctrl#showgan=loopcmd(-1,1000,200,{<: switch(oldmouse){
case '$[mousepos]':break;
default:pid.mid.neteventtos=showgan,$[mousepos];oldmouse=$[mousepos];break;
}
>});
OnAutoFire={<PtText Src=超时自动开球><: paramctrl#showgan=null;
paramctrl#timer=timer(1000,LButtonUp);beginfire=$[mousepos];>};
}
.CanFreeFireClass{
beginfreeball=1;
paramctrl#showgan=null;
OnLButtonDown=null;
OnRButtonDown=null;
paramctrl#sent=loopcmd(-1,100,200,{<: if=(oldmouse!='$[mousepos]')?{pid.mid.eve=setballpos,0,$[ballpos(0)];}>});
OnLButtonUp={<: if=(tryendfreeball)?{pid.mid.eve=setballpos,0,$[ballpos(0)];
paramctrl#sent=null;
class=CanFireClass;&promtext.eve=ptm,请你开球}>};
}
.DisFireClass{
canfire=0;
paramctrl#timer=null;
OnLButtonDown=null;
OnLButtonUp=null;
OnRButtonDown=null;
}
.game:TableDesk{
class=tableinit;
curplayer=0;
myep=0;
playsz=0,0;
OnCreate={<: pid.game=$[id];eve=Reset;>};
OnFull={<: if=(pid.)?{}:{};pid.pbc.eve=mode,1><PtText Src=人员已经全部就绪,等待主人开始游戏!>};
OnBegin={<PtText Src=比赛开始了!><: eve=Reset;>};
OnWait={<PtText Src=等待其他人继续!>};
OnNext={<PtText Src=所有人都同意继续了,等待主人开始!>};
OnPlayChg={<: curplayer=$[ep0];switch(ep1){case $[pid.myname]:{<PtText Src=该你打了!>};break;
default:{<PtText Src=换$[ep1]打了!>}}>};
Onputball={<: ballpos=ep0,ep1,ep2;>};
OnSetBallstatus={<: allballstatus=*ep;>};
OnAllballstop={<: pid.mid.neteventtos=ballstatus,$[allballstatus];
// if=(curplayer==pid.playerno)?{pid.mid.neteventtos=ballstatus,$[allballstatus]};
pid.mid.neteventtos=stop,$[ep]>};//s_ret,s_msg,s_autocmd
OnStoped={<: $[ep];>};
Onpt={<PtText src=$[ep];>};
Onshowgan={<: showfireto=$[ep]>};
OnFired={<: showfireoff=0;fireto=$[ep0],$[ep1]>};
OnAuto={<: autoputball=0>};
OnPlay={<: autoputball=0;if=(ep==1)?{class=CanFireClass;&promtext.eve=ptm,请你开球}:{class=DisFireClass;&promtext.eve=ptm,等待其他选手开球}>};
OnPlayFree={<: autoputball=0;if=(ep==1)?{class=CanFreeFireClass;&promtext.eve=ptm,请你选择自由球位置}:{class=DisFireClass;&promtext.eve=ptm,等待其他选手开自由球}>};
OnWin={<: &promtext.eve=ptm,$[ep1]赢了!;if=(pid.game.playerno==ep0)?{<: eve=PtWin>}:{<: eve=PtLost>}>}
OnLost={<: &promtext.eve=ptm,$[ep1]输了!;if=(pid.game.playerno!=ep0)?{<: eve=PtWin>}:{<: eve=PtLost>}>}
OnPtWin={<: playsnd=$.\sound\win.gsm><WinDlg OnDestroy={<: pid.myid.eve=restart}>};
OnPtLost={<: playsnd=$.\sound\lost.gsm><LostDlg OnDestroy={<: pid.myid.eve=restart}>};
}
.btn_c:text{
color=#88FF88;
showstyle=3;
src="txt";
OnShow={<: src=$[ep];show=1>};
OnClick={<: pid.pid.pid.pid.myid.eve=$[src],$[index]>};
}
.man:text{
src="man";
zorder=top;
pos=6,6;
color=#FFFFFF;
showstyle=3;
// align=center,center;
index=0;
me=0;
game=*pid.game;
OnCreate={<: src=$[ownername];
pbc=*pid.pbc;pid=*pid.pbar$[index];game.playsz[$[index]]=*id;>
<text pid=*pid.pid;pos=6,25;src="目标球:">
<text pid.pobj=*id;pid=*pid.pid;pos=64,25;src="?">
<text pid=*pid.pid;pos=6,42;src="剩余杆数:";>
<text pid.pnum=*id;pid=*pid.pid;pos=64,42;src="?">
<btn_c pid.padd=*id;pid=*pid.pid;pos=6,60;index=$[index]>
<btn_c pid.plook=*id;pid=*pid.pid;pos=6,60;index=$[index]>
};
OnEnter={<: uid=$[ep0];uname=$[ep1];
switch(uname){case $[pid.pid.pid.pid.myname]:eve=me,1;eve=btn,2;break;
default:eve=me,0;eve=btn,1}><PtText Src=$[ep1]加入游戏!>};
OnLook={<: uid=0;uname="空闲中...";eve=me,0;eve=btn,0><PtText Src=位置已空,等待加入!>}:
ifchged(uname)={<: src=$[uname]>};
OnMe={<: if=(ep==0)?{color=#FFFFAA;if=(me==1)?{pid.pid.pid.pid.mid=0;game.playerno=-1;};me=0}:{
color=#FFCCCC;pid.pid.pid.pid.mid=*id;game.playerno=*index;me=1}>};
OnBtn={<: switch(ep){
case 0:padd.eve=show,"加入";plook.show=0;break;
case 1:padd.show=0;plook.show=0;break;
case 2:padd.show=0;plook.eve=show,"旁观";break;
}>};
OnLeave={<: eve=mode,0>};
OnClick={<: if=(me==1)?{pid.pid.pid.pid.myid.eve=begin,$[index]}>};
Oncanbegin={<: pbc.eve=mode,1>};
Onwaitbegin={<: pbc.eve=mode,2>};
OnBegin={<: pid.pid.pid.pid.myid.eve=begin,$[index]>};
OnBegined={<: pbc.eve=mode,3;eve=play,$[ep0],1>};
OnFire={<: neteventtos=fire,$[ep0],$[ep1]>};
OnBallstatus={<: neteventtos=ballstatus,$[ep]>};
OnSetBallstatus={<: game.eve=SetBallstatus,$[ep]>};
OnBallstop={<: leftnum=(leftnum-1);neteventtos=ballstop,$[ep]>};
OnSetballpos={<: neteventtos=setballpos,$[ep]>};
leftnum=0;
bkimg=round(#FFFF99,4,1,-2);
// bkimg=roundbar(#CCFFFF,4,#333399);
// draw=2:{wv();textout(0,20,"Obj:$[curobj] left:$[leftnum]",#FFFFCC)};
OnObj={<: pobj.src=*game.ballname($[ep])>};
ifchged(leftnum)={<: pnum.src=*leftnum>};
OnPlay={<: if=(index==ep0 && me==1)?{game.eve=play,1;}:{game.eve=play,0;}>};
OnPlayFree={<: if=(index==ep0 && me==1)?{game.eve=playfree,1;}:{game.eve=playfree,0;}>};//
OnPlay#2={<: game.playsz[$[index]].eve=ActivePlay,$[ep1];game.playsz[1-$[index]].eve=NoPlay>};
OnPlayFree#2={<: game.playsz[$[index]].eve=ActivePlay,$[ep1];game.playsz[1-$[index]].eve=NoPlay>};
OnActivePlay={<: bkimg=roundbar(#FF99CC,4,#333399);leftnum=(ep0);>};
OnNoPlay={<: bkimg=roundbar(#660000,4,#333399);leftnum=0;>};
}
</style>
//<: location=(rand(1000));location[1]='网络台球';>
<sys import=,$.\misc.gml>
#ifndef PORT
#define PORT 10700
#endif
#define MAP_NAME $.\ui.gml
#define USER $.\user.gml
<: selfcreatex=320;selfcreatey=240>
<sys import=,$.\..\..\chat\index.gml>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -