• 大小: 576KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-14
  • 语言: Java
  • 标签: 源码  工具  

资源简介

NULL 博文链接:https://fengyanzhang.iteye.com/blog/1884350

资源截图

代码片段和文件信息

import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import java.util.Random;
import java.util.Timer;

import javax.swing.ImageIcon;
import javax.swing.Jframe;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Catch_Me extends Jframe implements Runnable
{
    Random R=new Random();
    Random RR=new Random();
ImageIcon bird_img = new ImageIcon(“03.gif“);//小鼠图片
ImageIcon mouse_img = new ImageIcon(“07.gif“);//老猫图片
ImageIcon milipic = new ImageIcon(“star1.gif“);//星星图片
ImageIcon sun= new ImageIcon(“sunshine_0.png“);//太阳图片
ImageIcon dog=new ImageIcon(“dog.gif“);
ImageIcon bread=new ImageIcon(“bread.gif“);
ImageIcon bread2=new ImageIcon(“bread2.gif“);
ImageIcon bread3=new ImageIcon(“bread3.gif“);
ImageIcon bread4=new ImageIcon(“bread4.gif“);
ImageIcon bread5=new ImageIcon(“bread5.gif“);



//图片装载到标签中
JLabel jb_bird = new JLabel(bird_img);
JLabel jb2_mouse = new JLabel(mouse_img);
JLabel mili = new JLabel(milipic);
JLabel sunl = new JLabel(sun);
JLabel dogl=new JLabel(dog);
JLabel breadl=new JLabel(bread);
JLabel breadl2=new JLabel(bread2);
JLabel breadl3=new JLabel(bread3);
JLabel breadl4=new JLabel(bread4);
JLabel breadl5=new JLabel(bread5);

//设置线程是否运行
static boolean isContinue=true;
static boolean noContinue=true;
static int i=0;
static int j=0;
//初始化对象

public Catch_Me() {
setBak(); // 调用背景方法
this.setSize(980 670);// 设置窗口大小
this.settitle(“小鼠快跑“);
//this.setLayout(null);
this.setLocationRelativeTo(null);
//设置游戏层

JPanel jp = new JPanel();
jp.setOpaque(false);this.add(breadl);
        this.add(breadl2);
        this.add(breadl3);
        this.add(breadl4);
        this.add(breadl5);


//jp.add(breadl);

jp.add(sunl);
        jp.add(jb_bird);
        jp.add(jb2_mouse);
        jp.add(mili);
        jp.add(dogl);
this.getContentPane().add(jp);
breadl.setBounds(R.nextInt(960) R.nextInt(640)205154);
breadl2.setBounds(R.nextInt(960) R.nextInt(640)205154);
breadl3.setBounds(R.nextInt(960) R.nextInt(640)205154);
breadl4.setBounds(R.nextInt(960) R.nextInt(640)205154);
breadl5.setBounds(R.nextInt(960) R.nextInt(640)205154);
 
this.setDefaultCloseOperation(Jframe.EXIT_ON_CLOSE);

//增加鼠标动作
this.addMouseMotionListener(new MouseMotionListener() {
//增加鼠标移动执行的方法
public void mouseMoved(MouseEvent arg0) {
if (arg0.getY() <=670&& arg0.getX() <=980) {
jb_bird.setLocation(arg0.getX() - 50 arg0.getY() - 80);
}
if((jb_bird.getLocation().x>=mili.getLocation().x-15&&jb_bird.getLocation().x<=mili.getLocation().x+15)&&(jb_bird.getLocation().y>=mili.getLocation().y-15&&jb_bird.getLocation().y<=mili.getLocation().y+15)){
Random rnd = new Random();
Random rnd2=new Random();
mili.setLocation(rnd.nextInt(300)+1 rnd2.nextInt(300)+1);
//jb2_mouse.setLocation(rnd.nextInt(544) rnd2.nextInt(420));
}
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2013-06-08 12:17  catch_me\
     文件         232  2012-06-04 19:29  catch_me\.classpath
     文件         384  2012-06-04 19:29  catch_me\.project
     文件       13791  2012-06-04 19:33  catch_me\03.gif
     文件       26319  2012-06-04 19:33  catch_me\07.gif
     目录           0  2013-06-08 12:17  catch_me\bin\
     文件        4033  2012-06-04 19:33  catch_me\bin\4.gif
     文件        1907  2012-06-13 16:12  catch_me\bin\Catch_Me$1.class
     文件        4975  2012-06-13 16:12  catch_me\bin\Catch_Me.class
     文件         989  2012-06-13 13:56  catch_me\bin\Catch_Me_Main.class
     文件         481  2012-06-05 13:25  catch_me\bin\timetest_noeasy.class
     文件      190839  2012-06-04 19:33  catch_me\body_bg.jpg
     文件         791  2012-06-04 19:33  catch_me\bread.gif
     文件         913  2012-06-04 19:33  catch_me\bread2.gif
     文件         699  2012-06-04 19:33  catch_me\bread3.gif
     文件         719  2012-06-04 19:33  catch_me\bread4.gif
     文件        1671  2012-06-04 19:33  catch_me\bread5.gif
     目录           0  2013-06-08 12:17  catch_me\catch\
     文件         651  2012-06-04 19:29  catch_me\catch\.classpath
     文件         381  2012-06-04 19:29  catch_me\catch\.project
     文件       13791  2012-06-04 19:29  catch_me\catch\03.gif
     文件       26319  2012-06-04 19:29  catch_me\catch\07.gif
     目录           0  2013-06-08 12:17  catch_me\catch\bin\
     文件        4033  2012-06-04 19:29  catch_me\catch\bin\4.gif
     文件        1907  2012-06-04 19:29  catch_me\catch\bin\Catch_Me$1.class
     文件        5653  2012-06-04 19:29  catch_me\catch\bin\Catch_Me.class
     文件         481  2012-06-04 19:29  catch_me\catch\bin\timetest_noeasy.class
     文件      190839  2012-06-04 19:29  catch_me\catch\body_bg.jpg
     文件         791  2012-06-04 19:29  catch_me\catch\bread.gif
     文件         913  2012-06-04 19:29  catch_me\catch\bread2.gif
     文件         699  2012-06-04 19:29  catch_me\catch\bread3.gif
............此处省略19个文件信息

评论

共有 条评论