91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 771KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發布日期: 2021-06-05
  • 語言: Java
  • 標簽: java??打地鼠??

資源簡介

JAva實現打地鼠小游戲,可用于課程設計

資源截圖

代碼片段和文件信息

package?project;


import?java.awt.Cursor;??
import?java.awt.Font;??
import?java.awt.Image;??
import?java.awt.Point;??
import?java.awt.Toolkit;??
import?java.awt.event.ActionEvent;??
import?java.awt.event.ActionListener;??
import?java.awt.event.MouseEvent;??
import?java.awt.event.MouseListener;??
import?java.util.Random;????
import?javax.swing.ImageIcon;??
import?javax.swing.Jframe;??
import?javax.swing.JLabel;??
import?javax.swing.JPanel;??
import?javax.swing.JButton;??
import?javax.swing.Timer;?

??
public?class?Hbzfh?extends?Jframe?implements?ActionListener?MouseListener?{??
????private?String?strDir?=?“./image/“;?//?定義一個變量為圖片所在的路徑,方便對圖片進行調用??
??
????JLabel?jlbMole?HitNumber?appearNumber?gradeNumber;//?設置圖片標簽
????JButton?st?=?new?JButton(“開始“);
????JButton?zt?=?new?JButton(“暫停“);
????JButton?nd?=?new?JButton(“難度增加“);
????Timer?timer;?//?定時器??
????Random?random;?//?隨機數用以決定地鼠的位置??
????int?delay?=?700;?//設置延遲時間?
????boolean?bool?=?false;
????int?r;//隨機數
????boolean?[]locate?=?{falsefalsefalsefalsefalsefalsefalsefalsefalsefalse};//防止重復點擊
????int?hit?=?0?apper?=?0?grade?=?0;?//?分別是打中次數、出現次數、等級??
??
????public?Hbzfh()?{??
????????this.settitle(“打地鼠“);//定義游戲窗口名稱??
????????
????????
????????setBack();?//?設置背景??
????????setGrade();?//?設置打中次數、出現次數、等級??
????????this.getContentPane().setLayout(null);?//?取消容器的原始布局,便于自定義

????????//?設置光標??
????????Toolkit?tk?=?Toolkit.getDefaultToolkit();?//定義光標?
????????Image?image?=?tk.createImage(strDir?+?“hammer.jpg“);?//讀取錘子圖片?
????????image=image.getScaledInstance(80?802);
????????Cursor?myCursor?=?tk.createCustomCursor(image?new?Point(10?10)?“xh“);?//設置光標圖像,大小,名稱?
????????this.setCursor(myCursor);?//采用此光標?
??
????????//?設置出現的地鼠??
????????ImageIcon?imageMole?=?new?ImageIcon(strDir?+?“mole.jpg“);//獲取圖片??
????????jlbMole?=?new?JLabel(imageMole);//將圖片定義到標簽中??
????????jlbMole.setSize(80?80);??//設置圖片大小
????????this.getContentPane().add(jlbMole);??//添加到容器中
????????jlbMole.setVisible(false);??//不顯示圖片
????????this.getContentPane().addMouseListener(this);//對面板進行監聽??
????????jlbMole.addMouseListener(this);//?監聽地鼠是否被打到??
????????
????????
????????//?定時器??
????????timer?=?new?Timer(delay?this);?//設置定時器為掩飾1s重復運行?
????????timer.start();??//開始計時
??
????????random?=?new?Random();??//產生隨機數
??
????????this.setLocation(200?200);?//設置面板位置?
????????this.setSize(438?450);??//設置面板大小
????????this.setResizable(true);?//用戶不可以改變面板大小?
????????this.setVisible(true);??//面板構建完成,可以顯示
????????
????????st.setBounds(70?370?90?30);//設置按鈕位置大小
????????zt.setBounds(170?370?9030);
????????nd.setBounds(270?370?9030);
????????st.addActionListener(this);//添加監控
????????zt.addActionListener(this);
????????nd.addActionListener(this);?
????????this.getContentPane().add(st);//顯示按鈕
????????this.getContentPane().add(zt);
????????this.getContentPane().add(nd);
????}??
??
????//?設置背景??
????private?void?setBack()?{??
????????((JPanel)?(this.getContentPan

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件????????301??2018-05-09?21:25??打地鼠\.classpath

?????文件????????385??2018-05-09?21:42??打地鼠\.project

?????文件????????629??2018-05-09?21:25??打地鼠\.settings\org.eclipse.jdt.core.prefs

?????文件???????6230??2018-07-02?22:46??打地鼠\bin\project\Hbzfh.class

?????文件?????407630??2018-05-09?22:05??打地鼠\image\1.png

?????文件?????475520??2018-05-09?22:49??打地鼠\image\backGround.png

?????文件???????1462??2018-05-09?21:40??打地鼠\image\hammer.jpg

?????文件???????2803??2018-05-09?21:40??打地鼠\image\mole.jpg

?????文件???????8440??2018-07-02?22:46??打地鼠\src\project\Hbzfh.java

?????目錄??????????0??2018-07-02?20:16??打地鼠\bin\project

?????目錄??????????0??2018-06-26?13:01??打地鼠\src\project

?????目錄??????????0??2018-06-26?13:01??打地鼠\.settings

?????目錄??????????0??2018-07-02?20:16??打地鼠\bin

?????目錄??????????0??2018-06-26?13:01??打地鼠\image

?????目錄??????????0??2018-06-26?13:01??打地鼠\src

?????目錄??????????0??2018-06-26?13:01??打地鼠

-----------?---------??----------?-----??----

???????????????903400????????????????????16


評論

共有 條評論