资源描述:
《java游戏代码--五子棋》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、importjava.util.*;importjava.io.*;importjava.awt.*;importjava.awt.event.*;importjava.applet.*;importjavax.swing.*;classWuZiQiextendsJFrameimplementsRunnable,ActionListener{finalstaticintPlayer=1;finalstaticintAI=-1;ClassLoadercl=this.getClass().getClass
2、Loader();Toolkittk=Toolkit.getDefaultToolkit();intlength=14,game_state,winner,check,step;intgrid[][]=newint[length][length];intlocX,locY/*囱竚*/,count/*硈囱计*/,x,y/*既竚*/,displace_x=0,displace_y=0/*簿秖*/,direction;ArrayListsteps=newArrayList();/*癘魁囱˙*/JP
3、opupMenucontrol_menu=newJPopupMenu();/*龄匡虫*/JMenuItem[]command=newJMenuItem[4];String[]command_str={"囱","郎","弄郎","秨"};int[][]dir={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};boolean[]dir2=newboolean[8];booleanturn;Stringmessage;finalJDi
4、alogdialog=newJDialog(this,"选择",true);Fontfont=newFont("new_font",Font.BOLD,20);Gridgrids[][]=newGrid[length][length];Imagewhite=tk.getImage(cl.getResource("white.png"));Imageblack=tk.getImage(cl.getResource("black.png"));Imagetitle=tk.getImage(cl.getRe
5、source("title.png"));Imagetemp;JPanelboardPanel,bigpanel;JRadioButton[]choice=newJRadioButton[2];finalstaticintStart=0;finalstaticintSelect=1;finalstaticintPlaying=2;finalstaticintEnd=3;finalstaticintnil=-1;/*礚よ*/finalstaticintoblique_1=0;/*オ*/fina
6、lstaticintoblique_2=1;/*オ*/finalstaticinthorizontal=2;/*绢*/finalstaticintvertical=3;/**/WuZiQi(){super("五子棋");boardPanel=newJPanel();boardPanel.setLayout(newGridLayout(length,length,0,0));boardPanel.setComponentOrientation(ComponentOrientation.RI
7、GHT_TO_LEFT);for(inti=0;i8、adStart();dialog.setSize(160,100);dialog.setResizable(false);dialog.setLocationRelativeTo(null);ButtonGroupchoice_group=newButtonGroup();JPanelchoice_menu=newJPanel();choice[0]=newJRadioButton("黑子",newImageIcon(black),true);choic