Plants vs. Zombies open a plug-in, it is more fun to make one yourself

An unknown college student, called Caigou by people in the Jianghu
original author: Jacky Li
Email : [email protected]

Time of completion:2023.8.6
Last edited: 2023.8.6

Guide: The open source project shared with you today can be said to be very suitable for getting started, it is more fun, and it is a project with a story. It can not only satisfy readers who want to learn, but also satisfy those readers who like gossip.

eb2b617036c84123bfa1dbf35eb44c21.jpeg

 

Table of contents

Project compilation environment

how to play

project run

functional aspects

Demo:

The author has something to say


 

 

549ea09eabc5efa08bebc8d855785052.jpeg

Briefly introduce this Plants vs. Zombies game developed in Python language.

A simple Plants vs Zombies game.
It's only for personal learning and noncommercial use. If this game infringes the copyright, please let me know.

  • Tool Plants: Sunflowers, Pea Shooters, Walnuts, Snow Pea Shooters, Cherry Bombs, Three Bean Shooters, Chopped Vegetables, Puffs, Potatoes, Spike Grass, Fright Grass, Pumpkin, Fright Grass, Jalapenos, Sun Mushrooms, Ice Mushrooms, Hypnotic Mushrooms.
  • Implement Zombies: Zombie, Banner Zombie, Cone Head Zombie, Barrel Head Zombie, Newspaper Zombie.
  • Use JSON files to store level data (e.g. zombie location and time, background info)
  • Support for selecting plant cards at the start of a level
  • Support day level, night level, mobile card selection level and walnut bowling level

Project compilation environment

For Python3.7 and above, you can download and install it directly from the python official website; you also need to rely on the pygame module, and you can install it by executing pip3 install pygame. The environment construction is still very simple, and even a rookie like a blogger who has never written Python can get it done in minutes.

  • python 3.7
  • Note: python version 3.7 is recommended, but not required. For LINUX: If your Linux system comes with python 3+ pre-installed, then it is possible to run this game. Updating directly to python 3.7 may break LINUX Mint.
  • Python-Pygame 1.9

how to play

  • Use the mouse to collect sun, select plant cards and sow plants
  • You can set the starting level by changing the START_LEVEL_NUM value in source/constants.py
    • Levels 1 and 2: Day Level
    • Level 3: Night
    • Level 4: Mobile Card Selection Level
    • Level 5: Walnut Bowling Level

project run

Download the source code locally (it is strongly recommended that you use the Downloade mode, git clone is very painful), and execute the python main.py command in the project root directory to run it.

23f2a84a6bbd64f6bc6d9ac025f29ff1.png

 

functional aspects

Currently supported plant types: sunflowers, pea shooters, ice shooters, nuts, cherry bombs, double pea shooters, etc.; supported zombie types: ordinary zombies, chess piece zombies, roadblock zombies, iron barrel zombies, and poison bomb zombies. The project uses Json The file saves the level information, and the time and location of the zombies can be independently set.

 

676c7fab2e7360fe8a8b66d5c2904fe4.png

In short, it is very suitable for beginners to learn!

Demo:

24df407bf03ea194858985ea76ded28b.jpeg

 

17ad600610aac6638a0c126d78d63629.jpeg

 

The author has something to say

If you need the code, please chat with the blogger privately, and the blogger will see back.
If you feel that what the blogger said is useful to you, please click to support it, and will continue to update such issues...

 

 

 

Guess you like

Origin blog.csdn.net/weixin_62075168/article/details/132133855