## I. GENERAL OVERVIEW team
team member | The division of tasks |
Zang Qi Vietnam (Leader) 201821123025 |
GUI design, programming interface, blog writing (Tuixiangzi.view bag, tuixiangzi.util package) |
Han Jiaxin 201821123024 |
Arithmetic logic functions, regret step function, restart function realization, bgm and timing Add (Tuixiangzi.model package) |
Lingui Long 201821123012 |
Map parameter settings, drawing, material collection (Tuixiangzi.model.goods bag, tuixiangzi.model.map package) |
## two Project git address:. The this the this !!!
III. Project git commit record
IV. Preliminary investigation
We are looking for Sokoban games in 4399, found that roughly follows function
So we want to achieve the basic functions are:
1. To achieve the function keyboard, arrow keys
2. clearance judge whether the game functions
3. Support off function is selected, may be selected from 1 to 50 Off
4. Add the game background music
5. Supports "undo" function, that is, go back and start again and function
Fives.
1. Item Function Chart
2. The main functional flowchart
Six. UML class diagram
VII. Run shot
Main interface:
Clearance reached:
Overall operating results:
VIII. The key codes
Step regret Code:
public void previousMove() { if(moveStack.isEmpty()){ return; } GameMove previous=moveStack.pollLast(); if(previous!=null) { boy.reset(previous.boyX,previous.boyY,previous.boyDirection); if(previous.moveBox!=null) { Box b=previous.moveBox; b.moveTo(previous.boxX, previous.boxY); GameMapCell homeCell=map.get(b.x, b.y); if(homeCell.type==GameMapCell.TYPE_HOME) { b.setWin(); } } }else { this.setLevel(this.level); } }
人物及箱子移动代码(以向左移动为例)
private void handleLeft() { int bx = boy.x, by = boy.y; // 获取boy前面类型 GameMapCell cell = map.get(bx-1, by); if (cell == null) { return; } switch (cell.type) { case GameMapCell.TYPE_BLOCK: // 障碍物,不能移动 return; case GameMapCell.TYPE_GRASS: case GameMapCell.TYPE_HOME: // 草地和目标位置上是否有箱子 Box box = getBoxAt(cell.x, cell.y); if (box == null) { // 没有,则boy移动 boy.moveLeft(); moveStack.add(GameMove.of(boy)); } else { // 有,判断盒子前面有什么 if (canBoxMoveIn(box.x-1, box.y)) { box.moveLeft(); boy.moveLeft(); moveStack.add(GameMove.of(boy,box)); } } break; } }
九. 扫描结果及改正
扫描结果:
改正结果:
十. 总结
不足:
悔一步功能只能够返回未到达目标的箱子,如若箱子已变成“win”状态,则不会再返回上一步(游戏难度降低):
界面编程仅用eclipse实现,界面些许简陋
展望:
尝试推箱子暴力破解
尝试NetBeans或JavaFx编程界面