Skip to content

A cross-platform re-implementation of PvZ using SDL2. Aiming to bring 100% authentic experience of PvZ GOTY. (Based on Patoke and Headshotnoby's re-pvz)

License

Notifications You must be signed in to change notification settings

wszqkzqk/PvZ-Portable

Repository files navigation

PvZ-Portable

Ask DeepWiki

A cross-platform community-driven reimplementation of Plants vs. Zombies: Game of the Year Edition, aiming to bring the 100% authentic PvZ experience to every platform.

🌿 Authentic 🎮 Portable 🛠️ Open
Almost 100% gameplay recreation Run on Linux, Windows, Switch... OpenGL & SDL

License

This project is licensed under the GNU Lesser General Public License v2.1 or later (LGPL-2.1-or-later).

  • The code is provided "as is", WITHOUT WARRANTY of any kind.
  • The original game IP (Plants vs. Zombies) belongs to PopCap/EA. This license applies only to the code implementation in this repository.

⚠️ Notice:

  • This repository does NOT contain any copyrighted game assets (such as images, music, or levels) owned by PopCap Games or Electronic Arts. Users must provide their own main.pak and properties/ folder from a legally purchased copy of Plants vs. Zombies: GOTY Edition.
  • The codebase is a manual reimplementation derived from publicly available reverse-engineering documentation and community research (such as 植物大战僵尸吧, PVZ Wiki and PvZ Tools). It is written to utilize portable backends like SDL2 and OpenGL.
  • This project is intended solely for educational purposes, focusing on cross-platform porting techniques, engine modernization, and learning how classic game logic can be adapted to various hardware architectures (e.g., Nintendo Switch, 3DS).
  • Non-Commercial: This project is not affiliated with, authorized, or endorsed by PopCap Games or Electronic Arts.
  • Most of the re-implementation code of the framework is contributed by Patoke and Headshotnoby.
  • Project icons and platform-specific logos are carried over from the original fork by Headshotnoby.
  • To play the game using this project you MUST have access to the original game files by purchasing it on EA's official website or Steam.

Features

This is a fork of Patoke and Headshotnoby's PVZ GOTY implementation with the following objectives:

  • Replace renderer with SDL + OpenGL
    • Also enable to resize the window, which was not possible in the original game
  • Replace Windows code with cross-platform code
  • Replace DirectSound/BASS/FMod with SDL Mixer X
    • This project uses a fork of SDL Mixer X that adds compatibility with the MO3 format by using libopenmpt. This fork is located under SexyAppFramework/sound/SDL-Mixer-X
  • main.pak support
  • Optimize memory usage for console ports (Partial)
  • Port the game to these platforms:
Platform Data path Status
Windows (SDL2) Executable dir (resources); per-user app-data for writable files Works
Linux (SDL2) Executable dir (resources); per-user app-data for writable files Works
Haiku (SDL2) Executable dir (resources); per-user app-data for writable files Partially works: no music
Nintendo Switch sdmc:/switch/PlantsvsZombies Works on real hardware. Kenji-NX crashes on boot.
Nintendo 3DS sdmc:/3ds/PlantsvsZombies In development, might not have enough memory for Old 3DS, might barely work on New 3DS
Nintendo Wii U No work started yet, but planned

To play the game, you need the game data from PvZ GOTY. Place main.pak and the properties/ folder next to the pvz-portable executable (the game will search for resources relative to the executable's directory). You can also use extracted data instead of main.pak if you prefer.

Note about writable data and caches:

  • The game will read resources (like main.pak and properties/) from the executable directory by default, so you can launch the binary from any working directory and it will still find them.
  • Per-user writable files (settings, savegames, compiled caches, screenshots) are stored in the OS-recommended application data path. With the current build these are under io.github.wszqkzqk/PlantsVsZombies and include subfolders such as:
    • userdata/ — player save files
    • compiled/ — compiled binary caches (reanimation / compiled definitions)
    • registry.regemu — settings/registry emulation
    • popcinfo.dat — basic runtime stats
    • _screenshots/ — screenshots created by the game

Examples:

  • Linux: ~/.local/share/io.github.wszqkzqk/PlantsVsZombies/
  • Windows: %APPDATA%\io.github.wszqkzqk\PlantsVsZombies\

If you prefer to keep everything in the same folder as the executable, you can still configure a custom data directory via the -changedir command-line parameter when launching the game.

Dependencies

Before building on PC, ensure you have the necessary dependencies installed:

  • Build Tools: CMake, Ninja, A C/C++ compiler (e.g., gcc, clang, MSVC)
  • Graphics: GLEW, OpenGL
  • Audio: libopenmpt, libogg, libvorbis, mpg123
  • Image: libpng, libjpeg-turbo
  • Windowing/Input: SDL2

Arch Linux

You can install the required dependencies using the following command:

sudo pacman -S --needed base-devel cmake glew libjpeg-turbo libogg libopenmpt libpng libvorbis mpg123 ninja sdl2-compat

Windows (MSYS2 UCRT64)

You can install the required dependencies using the following command:

pacman -S --needed base-devel mingw-w64-ucrt-x86_64-cmake mingw-w64-ucrt-x86_64-gcc mingw-w64-ucrt-x86_64-glew mingw-w64-ucrt-x86_64-libjpeg-turbo mingw-w64-ucrt-x86_64-libopenmpt mingw-w64-ucrt-x86_64-libogg mingw-w64-ucrt-x86_64-libpng mingw-w64-ucrt-x86_64-libvorbis mingw-w64-ucrt-x86_64-mpg123 mingw-w64-ucrt-x86_64-ninja mingw-w64-ucrt-x86_64-SDL2

Build Instructions

Run the following commands (assuming you have CMake and other dependencies installed) where the CMakeLists.txt file is located:

cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build

Configuration Options

You can customize the game features by adding options to the first cmake command:

Option Default Description
PVZ_DEBUG ON Enable cheat keys and debug displays, etc. Can be used in any build type no matter debug or release.
LIMBO_PAGE ON Enable access to the limbo page which contains hidden levels.
DO_FIX_BUGS OFF Apply community fixes for "bugs" of official 1.2.0.1073 GOTY Edition.1 These "bugs" usually be considered as "features" by many players, though.
CONSOLE OFF* Show a console window (Windows only). *Defaults to ON if build type is Debug. (Don't be confused with PVZ_DEBUG.)

Example: Enable DO_FIX_BUGS in Release build

cmake -G Ninja -B build -DCMAKE_BUILD_TYPE=Release -DDO_FIX_BUGS=ON

If running these commands does not create a successful build please create an issue and detail your problem.

Contributing

When contributing please follow the following guides:

SexyAppFramework coding philosophy

From the SexyAppFramework docs:


The framework differs from many other APIs in that some class properties are not wrapped in accessor methods, but rather are made to be accessed directly through public member data. The window caption of your application, for example, is set by assigning a value to the std::string mTitle in the application object before the application’s window is created. We felt that in many cases this reduced the code required to implement a class. Also of note is the prefix notation used on variables: “m” denotes a class member, “the” denotes a parameter passed to a method or function, and “a” denotes a local variable.

Thanks

  • @Headshotnoby: For fully implementing the 64-bit support and OpenGL backend.
  • @Patoke: For the incredible initial reimplementation of PvZ GOTY.
  • @rspforhp: For the 0.9.9 version's work.
  • @ruslan831: For archiving the 0.9.9 version's re-implementation.
  • The SDL Team: For the amazing cross-platform development library that powers this port.
  • The GLFW Team: For their work on the windowing library used in the original re-implementation.
  • The OpenMPT Team: For libopenmpt, enabling high-quality MO3 music playback.
  • PopCap Games: For creating the amazing PvZ franchise.
  • All the contributors who have worked or are actively working in this amazing project.

Footnotes

  1. Current DO_FIX_BUGS includes the following fixes:

    • Fix bungee zombie duplicate sun/item drop in I, Zombie mode.
    • Mind-controlled Gargantuars smash enemy zombies instead of plants.
    • Mind-controlled Gargantuars throw mind-controlled Imps (with scale, health, and direction fixes).
    • Mind-controlled Gargantuars can smash vases in Scary Potter mode.
    • Mind-controlled Pea/Gatling Head zombies shoot forward instead of backward.
    • Mind-controlled Jalapeno/Squash zombies damage enemy zombies instead of plants.
    • Coordinate fixes for mind-controlled Squash zombies tracking and smashing enemy zombies.
    • Jalapeno zombies correctly clear Dr. Zomboss' skills (Iceball/Fireball) and ladder logic.
    • Sync Dancer Zombie animations (fixes "Maid" displacement bug).
    • Fix visual glitch of Ladder Zombie's arm recovery.
    • Fix Dr. Zomboss' attack (RV, Fireball/Iceball) and summon range coverage for 6-lane (Pool) levels.

About

A cross-platform re-implementation of PvZ using SDL2. Aiming to bring 100% authentic experience of PvZ GOTY. (Based on Patoke and Headshotnoby's re-pvz)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •