1、目录 第一章 软件开发平台 游戏设计思路 第二章 小游戏五子棋的开发过程 第一节 JAVA 基础知识 第二节 启动程序的分析 第三节 游戏设计过程 第三章 总结 第四章 参考文献 第五章 附录 第一章 游戏游戏设计思路设计思路 : 五子棋五子棋 选子(黑色,选子(黑色, 白色)白色) 开始开始 右击:右击: 悔棋悔棋 读档读档 存档存档 重开重开 你输了你输了 你赢了你赢了 第二章 第一节 java 程序基础知识 本系统有 4 个程序每个程序都导入了不同的包和类运用了不同的所学知识。不同的类和 包提供的方法、类型等都不同,本程序还使用了继承。以至使其能够完成不同的功能。本节 主要讲述本系统所使
2、用的基础知识。 1、 类的基础 =4; i-) play=!play; step=i/2; gobangAI2(play); if(turn) return; gobangAI5(); if(!turn) gobangRandom(); private void gobangAI2(boolean player) check = player? Player: AI; for(int i=0; i=0 else space=0; x=locX-displace_x; y=locY-displace_y; while(x=0 else return false; public void Thre
3、adStart() new Thread(this).start(); private void setMark(int x, int y) steps.add(gridsxy); gridsxy.setValue(-1); WinCheck(); turn=true; /* 璸衡 */ private void setMark2(int x, int y) int space=0, temp_x=x, temp_y=y; do space=space+1; temp_x=temp_x+displace_x; temp_y=temp_y+displace_y; while(temp_x=0 e
4、lse setMark(x-(step+1)*displace_x, y-(step+1)*displace_y); public void run() try switch(game_state) case Start: Thread.sleep(2000); dialog.show(); game_state=Playing; repaint(); break; case End: repaint(); Thread.sleep(1500); ReStart(); repaint(); break; catch(InterruptedException ex) public void pa
5、int(Graphics g) super.paint(g); switch(game_state) case Start: g.drawString(“2005.7 by Yu Lin Tao“, 91, 240); g.setFont(font); g.setColor(Color.BLUE); g.drawString(“Gobang“, 112, 120); g.drawImage(title, 134, 135, this); break; case Playing: case End: g.drawString(“: 筿福:“, 105, 40); g.drawImage(blac
6、k, 132, 30, this); g.drawImage(white, 182, 30, this); if(winner!=0) g.setFont(font); g.setColor(Color.RED); message = winner=1? “:“; g.drawString(message, 120, 185); break; public void undo() if(steps.size()0) for(int i=0; i2; i+) (Grid)steps.get(steps.size()-1).Initial(); steps.remove(steps.size()-