那裡有用java寫的小游戲的原馬呀﹗﹗

gull1234 2003-03-12 07:53:19
同標題。
...全文
86 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
gull1234 2003-03-26
  • 打赏
  • 举报
回复
thx
ajoke 2003-03-22
  • 打赏
  • 举报
回复
/** the eight direction */
final static int addX[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
final static int addY[] = { -1, -1, -1,0,0,1,1,1 };

/**check whether the use can place the chess */
private boolean checkPass(int x, int y, int play)
{
if( board[ x ][ y ] != 0 )
return false;
for(int i = 0; i < 8; i ++ )
{
int x1 = x + addX[ i ];
int y1 = y + addY[ i ];
if( x1 < GRIDSIZE && x1 >=0 && y1<GRIDSIZE && y1>= 0 && board[ x1 ][ y1 ] != 0 && board[ x1 ][ y1 ] != play )
{
x1= x1 + addX[ i ];
y1= y1 + addY[ i ];
while( x1>=0 && x1 < GRIDSIZE && y1>=0 && y1< GRIDSIZE )
{
if( board[ x1 ][ y1 ] == 0 )
break;
if( board[ x1 ][ y1 ] == play )
return true;
x1= x1 + addX[ i ];
y1= y1 + addY[ i ];
}
}
}
return false;
}

/** popup a dialog to show the current steps that can be choiced */
public void showNextStep( int play )
{
String msg = "";
for( int i =0 ;i <GRIDSIZE ; i++ )
for( int j= 0; j < GRIDSIZE ; j++ )
if( checkPass( i, j, play ) == true )
msg += "Right point at: ->:" + Integer.toString( i ) +"," + Integer.toString( j ) + "\n" ;
JOptionPane.showMessageDialog( null , msg );
}

/** decide the step in (x,y) so change the board, import change the affect of the new place */
public void changeBoard( int x, int y, int play )
{
board[ x ][ y ] = play;
for(int i = 0; i < 8; i ++ )
{
int x1 = x + addX[ i ];
int y1 = y + addY[ i ];
if( x1 < GRIDSIZE && x1 >=0 && y1<GRIDSIZE && y1>= 0 && board[ x1 ][ y1 ] != 0 && board[ x1 ][ y1 ] != play )
{
x1= x1 + addX[ i ];
y1= y1 + addY[ i ];
while( x1>=0 && x1 < GRIDSIZE && y1>=0 && y1< GRIDSIZE )
{
if( board[ x1 ][ y1 ] == 0 )
break;
if( board[ x1 ][ y1 ] == play )
{
do
{
x1 = x1 - addX[ i ];
y1 = y1 - addY[ i ];
board[ x1 ][ y1 ] = play;
}
while( x1 != x || y1 != y );
break;
}
x1= x1 + addX[ i ];
y1= y1 + addY[ i ];
}
}
}
}

/** change the chess arry by board */
public void changeChessByBoard()
{
for( int i =0; i < GRIDSIZE ; i++ )
for( int j=0; j < GRIDSIZE ; j++ )
{
if( board[ i ][ j ] == WHITE_PLAY )
chessArray[ i ][ j ].setCurrentType( JokeChess.WHITE_CHESS );
else if( board[ i ][ j ] == BLACK_PLAY )
chessArray[ i ][ j ].setCurrentType( JokeChess.BLACK_CHESS );
}
}

/** repaint the panel to show all the chess that should be showed */
public void showChess( )
{
for( int i =0; i < GRIDSIZE ; i++ )
for( int j=0; j < GRIDSIZE ; j++ )
{
if( board[ i ][ j ] != 0 )
chessArray[ i ][ j ].setShow( true );
}
SwingUtilities.invokeLater( new Runnable(){
public void run(){
repaint();
}
});
}

/** get the current steps count */
private int getNextStepCount( int play )
{
int count = 0;
for( int i =0 ;i <GRIDSIZE ; i++ )
for( int j= 0; j < GRIDSIZE ; j++ )
if( checkPass( i, j, play ) == true )
count ++;
return count ;
}

/** get the detail of all the steps can be placed info of point(x,y) */
private Point[] getNextStepPoint(int play)
{
Point[] step = new Point[ getNextStepCount( play ) ];
int count = 0;
for( int i =0 ;i <GRIDSIZE ; i++ )
for( int j= 0; j < GRIDSIZE ; j++ )
if( checkPass( i, j, play ) == true )
{
step[ count ] = new Point( i, j );
count++;
}
return step;
}

ajoke 2003-03-22
  • 打赏
  • 举报
回复
// ChessBoar.java
/*
* ChessBoard.java
*
* Created on GRIDSIZE 03年3月5日, 上午8:54
*/


/**
*
* @author Administrator
* @version
*/
import javax.swing.*;
import java.awt.*;
import javax.swing.border.*;
import java.awt.event.*;
import javax.swing.text.*;
public class ChessBoard extends JPanel{

/** Creates new ChessBoard */

/** the display size of grid*/
public static int GRIDSIZE = 20;

/**the control of insert*/
private GridBagConstraints gbc;

/** store the chess condition on board*/
private int board[][];

/** stroe the whole chesses include hiden chesses*/
private JokeChess chessArray[][];

/** define the play ----just like user*/
final static int WHITE_PLAY = 1;

/** define the play ---just like computer*/
final static int BLACK_PLAY = 2;

/** parant -----playJoke is a JFrame*/
private playJoke parent;

/** temp use for decide who should move*/
// private boolean flag = true;

/**user style color*/
private int userPlay = BLACK_PLAY;


/**who first place the chess*/
private int whoFirst;

/**set user play style*/
public void setUserPlay( int style )
{
if( style == WHITE_PLAY )
userPlay = WHITE_PLAY;
else
userPlay = BLACK_PLAY;
}

/** get computer play style by user play*/
public int getComputerPlay()
{
return (userPlay == BLACK_PLAY ? WHITE_PLAY : BLACK_PLAY );
}
/**get user play style */
public int getUserPlay()
{
return userPlay ;
}

public ChessBoard(playJoke s) {
parent = s;
gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
loadChess();

addMouseListener( new MouseAdapter(){
public void mousePressed( MouseEvent event )
{
if( userMove( event.getX(), event.getY(), getUserPlay() ) == true )
{
parent.setStatusText("Computer move....");
computerMove( getComputerPlay() );
}
}
});


}

/** place the JokeChess on the board */
public void place( Component c, int x, int y )
{
gbc.gridx = x;
gbc.gridy = y;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.weightx = 0;
gbc.weighty = 0;
add( c , gbc );
}

/** Check whether the game is over*/
public boolean gameOver()
{
boolean flag = true;
for( int i =0; i< GRIDSIZE ; i++ )
for( int j =0 ; j < GRIDSIZE ; j ++ )
if( board[ i ][ j ] == 0)
{
flag = false;
break;
}
return flag;
}

/** check the board to get the winner */
public int getWinner()
{
int white = 0;
int black = 0;
for( int i =0; i< GRIDSIZE ; i++ )
for( int j =0 ; j < GRIDSIZE ; j ++ )
if( board[ i ][ j ] == WHITE_PLAY )
white ++ ;
else
black ++ ;
if( white == black )
return 0;
else
return white > black? WHITE_PLAY : BLACK_PLAY;
}


/** create all the JokeChess and add it the the chess board panel */
private void loadChess()
{
parent.setStatusText("Wait loading ...........");
parent.setEnabled( false );
removeAll();
this.setLayout( new GridLayout(GRIDSIZE ,GRIDSIZE ) );
this.setPreferredSize( new Dimension( 50+ GRIDSIZE * 20, 50+ GRIDSIZE * 20 ) );
this.setBorder( new LineBorder(Color.orange, 2) );

if( chessArray != null )
chessArray = null;
chessArray = new JokeChess[ GRIDSIZE ][ GRIDSIZE ];
if( board != null )
board = null;
board = new int[GRIDSIZE][GRIDSIZE ];
int position;
for( int y =0; y < GRIDSIZE ; y ++ )
for( int x =0 ; x < GRIDSIZE ; x ++ )
{
if( x == 0 && y == 0 )
position = JokeChess.TOP_LEFT;
else if( x == 0 && y == (GRIDSIZE - 1 ) )
position = JokeChess.BOTTOM_LEFT;
else if( x == (GRIDSIZE - 1 ) && y == 0 )
position = JokeChess.TOP_RIGHT;
else if( x == (GRIDSIZE - 1 ) && y == (GRIDSIZE - 1 ) )
position = JokeChess.BOTTOM_RIGHT;
else if( x == 0 )
position = JokeChess.LEFT;
else if( y == 0 )
position = JokeChess.TOP;
else if( x == (GRIDSIZE - 1 ) )
position = JokeChess.RIGHT;
else if( y == (GRIDSIZE - 1 ) )
position = JokeChess.BOTTOM;
else
position = JokeChess.CENTER;
/* if( x ==0 && y == 0 )
position = JokeChess.TOP_LEFT;
else if( x != 0 && y == 0 && x != (GRIDSIZE - 1 ) )
position = JokeChess.LEFT;
else if( x == (GRIDSIZE - 1 ) && y == 0 )
position = JokeChess.BOTTOM_LEFT;
else if( x == (GRIDSIZE - 1 ) && y != 0 && y != (GRIDSIZE - 1 ) )
position = JokeChess.BOTTOM;
else if( x == (GRIDSIZE - 1 ) && y == (GRIDSIZE - 1 ) )
position = JokeChess.BOTTOM_RIGHT;
else if( x !=0 && x != (GRIDSIZE - 1 ) && y == (GRIDSIZE - 1 ) )
position = JokeChess.RIGHT;
else if( x == 0 && y == (GRIDSIZE - 1 ) )
position = JokeChess.TOP_RIGHT;
else if( x == 0 && y != 0 && y!= (GRIDSIZE - 1 ) )
position = JokeChess.TOP;
else
position = JokeChess.CENTER;
*/
JokeChess newChess = new JokeChess(position);
newChess.setShow( false );
newChess.setNoX( y );
newChess.setNoY( x );
board[ newChess.getNoX() ] [ newChess.getNoY() ] = 0;
chessArray[ newChess.getNoX() ] [ newChess.getNoY() ] = newChess;
place( newChess, x, y );
}

board[ (GRIDSIZE / 2 ) ] [ (GRIDSIZE / 2 ) ] = BLACK_PLAY ;
board[ (GRIDSIZE / 2 ) ] [ (GRIDSIZE / 2 -1 ) ] = BLACK_PLAY;
chessArray[ (GRIDSIZE / 2 ) ][ (GRIDSIZE / 2 ) ].setCurrentType( JokeChess.BLACK_CHESS );
chessArray[ (GRIDSIZE / 2 ) ][ (GRIDSIZE / 2 - 1 ) ].setCurrentType( JokeChess.BLACK_CHESS );
chessArray[ (GRIDSIZE / 2 ) ][ (GRIDSIZE / 2 ) ].setShow( true );
chessArray[ (GRIDSIZE / 2 ) ][ (GRIDSIZE / 2 - 1 ) ].setShow( true );

board[ (GRIDSIZE / 2 - 1 ) ] [ (GRIDSIZE / 2 ) ] = WHITE_PLAY;
board[ (GRIDSIZE / 2 - 1 ) ] [ (GRIDSIZE / 2 - 1 ) ] = WHITE_PLAY;
chessArray[ (GRIDSIZE / 2 - 1 ) ][ (GRIDSIZE / 2 ) ].setCurrentType( JokeChess.WHITE_CHESS);
chessArray[ (GRIDSIZE / 2 - 1 ) ][ (GRIDSIZE / 2 - 1 ) ].setCurrentType( JokeChess.WHITE_CHESS );
chessArray[ (GRIDSIZE / 2 - 1 ) ][ (GRIDSIZE / 2 ) ].setShow( true );
chessArray[ (GRIDSIZE / 2 - 1 ) ][ (GRIDSIZE / 2 - 1 ) ].setShow( true );
repaint();
parent.setEnabled( true );
parent.setStatusText("Load Ok!");
}


ajoke 2003-03-22
  • 打赏
  • 举报
回复
公司不能发email,谅解,贴出来版主谅解
4个文件,其中还要resource目录下的一个splash.jpg文件
用Forte for Java 编译可以的
// playJoke.java
/**
*
* @author Administrator
* @version
*/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;

public class playJoke extends JFrame {


private JWindow splashScreen = null;
private JLabel status = null;
private ChessBoard chessBoard = null;
private JSplitPane split = null;
private ControlPanel rightPanel = null;
private JMenuBar menuBar = null;
/** Creates new playJoke */
public playJoke() {
super("Play Chess");
init();
pack();
this.setResizable( false );
}

private void init()
{
buildSplashScreen();
addWindowListener( new WindowAdapter(){
public void windowClosing( WindowEvent e )
{
System.exit( 0 );
}
});
createMenu();
status = new JLabel();
status.setText( "Loading ......" );
getContentPane().add( status, BorderLayout.SOUTH );

split = new JSplitPane();
split.setDividerSize( 5 );

chessBoard = new ChessBoard(this);
split.setLeftComponent( chessBoard );

rightPanel = new ControlPanel( this, chessBoard );
split.setRightComponent( rightPanel );

getContentPane().add( split, BorderLayout.CENTER );

this.setLocation( 200, 200 );
splashScreen.setVisible( false );
status.setText( "Loading OK!" );
}
public static void main( String[] args )
{
new playJoke().setVisible( true );
}

/**no use because the width and height is defiend by the chessboard
public java.awt.Dimension getPreferredSize() {
return new Dimension( 600, 400 );
}
*/

private void buildSplashScreen()
{
splashScreen = new JWindow();
JLabel splashLabel = new JLabel( new ImageIcon( getClass().getResource( "/resource/Splash.jpg" ) ) );
splashScreen.getContentPane().add( splashLabel, BorderLayout.CENTER );
splashScreen.pack();
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension thisSize = splashScreen.getSize();
splashScreen.setLocation( screenSize.width/2 - thisSize.width/2,
screenSize.height/2 - thisSize.height/2);
splashScreen.setVisible( true );
}

private void createMenu()
{
}
private class MouseAttention extends MouseAdapter
{
public void mousePressed( MouseEvent event )
{
}
}

public void setStatusText( String msg )
{
status.setText( msg );
}
}

gull1234 2003-03-21
  • 打赏
  • 举报
回复
overgull@hotmail.com
vicious 2003-03-18
  • 打赏
  • 举报
回复
楼上的 :) 我的email是 huanghaisong@hotmail.com :) 我想要一份黑白棋的源码 谢谢了:)
ajoke 2003-03-18
  • 打赏
  • 举报
