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

Android Control WebView

How to open a website in an Android app? Google h...

Is a "space funeral" actually possible?

It is said that when a loved one dies, they will ...

You treat oyster mushrooms as vegetables, but oyster mushrooms love to eat meat

Produced by: Science Popularization China Author:...

Brand promotion: How to plan a 0-1 brand?

In recent years, many brands have suddenly become...

Shennongjia National Park: A natural wonderland at 31° north latitude

Shennongjia Park, a national AAAAA-level tourist ...

Will this internet-famous asteroid really destroy the Earth?

Recently, an asteroid numbered 2022 AP7 was notic...

Summary of 2 aspects: The right way to open user growth

The essence of user growth is to conduct precise ...

What are the top ten mistakes Jack Ma made in the past 15 years?

[[151943]] On September 19 last year, Alibaba was...

Why can scalpers always get tickets but I can’t?

Audit expert: Zheng Yuanpan, professor at Zhengzh...

Mathematics and Programming

Many people have written to me and asked me, what...