dnartz / PvZ-Emulator

Plants vs. Zombies survival endless emulator.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PvZ-Emulator

Plants vs. Zombies Survival Endless emulator.

This emulator can emulate all kinds of plants and zombies except Dr. Zomboss and Zombie Bobsled Team (They don't occur in Survival Endless). It supports all 6 scenes (Day, Night, Pool, Fog, Roof, and Moon Night).

Install

To build the Python module with CMake, add flags -DPVZEMU_BUILD_PYBIND=True -DPYBIND11_PYTHON_VERSION=3.8 to your CMake build command.

You can install through pip as well:

python -m pip install git+https://github.com/dnartz/PvZ-Emulator

Usage

This emulator can be used as a static library or a python module. Include pvz-emulator/world.h before to your source code. All functions and methods are thread-safe.

Create and Update a Game Instance

int main(void) {
    pvz_emulator::world w(pvz_emulator::object::scene_type::pool);

    // The first wave of zombies will spawn after 6 seconds.
    for (int i = 0; i < 600; i++) {
        w.update();
    }

    return 0;
}
from pvzemu import World, SceneType

w = World(SceneType.pool)
for i in range(0, 600):
    w.update()

Control Flags

You can set some bool flags in the scene objects to enable or disable some easter eggs and bugs that affect motions of objects.

  • is_zombie_dance Enable the "dance" effect if set to true.
  • is_future_enalbed Enable the "future" effect if set to true.
  • stop_spawn Stop spawning zombies if set to true.
  • enable_split_pea_bug Enable the "future" effect if set to true.

Debugging

I wrote a simple web debugger to visualize the game state. To compile the debugger, you need to install node.js and extract some images from main.pak in the game installation directory.

After unpacked main.pak, copy these files to debugger/src/assets:

$ cd images
$ cp background1.jpg PATH_TO_THE_SOURCE_CODE/debugger/src/assets/day.jpg
$ cp background2.jpg PATH_TO_THE_SOURCE_CODE/debugger/src/assets/night.jpg
$ cp background3.jpg PATH_TO_THE_SOURCE_CODE/debugger/src/assets/pool.jpg
$ cp background4.jpg PATH_TO_THE_SOURCE_CODE/debugger/src/assets/fog.jpg
$ cp background5.jpg PATH_TO_THE_SOURCE_CODE/debugger/src/assets/roof.jpg
$ cp background6.jpg PATH_TO_THE_SOURCE_CODE/debugger/src/assets/moon_night.jpg

Then you can build the debug server:

$ cmake PATH_TO_THE_SOURCE_CODE -DPVZEMU_BUILD_DEBUGGER=True
$ make

Run the debug server:

$ ./debug-server PATH_TO_THE_SOURCE_CODE/debugger/dist

Now you can Open http://localhost:3000 on your browser.

About

Plants vs. Zombies survival endless emulator.

License:Other


Languages

Language:C++ 84.3%Language:Python 11.4%Language:CMake 2.1%Language:TypeScript 1.0%Language:C 1.0%Language:Shell 0.1%Language:JavaScript 0.0%Language:HTML 0.0%Language:CSS 0.0%