GithubHelp home page GithubHelp logo

pacman.c's Introduction

pacman.c

A Pacman clone written in C99 with minimal dependencies for Windows, macOS, Linux and WASM.

WASM version

For implementation details see comments in the pacman.c source file (I've tried to structure the source code so that it can be read from top to bottom).

Related projects:

Clone, Build and Run (Linux, macOS, Windows)

On the command line:

git clone https://github.com/floooh/pacman.c
cd pacman.c
mkdir build
cd build
cmake ..
cmake --build .

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).

On Mac and Linux this will create an executable called 'pacman' in the build directory:

./pacman

On Windows, the executable is in a subdirectory:

Debug/pacman.exe

Build and Run WASM/HTML version via Emscripten

NOTE: You'll run into various problems running the Emscripten SDK tools on Windows, might be better to run this stuff in WSL.

Setup the emscripten SDK as described here:

https://emscripten.org/docs/getting_started/downloads.html#installation-instructions

Don't forget to run source ./emsdk_env.sh after activating the SDK.

And then in the pacman.c directory:

mkdir build
cd build
emcmake cmake -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=MinSizeRel ..
cmake --build .

To run the compilation result in the system web browser:

> emrun pacman.html

IDE Support

On Windows with Visual Studio cmake will automatically create a Visual Studio solution file which can be opened with cmake --open .:

cd build
cmake ..
cmake --open .

On macOS, the cmake Xcode generator can be used to create an Xcode project which can be opened with cmake --open .

cd build
cmake -GXcode ..
cmake --open .

On all platforms with Visual Studio Code and the Microsoft C/C++ and CMake Tools extensions, simply open VSCode in the root directory of the project. The CMake Tools extension will detect the CMakeLists.txt file and take over from there:

cd pacman.c
code .

pacman.c's People

Contributors

floooh avatar mikedx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pacman.c's Issues

Pacman animation speed too slow

Comparing the animation speed in pacman.c seems to differ to the original by about 50%.

I propose the fix for this to check for the ticks to be increased from /4 to /2 in spr_anim_pacman around line 1139 from

 uint32_t phase = (tick / 4) & 3;

to

 uint32_t phase = (tick / 2) & 3;

This appears to be much closer to the original.

Happy to submit a PR if you wish :)

Instructions for Linux lack something

I also needed libasound2-dev.

Also what's the difference between ( cd build ; cmake .. ) and cmake --build . ? One seems superflous.

Otherwise, very nice :) 👍

Doesn't render if compiled with GCC-13

Hi, any thoughts why this doesn't work with GCC-13 (current stable GCC release)?
It builds fine, and when running it the window appears, but no visuals ever render, and no input is ever accepted.
I noticed the problem after both updating my laptop to Ubuntu 23.10, and also updating my Windows PC's msys2.
Instructing cmake to use GCC-12 instead on the laptop solves the issue. (Haven't tried the same on Windows.)

Slightly concerned about the copyright issues

This project is amazing, I am planing to use it as an education tool for students in my AI classes.

However, this project seems to be using some copyrighted data, i.e., the rom data dump for the arcade machine.

This may be a bit problematic. I am working to change the sound tracks and sprites a bit.

Keyboard control not accurate

I only tried the WASM version, not sure if the issue also exists in the desktop version: When I press a key, e. g. DOWN, before Pac-Man reaches a tile where he can move DOWN, then this should be remembered and he should move DOWN as soon as he reaches that tile. This is an essential behavior of the game.

Eaten ghosts are not transparent

Once a ghost is eaten, it returns to home but instead of being fully transparent, the ghosts wear a "black" suit, covering any tiles over as they pass (most noticeably the dots).

There are a couple of ways of fixing this.

The obvious one is to check for ARGB 0XFF000000 in the gfx_decode_color_palette function around line 2806 or to check for r+g+b==0 around line 2798 and set to 0x0 if true.

Happy to submit a PR for this, depending upon which approach you wish to take.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.