测试代码
将界面设计完后放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方法线程
决策树的类图
数据库类图
主方法类图
主方法类图从新排序的
俄罗斯方块类图
贪吃蛇类图
设计