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

  • 大小: 18.1MB
    文件類型: .zip
    金幣: 2
    下載: 1 次
    發布日期: 2023-07-13
  • 語言: Java
  • 標簽: Java??聯機??

資源簡介

這是本人初次MVC的練習,關于俄羅斯方塊的控制代碼借鑒了網上的一些資料,不足之處盡請諒解。 注:本程序存在一個偶爾會發生的方塊堆積到頂端時無法停止游戲的bug,原因未知。 詳見:http://blog.csdn.net/a343902152/article/details/49914759

資源截圖

代碼片段和文件信息

package?Controller;

import?MySocket.ExchangeThread;
import?entity.Rect;
import?model.GameDao;
import?view.OfflinePanel;
import?view.OnlinePanel;

import?javax.swing.*;
import?java.util.Random;
import?java.util.Timer;
import?java.util.TimerTask;

/**
?*?游戲整體控制器,比如命令方塊移動,暫停游戲等
?*?Create?by?Zhou
?*/
public?class?GameController?{

public?static?GameController?localController;

//?界面
private?JPanel?panel;
//?時間控制器,加載Gametask,每過一段時間,界面就變化一次
private?Timer?timer;

private?boolean?isRunning?=false;

public?GameDao?getGamedao()?{
return?gamedao;
}

public?Rect?getCurRect()?{
return?curRect;
}

public?Rect?getNextRect()?{
return?nextRect;
}

//?游戲進程控制器,比如碰撞檢測之類的
private?GameDao?gamedao;

//?當前圖形與下一個圖形
private?Rect?curRect;
private?Rect?nextRect;

//?遠程通信用的線程
private?ExchangeThread?exchangeThread;

private?class?Gametask?extends?TimerTask?{
private?int?speed?=?5;
????????public?void?run()?{

if(!isRunning){
return?;
}

//?speed來控制時間間隔。。
???????? if(speed?<=?0){
if(gamedao.isput(curRect)){
if(gamedao.gameover())?{
System.out.println(“begin?to?end?game“);
//?先暫停游戲
isRunning?=?false;
if(exchangeThread!=null){
exchangeThread.sendMessage(“gameover“);
int?myScore?=?gamedao.score;
int?remoteScore?=?RemoteController.remoteController.getGameDao().score;

String?str?=?Integer.toString(myScore)?+?“比“?+?Integer.toString(remoteScore)?+?““;
if?(myScore?>?remoteScore)?{
//?WIN
JOptionPane.showMessageDialog(panel?str?+?“你贏了“);
}?else?if?(myScore? //?LOSE
JOptionPane.showMessageDialog(panel?str?+?“你輸了“);
}?else?{
//?pingju
JOptionPane.showMessageDialog(panel?str?+?“這是一場平局“);
}
}else{
int?myScore?=?gamedao.score;
JOptionPane.showMessageDialog(panel?“游戲結束.“+
“你的得分為:“+Integer.toString(myScore));
}
return;
}
Random?random?=?new?Random();
//?已經放下來了的意思
if(exchangeThread!=null){
exchangeThread.sendMessage(“isput“);
}
curRect.setColor(0);
int?temp=random.nextInt(7)+1;
curRect?=?new?Rect(nextRect.color);
nextRect?=?new?Rect(temp);
if(exchangeThread!=null){
//?更新rect的命令只發送下一個的
exchangeThread.sendMessage(Integer.toString(temp));
}
if(gamedao.ispop()){
//?消去一行
if(exchangeThread!=null){
exchangeThread.sendMessage(“ispop“);
}
}
????????????????}else{
curRect.down();
if(exchangeThread!=null)
exchangeThread.sendMessage(“down“);
}
//?如果沒有放下來,就down
????????????????panel.repaint();
????????????????speed=10-gamedao.level;
???????? }
???????? else{
speed--;
}
????????}
????}
public?GameController(JPanel?panel){
this.panel=(OfflinePanel)panel;
}

public?GameController(ExchangeThread?threadOnlineP

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-11-14?21:05??Project2_newTetris\
?????文件?????????301??2015-11-12?13:27??Project2_newTetris\.classpath
?????目錄???????????0??2015-11-14?21:05??Project2_newTetris\.git\
?????文件?????????110??2015-11-12?22:56??Project2_newTetris\.git\FETCH_HEAD
?????文件??????????23??2015-11-12?22:52??Project2_newTetris\.git\HEAD
?????文件?????????315??2015-11-12?22:53??Project2_newTetris\.git\config
?????文件??????????73??2015-11-12?22:52??Project2_newTetris\.git\description
?????目錄???????????0??2015-11-14?21:04??Project2_newTetris\.git\hooks\
?????文件?????????177??2015-11-12?22:52??Project2_newTetris\.git\hooks\README.sample
?????文件????????6112??2015-11-13?23:27??Project2_newTetris\.git\index
?????目錄???????????0??2015-11-14?21:04??Project2_newTetris\.git\info\
?????文件?????????113??2015-11-12?22:52??Project2_newTetris\.git\info\exclude
?????目錄???????????0??2015-11-14?21:04??Project2_newTetris\.git\logs\
?????文件?????????387??2015-11-12?22:53??Project2_newTetris\.git\logs\HEAD
?????目錄???????????0??2015-11-14?21:04??Project2_newTetris\.git\logs\refs\
?????目錄???????????0??2015-11-14?21:04??Project2_newTetris\.git\logs\refs\heads\
?????文件?????????387??2015-11-12?22:53??Project2_newTetris\.git\logs\refs\heads\master
?????目錄???????????0??2015-11-14?21:04??Project2_newTetris\.git\logs\refs\remotes\
?????目錄???????????0??2015-11-14?21:04??Project2_newTetris\.git\logs\refs\remotes\origin\
?????文件?????????144??2015-11-12?22:53??Project2_newTetris\.git\logs\refs\remotes\origin\master
?????目錄???????????0??2015-11-14?21:05??Project2_newTetris\.git\objects\
?????目錄???????????0??2015-11-14?21:04??Project2_newTetris\.git\objects\02\
?????文件????????1132??2015-11-12?22:53??Project2_newTetris\.git\objects\02\ff1ae07e2d4e6d42527890c526e296a317c03b
?????目錄???????????0??2015-11-14?21:04??Project2_newTetris\.git\objects\11\
?????文件??????????83??2015-11-12?22:53??Project2_newTetris\.git\objects\11\9591274ce4c1200bf568149028590221e4de6d
?????目錄???????????0??2015-11-14?21:04??Project2_newTetris\.git\objects\12\
?????文件????????1217??2015-11-12?22:53??Project2_newTetris\.git\objects\12\14e4cfb1a718b782a431e86415af46213f24f9
?????文件?????????813??2015-11-12?22:53??Project2_newTetris\.git\objects\12\aab59d70f648124ed1e2b22d9999ac6a5a4201
?????目錄???????????0??2015-11-14?21:04??Project2_newTetris\.git\objects\15\
?????文件?????????289??2015-11-12?22:53??Project2_newTetris\.git\objects\15\70ffec28bdba3756ea7cc11156665ffaedcf66
?????文件?????????168??2015-11-12?22:53??Project2_newTetris\.git\objects\15\b3e777204395c052ae667bb8a5ecfeddd7d2a6
............此處省略254個文件信息

評論

共有 條評論