回复
我用JAVA写了一个黑白棋的单机版,不是很智能,打不过手机上的那个游戏
但是很稳定,不会出错
我刚学的,不知道有没有兴趣
shine333 2003-03-14
  • 打赏
  • 举报
回复
jdk目录下demo\applets\tictactoe
binbin 2003-03-14
  • 打赏
  • 举报
回复
自己去找,找到以后反编译就看到源码啦.
waittingforyou 2003-03-14
  • 打赏
  • 举报
回复
http://www.cnjm.net
【采用BPSK或GMSK的Turbo码】MSK、GMSK调制二比特差分解调、turbo+BPSK、turbo+GMSK研究(Matlab代码实现)【采用BPSK或GMSK的Turbo码】MSK、GMS内容概要:本文主要介绍了采用BPSK或GMSK调制方式的Turbo码相关技术研究,重点涵盖GMSK调制下的二比特差分解调方法、Turbo码与BPSK/GMSK调制相结合的系统性能分析,并提供了完整的Matlab代码实现方案。研究内容包括调制解调原理、编码结构设计、误码率仿真及系统优化等关键环节,旨在通过仿真手段验证所提出方案的有效性和可靠性,帮助研究人员深入理解现代数字通信系统中的关键技术和其实现方法。; 适合人群:具备一定通信原理和Matlab编程基础,从事无线通信、信号处理、编码理论等相关领域的研究生、科研人员及工程技术人员。; 使用场景及目标:①掌握GMSK调制与Turbo码结合的系统设计与仿真方法;②学习二比特差分解调算法在实际通信系统中的应用;③通过Matlab代码实现提升对数字调制解调和信道编码技术的理解与实践能力;④为相关课题研究、毕业设计或工程项目提供参考和技术支持。; 阅读建议:建议读者结合文中提供的Matlab代码逐模块运行与调试,对照通信系统基本原理深入理解各环节功能,重点关注调制解调过程与Turbo译码的协同工作机制,并尝试修改参数以观察系统性能变化,从而达到理论与实践相结合的学习效果。
代码转载自:https://pan.quark.cn/s/a4b39357ea24 LA 1010 逻辑分析仪被视作一种效能卓越的数字信号分析设备,其核心功能在于对数字通信协议,例如I²C,进行检测与解构。本资源将集中阐述LA 1010的操作流程以及如何借助该设备对I²C协议的波形展开分析。 确保逻辑分析仪被正确地连接至目标系统是极为关键的环节。在运用LA 1010的过程中,必须将分析仪的通道0与通道1分别对应连接至目标装置的SCL(时钟)与SDA(数据)线路。务必保证连接的稳固性且无任何干扰因素,以此确保数据采集的精确度。 随后,需要设定采样参数。采样频率对于能否成功捕捉到信号具有决定性的作用。针对I²C协议,通常选用的采样频率范围介于100kHz到400kHz之间,这一范围的选择取决于实际应用场景中I²C总线的运行速度。然而,LA 1010所能达到的最高采样速率可能高达500MHz,因此需要根据具体需求进行相应的调整。此外,还必须精心挑选适配目标设备工作电压的电压等级,例如3.3V、5V或1.8V。 在软件操作层面,需要选取恰当的通道与协议种类,即I²C。一旦启动采样,逻辑分析仪便开始记录相关数据。软件界面通常会实时展示波形图,为观察与分析提供便利。 关于I²C协议波形的解读,我们可以遵循以下步骤: 1. 总线处于空闲状态时:SCL与SDA均维持在高电平位置,这表明总线当前未进行数据传输。 2. 传输起始信号:当SCL处于高电平期间,SDA线从高电平转换至低电平,此动作标志着数据传输的开始。 3. 地址、数据及应答的识别:在每一个SCL高电平脉冲的持续时间内,SDA线上的电平状态代表了数据位。地址与数据的传输均为双向过程,而读写标识则由SDA线上的电平来...
下载代码方式:https://pan.quark.cn/s/a4b39357ea24 在当前文档中,我们将详细研究在C#开发平台中借助BouncyCastle.Crypto库1.8.10版本达成中国的国家标准密码学方案,涵盖SM2、SM3以及SM4这几项技术。这些密码学方案在中国网络安全保障与数据维护领域具有核心地位,为本地化安全解决方案提供了坚实的技术支撑。 让我们首先掌握这三个国家密码算法的基本原理: 1. **SM2算法**:SM2是一种基于椭圆曲线密码体系(ECC)的公钥加密方案,主要用于数字签名和加密操作。它提供了一种高效且安全的身份确认和数据防护机制。 2. **SM3算法**:SM3是一种密码学哈希函数,与SHA-256类似,能够将任意长度的输入信息压缩为固定长度的摘要,常用于数据完整性的检验和确认。 3. **SM4算法**:SM4是一种分组密码方案,采用128位的分组大小和128位的密钥,适用于对称加密,广泛用于无线网络传输和存储数据的加密处理。 接下来,我们将逐步解析如何运用BouncyCastle.Crypto库在C#环境下实现这些密码学方案: **1. 引入库与配置开发环境** 在C#应用程序中,需要通过NuGet包管理工具或手动方式添加BouncyCastle库的引用。务必确保安装的是1.8.10版本。 ```csharp using Org.BouncyCastle.Crypto; using Org.BouncyCastle.Crypto.Parameters; using Org.BouncyCastle.Security; ``` **2. 实施SM2的加签与解签** SM2的签名过程和验证操作涉及椭圆曲线运算。必须创建一个私...
源码下载地址: https://pan.quark.cn/s/28d95df2f2ec 在数字化时代的进程中,微信小程序凭借其便捷性、无需下载安装的优势,成为了移动互联网应用的热门选择。本篇将详细剖析“猫眼微信小程序源码”,展示其内部开发技术和设计思想,为计划从事微信小程序开发的人员提供重要的学习素材。猫眼微信小程序是一款融合了电影票务购买、影片资讯检索、影评交流等功能的娱乐软件,其源代码具有显著的学习意义。我们必须掌握微信小程序的基本构成。微信小程序由JSON配置文档、WXML结构文档、WXSS样式文档和JavaScript逻辑文档四个部分构成,这些部分共同创建了小程序的运行条件。 1. JSON配置文档:这是小程序的整体设置,包括小程序的基本要素,例如AppID、页面路由、网络请求地址等。猫眼小程序的JSON配置文档或许包含了特定的功能配置,例如个性化主题色调、导航栏设计等,以达成其独特的视觉呈现。 2. WXML(WeiXin Markup Language):这是微信小程序的结构性语言,类似于HTML,用于构建页面的结构和布局。猫眼小程序的WXML文档中,可能包含了丰富的组件,如button(按钮)、view(视图容器)、image(图片)等,通过这些组件来设计出用户交互界面。 3. WXSS(WeiXin Style Sheet):这是微信小程序的样式定义语言,基于CSS,但包含一些扩展功能。猫眼小程序的WXSS文档中,可能会采用多种布局技术(如Flex布局)以及样式动画,以完成精细的UI设计和平滑的用户体验。 4. JavaScript逻辑文档:这是小程序的关键部分,负责处理业务流程和数据管理。猫眼小程序的JavaScript文档中,可能包含了接口调...

67,535

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