| 1 | # pacman.c |
| 2 | |
| 3 | A Pacman clone written in C99 with minimal dependencies for Windows, macOS, Linux and WASM. |
| 4 | |
| 5 | [WASM version](https://floooh.github.io/pacman.c/pacman.html) |
| 6 | |
| 7 | For implementation details see comments in the pacman.c source file (I've tried |
| 8 | to structure the source code so that it can be read from top to bottom). |
| 9 | |
| 10 | Related projects: |
| 11 | |
| 12 | - Zig version: https://github.com/floooh/pacman.zig |
| 13 | |
| 14 | ## Clone, Build and Run (Linux, macOS, Windows) |
| 15 | |
| 16 | On the command line: |
| 17 | |
| 18 | ``` |
| 19 | git clone https://github.com/floooh/pacman.c |
| 20 | cd pacman.c |
| 21 | mkdir build |
| 22 | cd build |
| 23 | cmake .. |
| 24 | cmake --build . |
| 25 | ``` |
| 26 | |
| 27 | > NOTE: on Linux you'll need to install the OpenGL, X11 and ALSA development packages (e.g. mesa-common-dev, libx11-dev and libasound2-dev). |
| 28 | |
| 29 | On Mac and Linux this will create an executable called 'pacman' |
| 30 | in the build directory: |
| 31 | |
| 32 | ``` |
| 33 | ./pacman |
| 34 | ``` |
| 35 | |
| 36 | On Windows, the executable is in a subdirectory: |
| 37 | |
| 38 | ``` |
| 39 | Debug/pacman.exe |
| 40 | ``` |
| 41 | |
| 42 | ## Build and Run WASM/HTML version via Emscripten |
| 43 | |
| 44 | > NOTE: You'll run into various problems running the Emscripten SDK tools on Windows, might be better to run this stuff in WSL. |
| 45 | |
| 46 | Setup the emscripten SDK as described here: |
| 47 | |
| 48 | https://emscripten.org/docs/getting_started/downloads.html#installation-instructions |
| 49 | |
| 50 | Don't forget to run ```source ./emsdk_env.sh``` after activating the SDK. |
| 51 | |
| 52 | And then in the pacman.c directory: |
| 53 | |
| 54 | ``` |
| 55 | mkdir build |
| 56 | cd build |
| 57 | emcmake cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=MinSizeRel .. |
| 58 | cmake --build . |
| 59 | ``` |
| 60 | |
| 61 | To run the compilation result in the system web browser: |
| 62 | |
| 63 | ``` |
| 64 | > emrun pacman.html |
| 65 | ``` |
| 66 | |
| 67 | ## IDE Support |
| 68 | |
| 69 | On Windows with Visual Studio cmake will automatically create a **Visual Studio** solution file which can be opened with ```cmake --open .```: |
| 70 | ``` |
| 71 | cd build |
| 72 | cmake .. |
| 73 | cmake --open . |
| 74 | ``` |
| 75 | |
| 76 | On macOS, the cmake **Xcode** generator can be used to create an |
| 77 | Xcode project which can be opened with ```cmake --open .``` |
| 78 | ``` |
| 79 | cd build |
| 80 | cmake -GXcode .. |
| 81 | cmake --open . |
| 82 | ``` |
| 83 | |
| 84 | On all platforms with **Visual Studio Code** and the Microsoft C/C++ and |
| 85 | CMake Tools extensions, simply open VSCode in the root directory of the |
| 86 | project. The CMake Tools extension will detect the CMakeLists.txt file and |
| 87 | take over from there: |
| 88 | ``` |
| 89 | cd pacman.c |
| 90 | code . |
| 91 | ``` |