How programmers play mobile games, go play now~

How programmers play mobile games, go play now~

Since the update of WeChat latest version 6.6.1 a few days ago, the WeChat mini-program game "Jump Jump" seems to have become popular in the circle of friends overnight.

[[216189]]

It is even more popular than the airplane war game five or six years ago. The popularity of this kind of game is not only because it is magical and interesting, but more importantly, it allows you to PK with your friends!

[[216190]]

After the launch of the "Jump Jump" mini-game, the beautiful vision of many students who were preparing to work hard for progress had their holiday plans ruined.

In order to jump a few more steps and rank higher in the circle of friends,

This is what everyone did during the holiday:

[[216191]]

Just jump and jump like this...

Jump on the subway, jump on the toilet, jump in the elevator,

Every second of silence cannot be wasted

[[216192]]

In the office, you should always be alert to the people behind you...

[[216193]]

Where's the work I agreed to do? I can't control myself!

[[216194]]

But many people spent a whole afternoon dancing

No more than 100 points

But three quarters of the people on the list have exceeded three digits...

It really hurts...

Today, I will tell you how to get high scores and how to top the list of friends circle?

Game strategy to get high scores

The normal version of the high score cheats is as follows:

  • If you can pick the middle of each one every time, you can get +2 points. If you jump to the middle continuously, you will get +4, +6, +8, +10...
  • Jump onto the manhole cover, stay there for 2 seconds, and wait until the sewer sound is heard to get +5 points
  • Jump onto the Rubik's Cube, stay there for 2 seconds, and wait until the Rubik's Cube turns right to get +10 points
  • Jump onto the music box, stay there for 2 seconds, and wait until the music starts to play to get +30 points.
  • Jump to the convenience store, stay there for 2 seconds, and wait until the convenience store opens to directly increase 15 points

[[216195]]

The above is for ordinary users, but for us programmers, this set is too low. Next, we will talk about how to achieve high scores from a technical level:

Technical means to achieve high scores

By Python

Someone has already used Python to play the game Jump Jump on Github, and you can get as many points as you want.

GitHub address: https://github.com/wangshub/wechat_jump_game

step:

  1. On Android phones, turn on USB debugging, go to Settings>Developer Options>USB Debugging.
  2. Connect the computer to the phone via USB cable and make sure that the device ID can be found by executing adb devices.
  3. Switch to the WeChat Jump Game interface and click to start the game.
  4. Run python wechat_junp_auto.py. If the phone interface displays USB authorization, please click Confirm.
  5. Very interesting! To put it simply: use your computer to help you play WeChat, fully automatic, no manual work required.
  6. Here is a slightly more complete set of steps, taking Mac as an example. The idea for Win is the same.

In addition, an Android phone is used here, and iOS is similar, but you need to download a 5.5GB Xcode.

1. Download the program, open the link below, click clone or download on the right, and then click download zip.

2. Unzip the zip file, move the folder to the desktop, and open the folder. You will see a lot of stuff:

3. Open the "Terminal" that comes with the Mac system. This is a command line application. You can just use cmd for win.

[[216196]]

4. Enter the folder through the terminal. The command line is as follows:

  1. ~/Decktop/wechat_jump_game-master

5. Install pip. Enter sudo easy_install pip in the terminal and press Enter. You may need to enter a password.

6. Install various dependent programs. Enter pip install -r requirements.txt in the terminal and press Enter. The system will automatically install it.

requirements.txt is a txt document in the folder, which tells which programs will be automatically installed.

pip is the program installed in step 5. If it is not installed, pip install -r requirements.txt will not work.

7. Install adb and open the link below to view. There are 3 methods. It is recommended to use the second one, which is in English. If you don’t understand English, you can Baidu Chinese tutorial.

https://stackoverflow.com/questions/31374085/installing-adb-on-mac-os-x

8. Open the Android phone's Settings - Developer Options - USB Debugging (if there is no developer option, you can Baidu to open the developer option method), connect the phone and computer with a USB cable, the phone may pop up a dialog box, click Agree.

If the little man does not jump after running the script, please check whether "USB debugging (safe mode)" is turned on, and remember to turn on USB simulated click.

9. Enter adb devices in the terminal. If you see the following information, it means that adb has been installed correctly and the computer has successfully detected the phone.

