Android source code download: Five-piece elimination game

Android source code download: Five-piece elimination game

Functional classification: Leisure and puzzle

Supported platforms: Android

Operating environment: Android

Development language: Java

Development tools: Ecppse

Source code size: 5.43MB

Source code download address: http://down..com/data/1975239

Source code introduction

The source code of a popular five-piece elimination game in the past. I have studied it in the early days, and I hope that friends who are interested can study and discuss it together.

Source code running screenshot

Game Splash interface

The game starts with two teams facing each other

When the game succeeds, the score is tallied and the controls disappear

Source code snippet:

  1. //Some algorithm fragments involved in the game  
  2. /**
  3. * Breadth-first search method
  4. * @param from starting point
  5. * @param to end point
  6. * @param beads beads two-dimensional array
  7. * @return
  8. */  
  9. private   boolean isLink(Point from, final Point to, Bead[][] beads) {
  10. // Step 1: Record the points you have walked through  
  11. invalidPoints.add(from);
  12. // Step 2: Get the top, right, left and bottom points.  
  13. Point[] points = {
  14. new Point(from.x, from.y - 1 ),
  15. new Point(from.x, from.y + 1 ),
  16. new Point(from.x - 1 , from.y),
  17. new Point(from.x + 1 , from.y)
  18. };
  19. // Step 3: Determine whether the four points are valid or the destination points.  
  20. List<point> temp = new ArrayList<point>();
  21. for (Point p : points){
  22. // Have we reached the destination?  
  23. if (p.equals(to)){
  24. pathPoints.add(p);
  25. return   true ;
  26. }
  27. if (isCheck(p, beads)){
  28. temp.add(p);
  29. }
  30. }
  31. // Step 4: Determine whether all valid points are occupied.  
  32. if (temp.isEmpty()) return   false ;
  33.           
  34. // Step 5: Sort the valid points by the shortest path.  
  35. Collections.sort(temp, new Comparator<point>() {
  36. @Override  
  37. public   int compare(Point p1, Point p2) {
  38. double r1 = Math.sqrt((p1.x - to.x) * (p1.x - to.x) + (p1.y - to.y) * (p1.y - to.y));
  39. double r2 = Math.sqrt((p2.x - to.x) * (p2.x - to.x) + (p2.y - to.y) * (p2.y - to.y));
  40. return r1 < r2 ? - 1 : 0 ;
  41. }
  42. });
  43. // Step 6: Recursively find valid points and search until the destination point is reached or all valid points are searched.  
  44. for (Point p : temp){
  45. boolean flag = isLink(p, to, beads);
  46. if (flag){
  47. pathPoints.add(p);
  48. return   true ;
  49. }
  50. }
  51. return   false ;
  52. }</point></point></point>

Source code download address: http://down..com/data/1975239

<<:  iOS source code download: Draw the input words with animation

>>:  Wandoujia opens up a new way to discover personalized content

Recommend

Leeks, cut and grown again, are a favorite on Chinese tables

Written by Wei Shuihua Header image | TuChong Cre...

Volkswagen recalls some diesel models in the country due to emissions cheating

Recently, Volkswagen (China) Sales Co., Ltd. file...

Traffic acquisition methodology!

I would like to share some experience in traffic ...

How to use heap and stack in iOS

Both heap and stack are data structures where dat...

Why Arm's ban on Huawei will not have any substantial effect?

Huawei can rely on its existing ARMv8 licenses fo...

Tongxiang SEO training: How to improve website keyword ranking!

Theoretically, it is very simple to improve the k...

E-commerce operations: 50 Taobao brand marketing notes

Taobao was born in 2003. The first batch of “Taob...

For every extra hour you sit, a slim waist disappears from the world

Friends, are you sitting now? Do you know that &q...

3 tips for refined operation strategies!

As the cost of acquiring traffic gradually increa...