资源简介
java小游戏源码,亲测可用。内含 推箱子,坦克大战,俄罗斯方块,贪吃蛇,扫雷。好玩不贵,值得一探。
代码片段和文件信息
package org.lixiaogang.controller;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import zhh.game.tetris.entity.Ground;
import zhh.game.tetris.entity.Level;
import zhh.game.tetris.entity.Shape;
import zhh.game.tetris.entity.ShapeFactory;
import zhh.game.tetris.global.Config;
import zhh.game.tetris.global.Utilities;
import zhh.game.tetris.listener.ConfigListener;
import zhh.game.tetris.listener.GameListener;
import zhh.game.tetris.listener.GameViewListener;
import zhh.game.tetris.listener.PreviewListener;
import zhh.game.tetris.listener.ScoringListener;
/**
* 娓告垙鎺у埗鍣?br>
* 鎺у埗娓告垙鐨勫紑濮?缁撴潫鏆傚仠缁х画
* 鎺у埗娓告垙涓舰鐘剁殑绉诲姩鍙樺舰鑷姩涓嬭惤闅滅鐗╃殑婊¤璁″垎绾у埆鍙樻洿绛?br>
* 鍦ㄦ父鎴忕姸鎬佸彉鍖栨椂鍚戞敞鍐岀殑鐩戝惉鍣ㄥ彂鍑烘父鎴忎簨浠?br>
* 鍦ㄥ舰鐘?闅滅鐗╁彂鐢熷彉鍖栨椂鍚戞敞鍐岀殑鐩戝惉鍣ㄥ彂鍑烘父鎴忔樉绀轰簨浠?br>
* @author zhaohuihua
*/
public class GameController extends KeyAdapter
implements ConfigListener ScoringListener {
/**
* 娓告垙鐩戝惉鍣?
*/
private GameListener[] gameListeners;
/**
* 娓告垙鏄剧ず鐩戝惉鍣?
*/
private GameViewListener[] gameViewListeners;
/**
* 棰勮鐩戝惉鍣?
*/
private PreviewListener[] previewListeners;
/**
* 璁″垎绠$悊鍣?
*/
private ScoringController scorer;
/**
* 鍦板舰
*/
private Ground ground;
/**
* 褰㈢姸
*/
private Shape shape;
/**
* 褰㈢姸鍒涘缓鐨勬椂闂?br>
* 鐢ㄤ簬灞忚斀褰㈢姸鍒氬垱寤烘椂鐨勬搷浣滀簨浠?br>
* 鏈夋椂鐢ㄦ埛瀵逛竴涓舰鐘舵寔缁墽琛屾煇涓?搷浣? 鐩磋嚦璇ュ舰鐘惰Е搴曞彉鎴愰殰纰嶇墿
* 鑰岀敤鎴峰彲鑳戒粛鏈仠姝㈡搷浣? 瀵艰嚧璇ユ搷浣滅洿鎺ヤ綔鐢ㄤ簬涓嬩竴褰㈢姸
* 浣嗚繖涓?搷浣滃浜庝笅涓?舰鐘跺彲鑳藉苟涓嶅悎閫?br>
* 浠ュ舰鐘跺垱寤虹殑鏃堕棿鍔犱笂涓?釜閰嶇疆鐨勫亸绉绘椂闂存潵灞忚斀褰㈢姸鍒氬垱寤烘椂鐨勯儴鍒嗘搷浣滀簨浠?br>
* 浠ュ噺灏戣繖绉嶆儏鍐?br>
*/
private long shapeCreateTime;
/**
* 涓嬩竴娆$殑褰㈢姸 鐢ㄤ簬鎻愪緵棰勮
*/
private Shape nextShape;
/**
* 褰㈢姸鑷姩涓嬭惤鐨勬帶鍒跺櫒
*/
private Thread shapeDropDriver;
/**
* 娓告垙鏄惁姝e湪杩愯
*/
private boolean playing;
/**
* 娓告垙鏄惁宸叉殏鍋?
*/
private boolean pause;
public GameController() {
// 灏嗙洃鍚櫒鍒濆鍖栦负0闀垮害鏁扮粍 鍑忓皯鍚庣画浜嬩欢骞挎挱鏃剁殑绌哄?鍒ゆ柇
gameListeners = new GameListener[0];
gameViewListeners = new GameViewListener[0];
previewListeners = new PreviewListener[0];
// 璁″垎鍣?
scorer = new ScoringController();
// 璁″垎鍣ㄥ鍔犵洃鍚櫒
scorer.addScoringListener(this);
// 澧炲姞澹伴煶鐩戝惉鍣?
SoundController sound = new SoundController();
addGameListener(sound); // 娓告垙鐘舵?鍙樺寲瑙﹀彂鐨勫0闊?
addGameViewListener(sound); // 娓告垙鏄剧ず鍙樺寲瑙﹀彂鐨勫0闊?褰㈢姸涓嬭惤鍒颁綅)
scorer.addScoringListener(sound); // 璁″垎鍙樺寲瑙﹀彂鐨勫0闊?
}
/**
* 娓告垙鏄惁鏄殏鍋滅姸鎬?
* @return
*/
public boolean isPause() {
return pause;
}
/**
* 娓告垙鏄惁姝e湪杩愯
* @return
*/
public boolean isPlaying() {
return playing;
}
/**
* 鎸夐敭澶勭悊:
* 1. 寮?/缁撴潫
* 2. 鏆傚仠/缁х画
* 3. 褰㈢姸鍚戝乏绉诲姩
* 4. 褰㈢姸鍚戝彸绉诲姩
* 5. 褰㈢姸鍙樺舰
* 6. 褰㈢姸鍚戜笅绉诲姩
* 7. 褰㈢姸涓?惤鍒板簳
* 褰㈢姸鐨勬寜閿鐞嗛鍏堝垽鏂舰鐘剁Щ鍔ㄦ垨鍙樺舰鍚庢槸鍚︿笌鍦板舰鍙戠敓纰版挒
* 濡傛灉涓嶅彂鐢熺鎾炲垯鎵ц绉诲姩鎴栧彉褰㈡搷浣?br>
* 褰撳舰鐘朵笉鑳藉啀鍚戜笅绉诲姩鏃? 灏嗚褰㈢姸鍙樻垚闅滅鐗? 鐒跺悗杩涜婊¤璁″垎绛夊悗缁鐞?br>
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
I.A.... 0 2018-05-07 13:47 Workspace-I\.me
I.A.... 43913 2018-05-07 14:53 Workspace-I\.me
I.A.... 20 2018-05-07 13:49 Workspace-I\.me
I.A.... 32 2018-05-07 13:49 Workspace-I\.me
I.A.... 250 2018-05-07 14:31 Workspace-I\.me
I.A.... 438 2018-05-07 13:47 Workspace-I\.me
I.A.... 250 2018-05-07 14:51 Workspace-I\.me
I.A.... 936 2018-05-07 14:09 Workspace-I\.me
I.A.... 1151 2018-05-07 14:09 Workspace-I\.me
I.A.... 25168 2018-05-07 14:27 Workspace-I\.me
I.A.... 3203 2018-05-07 14:24 Workspace-I\.me
I.A.... 868 2018-05-07 14:09 Workspace-I\.me
I.A.... 13165 2018-05-07 14:46 Workspace-I\.me
I.A.... 0 2018-05-07 14:00 Workspace-I\.me
I.A.... 7517 2018-05-07 14:17 Workspace-I\.me
I.A.... 3215 2018-05-07 14:22 Workspace-I\.me
I.A.... 6130 2018-05-07 14:47 Workspace-I\.me
I.A.... 59 2018-05-07 14:17 Workspace-I\.me
I.A.... 1386 2018-05-07 14:09 Workspace-I\.me
I.A.... 0 2018-05-07 14:46 Workspace-I\.me
I.A.... 3873 2018-05-07 14:22 Workspace-I\.me
I.A.... 10107 2018-05-07 14:23 Workspace-I\.me
I.A.... 0 2018-05-07 14:47 Workspace-I\.me
I.A.... 3222 2018-05-07 14:23 Workspace-I\.me
I.A.... 13172 2018-05-07 14:46 Workspace-I\.me
I.A.... 4099 2018-05-07 13:50 Workspace-I\.me
I.A.... 1593 2018-05-07 14:24 Workspace-I\.me
I.A.... 4095 2018-05-07 14:23 Workspace-I\.me
I.A.... 1641 2018-05-07 14:18 Workspace-I\.me
I.A.... 14075 2018-05-07 14:09 Workspace-I\.me
............此处省略952个文件信息
- 上一篇:JAVA实现排课系统代码--机密.rar
- 下一篇:java转pdf需要的jar包
评论
共有 条评论