If your system is Win10 or Win8, you may need to set "Disable mandatory driver signature" first.

Otherwise, the following problem will occur: "The hash value of the file is not in the specified directory" and the adb driver cannot be installed. There are tutorials online, please study them by yourself.

10. Open WeChat and click Start. Enter python wechat_jump_auto.py in the terminal and press Enter. The game will start automatically. Please run the corresponding *.py file according to the resolution of your phone.

Notice:

I jumped many times, but the box would fall off every time. For now, I can only jump to 1800+ points at most, and I can't keep jumping.

Different resolutions require different configuration files, please refer to the config folder for details.

Don’t score too high. Some people scored as high as 4,000, but their scores were reset to zero by WeChat.

Experimental results:

[[216197]]

As long as you have patience, you are the king

[[216198]]

Let's analyze the code. The Main part has a While loop, which will repeat the operation as long as you don't terminate it.

There are three main custom functions called in the Main code, and a time.sleep is used for delay:

  • pull_screenshot() #Get the image
  • find_piece_and_board(im) #Get the coordinates of two points based on the image
  • jump(math.sqrt((board_x – piece_x) ** 2 + (board_y – piece_y) ** 2))#Calculate the pressing time and JUMP based on the distance between the two points and the phone pixels

pull_screenshot()

This function mainly uses adb to obtain images. By the way, "adb" is the bridge connecting Android phones and PCs, allowing users to perform comprehensive operations on their phones on the computer.

With the help of adb tools, we can manage devices, install software, upgrade the system, run Shell commands, and so on. For example, "pull" is to get the files in the device. If you want to know more about ADB, please learn it yourself~

find_piece_and_board()

Get the coordinate system of the current position and landing point of the character according to the image (piece_x, piece_y, board_x, board_y). This is the core part of this script.

jump

The required pressing time is calculated according to the set "long press time coefficient". This coefficient is derived based on the resolution of the mobile phone. The pressing time is set to no less than 200ms. The core command is adb's "input swipe".

"Input swipe" simulates the sliding event of a finger on the screen. If the coordinates of the two points do not change, it becomes a long press.

The settings of the four variables in the code are: "swipe_x1, swipe_y1, swipe_x2, swipe_y2 = 320, 410, 320, 410", so it is a simulated long press, but sliding is also possible.

Forged POST request to cheat

In addition to using Python to achieve high scores, some netizens have revealed that it is also possible to directly forge POST requests to brush scores and directly change scores.

Recently, an article titled "WeChat Jump can directly change the score, the POST request is not verified..." on the V2EX website has received a lot of exposure. The post pointed out that there is a loophole in the WeChat applet, and the Jump game can directly change the score.

Following the instructions in the post, user Zhu Pengfei discovered that even the source code of WeChat applets and mini-games can be downloaded directly. All he needs to do is to know the appid and version number, and then he can directly construct a URL to download the source code package with the suffix wxapkg, without any verification.

According to the WeChat official account "Small Column Platform", as of 23:50 on January 1, WeChat has officially fixed this vulnerability. However, it is said that some older versions of WeChat can still capture packets and obtain packet addresses.

[[216200]]

***The bug has been fixed in WeChat (some versions have not been fixed), but as long as you make good use of the previous two strategies and control the rhythm, it will be no problem to be in the top few in the circle of friends.

Without further ado, let’s go play!!!

<<:  Celebrities aren’t the only ones who get doxed. Learn these tips to protect your online privacy

>>:  Offline payment war among giants: WeChat's offensive is fierce, while Alipay survives in adversity

Recommend

Why doesn't the iPhone 7 Plus telephoto lens work in low light?

This year's dual-camera upgrade to the iPhone ...

During product iteration, how to use data to drive user growth?

In product iteration aimed at user growth , "...

Using pointers in Swift

Apple hopes to minimize the appearance of pointer...

Pico 1 mobile headset: Will you buy the 399 yuan VR ticket?

More than half a month ago, VR newcomer Pico rele...

How to optimize conversion rate through channel conversion model?

Advertising guru John Wanamaker once said, "...

Long March 5B is ready!

On July 18, the Wentian Experimental Module and t...

Tractica: Autonomous driving industry revenue will reach $35 billion in 2022

199IT original compilation Interest in autonomous...