測試代碼
將界面設計完後放app使用示意圖於此android
嚴域俊 | 吳恆佚 | 曾程 | 劉辰 | 鄧煜坤 |
---|---|---|---|---|
3.5 | 3.5 | 3.3 | 3.6 | 3 |
日期 | 嚴域俊 | 吳恆佚 | 曾程 | 劉辰 | 鄧煜坤 |
---|---|---|---|---|---|
第2天 | 3 | 3.5 | 2.5 | 3.2 | 2.6 |
第3天 | 3.5 | 3.5 | 3.3 | 3.6 | 3 |
第4天 | 3.5 | 3.5 | 3.3 | 3.6 | 3 |
第5天 | 3.4 | 3.1 | 3.3 | 3.5 | 3.1 |
第6天 | 3.4 | 3 | 3 | 3.5 | 3.2 |
第7天 | 3.5 | 3.5 | 3.3 | 3.6 | 3 |
合計 | 20 | 21 | 19 | 21 | 19 |
public static boolean canMoveToLeft(List<BlockUnit> blockUnits, int max_x, List<BlockUnit> allBlockUnits) { for (BlockUnit blockUnit : blockUnits) { int x = blockUnit.x; if (x - UNIT_SIZE < BEGIN) { return false; } int y = blockUnit.y; if (isSameUnit(x - UNIT_SIZE, y, allBlockUnits)) { return false; } } return true; }
public static boolean canMoveToRight(List<BlockUnit> blockUnits, int max_x, List<BlockUnit> allBlockUnits) { for (BlockUnit blockUnit : blockUnits) { int x = blockUnit.x; if (x + UNIT_SIZE > max_x - UNIT_SIZE) { return false; } int y = blockUnit.y; if (isSameUnit(x + UNIT_SIZE, y, allBlockUnits)) { return false; } } return true; }
public static boolean canMoveToDown(List<BlockUnit> blockUnits, int max_y, List<BlockUnit> allBlockUnits) { for (BlockUnit blockUnit : blockUnits) { int x = blockUnit.x; int y = blockUnit.y + UNIT_SIZE * 2; if (y > max_y - UNIT_SIZE) { return false; } if (isSameUnit(x, y, allBlockUnits)) { return false; } } return true; }
以上方法均爲循環(知識點:列表)數據庫
public static boolean canRoute(List<BlockUnit> blockUnits, List<BlockUnit> allBlockUnits) { for (BlockUnit blockUnit : blockUnits) { if (isSameUnit(blockUnit.x, blockUnit.y, allBlockUnits)) { return false; } } return true; }
public static boolean canContinueGame(List<BlockUnit> allBlockUnits) { if (allBlockUnits.size() == 0) { return true; } for (BlockUnit blockUnit : allBlockUnits) { if (blockUnit.y <= BlockUnit.BEGIN) { return false; } } return true; }
public static boolean toLeft(List<BlockUnit> blockUnits, int max_x, List<BlockUnit> allBlockUnits) { if (canMoveToLeft(blockUnits, max_x, allBlockUnits)) { for (BlockUnit blockUnit : blockUnits) { blockUnit.x = blockUnit.x - UNIT_SIZE; } return true; } return false; }
public static boolean toRight(List<BlockUnit> blockUnits, int max_x, List<BlockUnit> allBlockUnits) { if (canMoveToRight(blockUnits, max_x, allBlockUnits)) { for (BlockUnit blockUnit : blockUnits) { blockUnit.x = blockUnit.x + UNIT_SIZE; } return true; } return false; }
public static void toDown(List<BlockUnit> blockUnits, int max_Y, List<BlockUnit> allBlockUnits) { for (BlockUnit blockUnit : blockUnits) { blockUnit.y = blockUnit.y + BlockUnit.UNIT_SIZE; } }
public static boolean isSameUnit(int x, int y, List<BlockUnit> allBlockUnits) { for (BlockUnit blockUnit : allBlockUnits) { if (Math.abs(x - blockUnit.x) < UNIT_SIZE && Math.abs(y - blockUnit.y) < UNIT_SIZE) { return true; } } return false; }
public static void remove(List<BlockUnit> allBlockUnits, int j) { for (int i = allBlockUnits.size() - 1; i >= 0; i--) { if ((int) ((allBlockUnits.get(i).y - BEGIN) / 50) == j) allBlockUnits.remove(i); } }
GameConfit(遊戲佈局)
把速度設計爲400數組
NextBlockView(定義了下一個方塊的構建)
調用android.Content.Context網絡
android.Content.Context | 知識點 |
---|---|
android.graphics.Canvas | 背景 |
android.graphics.Color | 顏色 |
android.graphics.Paint | 繪畫 |
android.graphics.RectF | 網格 |
利用的知識點是數組列表app
NextBlockView(其構造方法):佈局
FetrisActivityAW(俄羅斯方塊主程序)
調用:1. NextBlockView
2. TetrisViewAW
StartGame:調用T·etrisViewAW中的同名方法
PauseGame:調用T·etrisViewAW中的同名方法
ContinueGame:調用T·etrisViewAW中的同名方法
StopGame:調用T·etrisViewAW中的同名方法,並將得分設置爲0
to Left、to Right、to Route、on Destroy:前三個方法調用調用T·etrisViewAW中的同名方法,最後一個調用調用T·etrisViewAW中的stopGame方法測試
TetrisViewAw(定義基本參數和運動方法)
變量:beginpoint=10(網格開始值與橫座標開始值)
Max_x、Max_y:俄羅斯方塊的最大座標
num_x=0,num_y=0:行數和列數
paintWall:背景畫筆 使用的Paint
paintBlock:單元塊畫筆 使用的Paintspa
FetrisActivityAW(俄羅斯方塊主程序)
調用:1. NextBlockView
2. TetrisViewAW
StartGame:調用T·etrisViewAW中的同名方法
PauseGame:調用T·etrisViewAW中的同名方法
ContinueGame:調用T·etrisViewAW中的同名方法
StopGame:調用T·etrisViewAW中的同名方法,並將得分設置爲0
to Left、to Right、to Route、on Destroy:前三個方法調用調用T·etrisViewAW中的同名方法,最後一個調用調用T·etrisViewAW中的stopGame方法線程
決策樹的類圖
數據庫類圖
主方法類圖
主方法類圖從新排序的
俄羅斯方塊類圖
貪吃蛇類圖
設計