Skip to content

armin-reichert/pacman-javafx

Repository files navigation

A JavaFX UI (2D + 3D) for Pac-Man and Ms. Pac-Man

ℹ️ Online version available

An older release of Pac-Man and Ms. Pac-Man (2D) can be played online:

This has been made possible thanks to the WebFX transpiler technology (👏 to Bruno Salmon).

Videos

About this project

This is an implementation of the classic Arcade games Pac-Man and Ms. Pac-Man in a JavaFX user interface. The game implementation is completely decoupled from the user interface such that also different user interfaces (e.g. a Swing UI) can be implemented without any change to the game code. (When developing the game, I originally maintained a Swing and a JavaFX UI in parallel to validate the UI abstraction, however the Swing UI got outdated and has been abandonded.)

There is a 2D-only user interface version and an extended version where the play scene can be switched between 2D and 3D, even during the gameplay (key combination Alt+3). The game implementation tries to mimic the original Arcade version as good as possible, however there are some differences, e.g. in the "attract mode" behaviour, or the bonus behaviour in the Ms. Pac-Man game.

How to run

In each release you find attached 3 installers.

On Windows, the application must be uninstalled first (if already installed), otherwise the installer crashes (no idea why).

The Linux (.deb) installer has only been tested on Ubuntu inside a VM, it worked after installing the FFMPeg library (see linux-issues.md).

The Mac-OS (.dmg) version has not been tested at all, any help is appreciated.

How to build

Prerequisites: You need to have JDK 21 and Git installed on your computer.

Cloning the GitHub repository

  • cd /whatever/path/to/your/repositories
  • git clone https://github.com/armin-reichert/pacman-javafx.git

Building with Gradle

  • cd pacman-javafx
  • ./gradlew jpackage

This will create installers in the subdirectories pacman-ui-fx-2d/build/jpackage and pacman-ui-fx-3d/build/jpackage.

(Note: On Windows, gradlew clean jpackage always fails because the old exe-files cannot be deleted, see gradle/gradle#26912). Manually deleting the build folder or clearing the exe-file's read-only flag helps.)

Running the application(s) using Gradle

  • Pac-Man 2D: ./gradlew pacman-ui-fx-2d:run
  • Pac-Man 3D: ./gradlew pacman-ui-fx-3d:run

Building with Maven

Building Windows installers (.exe)

  • cd /whatever/path/to/your/repositories/pacman-javafx
  • ./mvnw clean install -Pbuild-for-windows

Build 2D and 3D user interface variants separately

  • cd /whatever/path/to/your/repositories/pacman-javafx/pacman-ui-fx-2d

  • ../mvnw install -Djavafx.platform=win or mvnw install -P build-for-windows (Windows executables of 2D game)

  • cd /whatever/path/to/your/repositories/pacman-javafx/pacman-ui-fx-3d

  • ../mvnw install -Djavafx.platform=win or mvnw install -P build-for-windows (Windows executables of 2D+3D game)

To be able to create the Windows executables, you need to have the following tools installed:

as described in the JavaPackager guide (👏 to Francisco Vargas Ruiz).

I also had to add the paths "C:\Program Files (x86)\WiX Toolset v3.11\bin" and "C:\Program Files (x86)\Inno Setup 6" to my PATH variable.

Running the application(s) using Maven

In the 2D or 3D subproject folder, call ..\mvnw javafx:run.

How to use the application

Start screen:

  • V, LEFT Select next game variant
  • RIGHT Select previous game variant
  • ENTER or SPACE Start game

Intro screen:

  • 5 Adds one credit ("inserts coin")
  • 1 Starts the game
  • HShows/hides context-sensitive help

The keys 5 and 1 have been chosen because the MAME emulator uses them too.

Pac-Man steering with the keyboard:

  • Pac-Man is steered using the cursor keys. When the dashboard is open (in the 3D app version), these keys are taken away by the JavaFX widgets. In that case, you can use CTRL+cursor key.

General shortcuts:

  • F11 Enters full-screen mode
  • Esc Exits full-screen mode
  • F1 or Alt+B Toggles the dashboard on/off
  • F2 Toggles the picture-in-picture view
  • Alt+C Plays all cut scenes (only from intro screen)
  • Alt+3 Toggles between 2D and 3D play scene

Play screen shortcuts:

  • Alt+LEFT Selects the previous camera perspective
  • Alt+RIGHT Selects the next camera perspective
  • QQuits the play scene and shows the intro screen

Cheats:

  • Alt+A Toggles manual/autopilot steering modes
  • Alt+E Eats all pellets (except the energizers)
  • Alt+I Toggles immunity of player against ghost attacks
  • Alt+L Adds 3 player lives
  • Alt+N Enters next game level
  • Alt+X Kills all ghosts outside of the ghost house

How it looks

2D Play Scenes

Pac-Man Play Scene

Pac-Man Play Scene New

Ms. Pac-Man Play Scene

3D Play Scenes

Pac-Man Play Scene

Pac-Man Play Scene New

Ms. Pac-Man Play Scene

Tile map editor

Map Editor