A fully playable Pac-Man game built as a Lightning Web Component (LWC), packaged as a Salesforce DX Unlocked Package.
Play classic Pac-Man right inside Salesforce! Eat dots, dodge ghosts (or eat them with power pellets!), and save your high score to a custom object.
| Component | Type | Description |
|---|---|---|
pacman |
LWC | The full game — canvas-based Pac-Man with ghosts, scoring, pause, and name entry |
PacmanScoreController |
Apex Class | Saves scores to Salesforce via @AuraEnabled |
PacmanScoreControllerTest |
Apex Test | 100% code coverage test class |
PacmanScore__c |
Custom Object | Stores player name + final score |
pacman (tab) |
Custom Tab | Lightning tab for the game LWC |
PacmanScore__c (tab) |
Custom Tab | Lightning tab for the Scores object |
Pacman |
Lightning App | App with both tabs |
- Arrow Keys — Move Pac-Man
- P key or Pause button — Pause / Resume
- Eat all dots to win
- Eat power pellets (large flashing dots in corners) to turn ghosts blue — then eat them for bonus points!
- 3 lives total
| Action | Points |
|---|---|
| Eat a dot | 10 |
| Eat a power pellet | 50 |
| Eat a frightened ghost | 200 |
- Salesforce CLI (
sf) - A Salesforce Dev Hub org with Unlocked Packages enabled
- A scratch org or target org
sf org login web --set-default-dev-hub --alias myDevHubsf org create scratch --definition-file config/project-scratch-def.json --alias pacman-scratch --set-default --duration-days 7You may need to create
config/project-scratch-def.json. A minimal one:{ "orgName": "Pacman Dev", "edition": "Developer", "features": ["EnableSetPasswordInApi"] }
sf project deploy startOr for a scratch org:
sf pushsf org openNavigate to the Pacman app in the App Launcher.
sf package create \
--name "Pacman" \
--package-type Unlocked \
--path force-app \
--target-dev-hub myDevHubThis will update sfdx-project.json with a package ID. Commit that change.
sf package version create \
--package Pacman \
--installation-key-bypass \
--wait 10 \
--target-dev-hub myDevHubsf package install \
--package "Pacman@1.0.0-1" \
--target-org myTargetOrg \
--wait 10force-app/main/default/
lwc/pacman/ ← Lightning Web Component (the game)
pacman.html
pacman.js
pacman.js-meta.xml
pacman.css
classes/
PacmanScoreController.cls ← Apex: saves scores
PacmanScoreController.cls-meta.xml
PacmanScoreControllerTest.cls ← Apex: test class (100% coverage)
PacmanScoreControllerTest.cls-meta.xml
objects/PacmanScore__c/
PacmanScore__c.object-meta.xml ← Custom object definition
fields/PlayerName__c.field-meta.xml
fields/Score__c.field-meta.xml
tabs/
pacman.tab-meta.xml ← LWC tab
PacmanScore__c.tab-meta.xml ← Object tab
applications/
Pacman.app-meta.xml ← Lightning App
sf apex run test --class-names PacmanScoreControllerTest --result-format human- API Version: 62.0
- The game uses HTML5 Canvas rendered inside an LWC. This requires the component to run in a Lightning Tab or a page where
canvasrendering is supported. - Score saving is done via Apex when the game ends. If the save fails (e.g., offline or permissions issue), the game still shows the game over screen.
Built with 💛 and a lot of dots to eat.