資源簡介
自己用Java 寫的俄羅斯方塊程序。供大家批評指正。

代碼片段和文件信息
//本類是方塊類的基類,包含所有方塊共有的方法
?class?Block?{
?int?temp?[][]?=?new?int?[4][2]?;
?int?current_Type_ID?;??????????//存儲當前方塊樣式
?int?current_Block_Type?[][]?;??//存儲當前迷宮樣式數據的二維數組
?int?current_Rotate_State????;??//存儲當前的旋轉狀態
?int?current_Block_Position?[][]?;?//存儲當前方塊的位置
?int?rotate_Data?[][][]??????;??//存儲不同旋轉狀態下的坐標
?int?rotate_State_Count? ?;??//記錄方塊旋轉狀態的個數
?
?int?offset_Row =?-1 ?; //存儲行上的偏移量
?int?offset_Column?=?1 ?; //存儲列上的偏移量?
?Game?game ?;??
?//方塊旋轉?
?void?rotate(??)
{
?switch(?current_Type_ID?)
?{
? case?0?:
?
? current_Rotate_State?=??(?current_Rotate_State?+?1?)?%?2?;
?
? current_Block_Type?=?BlocksFactory.rotate_data_0[current_Rotate_State?].clone()?;
? break?;
?
? case?2?:
? current_Rotate_State?=??(?current_Rotate_State?+?1?)?%?4?;
?
? current_Block_Type?=?BlocksFactory.rotate_data_2[current_Rotate_State?].clone()?;
?
? break?;
?
? case?3?:
?
? current_Rotate_State?=??(?current_Rotate_State?+?1?)?%?2?;
?
? current_Block_Type?=?BlocksFactory.rotate_data_3[current_Rotate_State?].clone()?; ?
?
? break?;
?
? case?4?:
?
? current_Rotate_State?=??(?current_Rotate_State?+?1?)?%?2?;
?
? current_Block_Type?=?BlocksFactory.rotate_data_4[current_Rotate_State?].clone()?; ?
?
? break?;
?
? case?5?:
?
? current_Rotate_State?=??(?current_Rotate_State?+?1?)?%?4?;
?
? current_Block_Type?=?BlocksFactory.rotate_data_5[current_Rotate_State?].clone()?; ?
?
? break?;
?
? case?6?:
?
? current_Rotate_State?=??(?current_Rotate_State?+?1?)?%?4?;
?
? current_Block_Type?=?BlocksFactory.rotate_data_6[current_Rotate_State?].clone()?;
?
? break?;
?
?}
?
}
//方塊向左移動
void??move_Left(?)
{
if?(??game.collisionDetecor(Game.direction.left)?)
{
offset_Column?--?;
}
}
//方塊向右移動
void?move_Right()
{
if?(??game.collisionDetecor(Game.direction.right)?)
{
offset_Column?++?;
}
}
//方塊向下移動
void?move_down()
{
if?(??game.collisionDetecor(Game.direction.down)?)
{
offset_Row?++?;
}
}
int[][]?getCurrentPosition()
{
for?(?int?i?=?0?;?i?4?;?i?++)
{
current_Block_Position??[?i?][?0?]?=??current_Block_Type?[?i?]?[?0?]?+?offset_Row?;
current_Block_Position??[?i?][?1?]?=??current_Block_Type?[?i?]?[?1?]?+?offset_Column?;?
}
return?current_Block_Position?;
}
??????
public?Block(?int?id??Game?game?)
{
current_Rotate_State??=?0? ;
current_Block_Position?=?new?int?[?4?][?2?]? ;
current_Type_ID?=?id? ;
current_Block_Type?=?(int?[][])?BlocksFactory.block_Type[id].clone();??//克隆block_Type中的數據
this.game?=?game? ;
//構造當前方塊的旋轉狀態數組
switch?(?current_Type_ID?)
{
case?0?:
rotate_Data?=?BlocksFactory.rotate_data_0?;
rotate_State_Count?=?2? ;
break?;
case?2?:
rotate_Data?=?BlocksFactor
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2011-10-14?23:55??俄羅斯方塊\
?????目錄???????????0??2011-10-14?22:59??俄羅斯方塊\Tetris\
?????文件?????????232??2011-10-09?21:26??俄羅斯方塊\Tetris\.classpath
?????文件?????????568??2011-10-14?22:38??俄羅斯方塊\Tetris\.project
?????文件???????47364??2011-10-14?16:35??俄羅斯方塊\Tetris\back.jpg
?????目錄???????????0??2011-10-14?22:59??俄羅斯方塊\Tetris\bin\
?????文件???????47364??2011-10-14?16:35??俄羅斯方塊\Tetris\bin\back.jpg
?????文件????????2246??2011-10-14?22:20??俄羅斯方塊\Tetris\bin\Block.class
?????文件????????2583??2011-10-14?22:10??俄羅斯方塊\Tetris\bin\BlocksFactory.class
?????文件????????1015??2011-10-14?22:19??俄羅斯方塊\Tetris\bin\Game$direction.class
?????文件????????3147??2011-10-14?22:19??俄羅斯方塊\Tetris\bin\Game$GameMonitor.class
?????文件????????1015??2011-10-14?22:19??俄羅斯方塊\Tetris\bin\Game$gameState.class
?????文件?????????510??2011-10-14?22:19??俄羅斯方塊\Tetris\bin\Game$GameTimer.class
?????文件????????7471??2011-10-14?22:19??俄羅斯方塊\Tetris\bin\Game.class
?????文件????????1799??2011-10-14?22:22??俄羅斯方塊\Tetris\bin\GameCanvas.class
?????文件????????2440??2011-10-14?17:30??俄羅斯方塊\Tetris\bin\Tetris$fr
?????文件????????3336??2011-10-14?17:30??俄羅斯方塊\Tetris\bin\Tetris.class
?????目錄???????????0??2011-10-14?22:59??俄羅斯方塊\Tetris\src\
?????文件???????47364??2011-10-14?16:35??俄羅斯方塊\Tetris\src\back.jpg
?????文件????????3661??2011-10-14?22:20??俄羅斯方塊\Tetris\src\Block.java
?????文件????????2541??2011-10-14?22:10??俄羅斯方塊\Tetris\src\BlocksFactory.java
?????文件???????15466??2011-10-14?22:19??俄羅斯方塊\Tetris\src\Game.java
?????文件????????2922??2011-10-14?22:22??俄羅斯方塊\Tetris\src\GameCanvas.java
?????文件????????6477??2011-10-14?17:30??俄羅斯方塊\Tetris\src\Tetris.java
?????文件???????54723??2011-10-14?22:40??俄羅斯方塊\俄羅斯方塊.jar
?????文件?????????119??2011-10-14?23:58??俄羅斯方塊\游戲操作說明.txt
?????目錄???????????0??2011-10-14?23:00??俄羅斯方塊\源代碼\
?????文件???????47364??2011-10-14?16:35??俄羅斯方塊\源代碼\back.jpg
?????文件????????3661??2011-10-14?22:20??俄羅斯方塊\源代碼\Block.java
?????文件????????2541??2011-10-14?22:10??俄羅斯方塊\源代碼\BlocksFactory.java
?????文件???????15466??2011-10-14?22:19??俄羅斯方塊\源代碼\Game.java
............此處省略2個文件信息
評論
共有 條評論