• 大小: 50.09MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-07-11
  • 语言: Java
  • 标签:

资源简介

Java联网双人对战的简单翻牌游戏,具有全屏的gui,awt绘图,IO流,EXPECTION,

资源截图

代码片段和文件信息

package remembergame;

import javax.swing.Jframe;
import javax.swing.JPanel;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collections;
import java.awt.Color;
import java.awt.Container;

import javax.swing.ImageIcon;
import javax.swing.JButton;

public class GameGUI extends Jframe {
private static final long serialVersionUID = 5407298675903095654L;

Container container;
//插入背景图片
BackgroundPanel bgd;
JPanel contentPane;
//计时框
JTextField textField;
public JButton buttonbutton1button2button3button4button5button6button7button8button9button10button11;
//对图片进行编号
public int[] picture = {123450012345};
//存入图片
public ImageIcon[] image = new ImageIcon[12];
//初始卡牌背面图片
public ImageIcon nul = new ImageIcon(“picture//99.jpg“);
//当前翻开的卡牌数
private int choose = 0;
//当前已翻开的卡牌
private int per1per2;
//记录已完成的数目以判断游戏结束
int win=0;
//当前翻开的卡牌对应的按钮
public JButton buttonXbuttonY;
//记录卡牌路劲以判断配对与否
public String[] ss = new String[12];
//记录开始的系统时间
long starttime = System.currentTimeMillis();
//游戏对局信息
public JTextField textField_1;
//开局
public void start() {
try {
//计时
time();
setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
@SuppressWarnings({ “unchecked“ “rawtypes“ })
//以列表打乱顺序
public int[] daluan(){
ArrayList list = new ArrayList();
for(int i = 0;i < picture.length;i++){     
            list.add(picture[i]);   
}
            Collections.shuffle(list);
for(int i = 0;i < picture.length;i++){
//重新写入图片顺序
picture[i] = (int) list.get(i);
}
 return picture;
}
public void time(){
//新的线程用于计时,直至游戏结束
new Thread(){
public void run(){
while (true) {
textField.setText(“   “+((System.currentTimeMillis() - starttime) / 1000));
}}
}.start();
}

@SuppressWarnings(“static-access“)
//绘制对局界面
public GameGUI() {
setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);
contentPane = new JPanel();
setContentPane(contentPane);
contentPane.setLayout(null);
bgd = new BackgroundPanel((new ImageIcon(“picture\\98.jpg“)).getImage());
bgd.setBounds(0020201100);
//将背景添加到底层
contentPane.add(bgd-1);

JLabel label = new JLabel(“用时:“);
label.setFont(new Font(“楷体“ Font.BOLD 60));
label.setForeground(Color.GRAY);
label.setBounds(264 67 211 105);
contentPane.add(label0);

textField = new JTextField();
textField.setFont(new Font(“楷体“ Font.PLAIN 60));
textField.setEditable(false);
textField.setOpaque(false);
textField.setBounds(466 90 225 59);
contentPane.add(textField);
textField.setColumns(10);
getContentPane().add(textField0);

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件          0  2017-11-28 16:06  Online_game\.metadata\.lock

     文件      76174  2017-12-24 11:28  Online_game\.metadata\.log

     文件         20  2017-11-28 16:07  Online_game\.metadata\.mylyn\.taskListIndex\segments.gen

     文件         32  2017-11-28 16:07  Online_game\.metadata\.mylyn\.taskListIndex\segments_1

     文件        235  2017-12-24 13:49  Online_game\.metadata\.mylyn\.tasks.xml.zip

     文件        561  2017-11-28 16:08  Online_game\.metadata\.mylyn\repositories.xml.zip

     文件        235  2017-12-24 14:11  Online_game\.metadata\.mylyn\tasks.xml.zip

     文件      10478  2017-12-24 04:38  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\0\c080706021e80017160dac2e8fb00a45

     文件       5845  2017-12-24 05:25  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\1\f04f931928e80017160dac2e8fb00a45

     文件      11053  2017-12-24 04:27  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\11\a06101d41fe80017160dac2e8fb00a45

     文件      10494  2017-12-24 05:24  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\17\100f961928e80017160dac2e8fb00a45

     文件      10588  2017-12-24 05:30  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\19\103512982ae80017160dac2e8fb00a45

     文件       7026  2017-12-24 12:45  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\1a\90e66a6e65e800171bd4b211f5513825

     文件      10630  2017-12-24 11:37  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\1c\80da78585ce800171bd4b211f5513825

     文件       6967  2017-12-24 11:58  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\22\40a8e5235fe800171bd4b211f5513825

     文件       6543  2017-12-24 05:42  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\23\40e0f6322ae80017160dac2e8fb00a45

     文件      10471  2017-12-24 04:41  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\24\507df1ba22e80017160dac2e8fb00a45

     文件       5849  2017-12-24 05:27  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\24\b063c14428e80017160dac2e8fb00a45

     文件       7020  2017-12-24 12:11  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\25\f0e25fcc60e800171bd4b211f5513825

     文件      10741  2017-12-24 04:36  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\29\e0dc67f220e80017160dac2e8fb00a45

     文件      11085  2017-12-24 04:31  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\2b\602ebb7820e80017160dac2e8fb00a45

     文件      10922  2017-12-24 04:09  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\2e\50b928661de80017160dac2e8fb00a45

     文件       8147  2017-12-24 14:12  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\2f\90903d9f71e800171bd4b211f5513825

     文件      11482  2017-12-24 13:11  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\31\e0400ee168e800171bd4b211f5513825

     文件       7914  2017-12-24 13:11  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\34\309a741971e800171bd4b211f5513825

     文件      10695  2017-12-24 04:58  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\37\20e2da0127e80017160dac2e8fb00a45

     文件      11482  2017-12-24 13:11  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\39\a05106e168e800171bd4b211f5513825

     文件       7940  2017-12-24 13:05  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\39\e073241668e800171bd4b211f5513825

     文件       7070  2017-12-24 12:50  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\3a\4051011766e800171bd4b211f5513825

     文件      11455  2017-12-24 12:23  Online_game\.metadata\.plugins\org.eclipse.core.resources\.history\3a\50aabe1663e800171bd4b211f5513825

............此处省略587个文件信息

评论

共有 条评论

相关资源