In Plants vs. Zombies, the plants in Zen Garden drop coins or diamonds periodically. Given an image of coin/diamond, look for the coin/diamond on the screen and click the center to collect them.
OS: Windows 7
Python: 3.6
Package: pyautogui
pip install pyautogui
- Capture a screenshot of the game using
pyautogui.screenshot()
- Manually crop the coin or diamond image and save it to a location
- Pass location of image to
pyautogui.locateOnScreen()
- Run with
python main.py
Capturing the image of coin using Window's screenshot function does not work. Must use pyautogui's screenshot() method.
- Refactor code for easier usage.
- Code forces clicks too frequently; making mouse unusable.
- Need to accommodate for different resolution window sizes.