Learn R Programming

A ggplot2 and gganimate Version of Pac-Man

The goal of ggpacman is to … Build a GIF of the game Pac-Man (not to develop an R version of Pac-Man …).

Installation

# Install ggpacman from CRAN:
install.packages("ggpacman")

# Or the the development version from GitHub:
# install.packages("remotes")
remotes::install_github("mcanouil/ggpacman")

Pac-Man in action

library(ggpacman)
animate_pacman(
  pacman = pacman,
  ghosts = list(blinky, pinky, inky, clyde),
  font_family = "xkcd"
)

The Story of ggpacman

It started on a Saturday evening …

It was the 21st of March (for the sake of precision), around 10 pm CET (also for the sake of precision and mostly because it is not relevant). I was playing around with my data on ‘all’ the movies I have seen so far (mcanouil/IMDbRating) and looking on possibly new ideas of visualisation on twitter using #ggplot2 and #gganimate (by the way the first time I played with gganimate was at useR-2018 (Brisbane, Australia), just before and when @thomasp85 released the actual framework). The only thing on the feed was “contaminated/deaths and covid-19” curves made with ggplot2 and a few with gganimate … Let’s say, it was not as funny and interesting as I was hoping for … Then, I’ve got an idea, what if I can do something funny and not expected with ggplot2 and gganimate? My first thought, was let’s draw and animate Pac-Man, that should not be that hard!

Well, it was not that easy after-all … But, I am going to go through my code here (you might be interested to actually look at the commits history.

Maybe I went too far with #ggplot2 and #gganimate

Copy Link

Version

Install

install.packages('ggpacman')

Monthly Downloads

9

Version

0.1.0

License

GPL-3

Issues

Pull Requests

Stars

Forks

Maintainer

Mickael Canouil

Last Published

May 16th, 2020

Functions in ggpacman (0.1.0)

inky

Inky moves
maze_points

Maze Points
compute_ghost_status

Compute Ghost Status
compute_pacman_coord

Compute Pac-Man Coordinates
maze_walls

Maze Walls
pacman

Pac-Man moves
clyde

Clyde moves
compute_ghost_coord

Compute Ghost Coordinates
animate_pacman

Create a Pac-Man Game GIF
compute_points_eaten

Compute Point Eaten by Pac-Man
ghost_eyes

Ghost Eyes Polygon
ghost_body

Ghost Body Polygon
blinky

Blinky moves
pinky

Pinky moves
ggpacman-package

ggpacman: A 'ggplot2' and 'gganimate' Version of Pac-Man