# Galactic Unicorn - Animated Pacman

**URL:** <https://forums.pimoroni.com/t/galactic-unicorn-animated-pacman/20809>\
**Category:** Projects\
**Created:** [November 26, 2022, 3:46pm UTC](https://forums.pimoroni.com/t/galactic-unicorn-animated-pacman/20809 "2022-11-26T15:46:51Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Tonygo2](https://sea2.discourse-cdn.com/flex016/user_avatar/forums.pimoroni.com/tonygo2/32/7814_2.png) [@Tonygo2](https://forums.pimoroni.com/u/Tonygo2)\
**Post date:** [November 27, 2022, 11:01am UTC](https://forums.pimoroni.com/t/galactic-unicorn-animated-pacman/20809/2 "2022-11-27T11:01:52Z")

</div>

![DSCN4421](https://us1.discourse-cdn.com/flex016/uploads/pimoroni/original/2X/3/30d31d46e636ca14a3feadb5952ace1928cc4ade.jpeg)

Managed to get the monster’s mouth working

```auto
# PacMan + Monster Muncher
# Tony Goodhew - TonyGo2 - 26th November 2022
# Pimoroni Galactic Unicorn

from galactic import GalacticUnicorn
from picographics import PicoGraphics, DISPLAY_GALACTIC_UNICORN
import time

# create a PicoGraphics framebuffer to draw into
graphics = PicoGraphics(display=DISPLAY_GALACTIC_UNICORN)

# create our GalacticUnicorn object
gu = GalacticUnicorn()

#Define some colours
BLACK = graphics.create_pen(0, 0, 0)
RED = graphics.create_pen(255, 0, 0)
RED2 = graphics.create_pen(128, 0, 0)
YELLOW = graphics.create_pen(255, 255, 0)
GREEN = graphics.create_pen(0, 255, 0)
GREEN2 = graphics.create_pen(0, 128, 0)
CYAN = graphics.create_pen(0, 255, 255)
BLUE = graphics.create_pen(0, 0, 255)
BLUE2 = graphics.create_pen(0, 0, 128)
MAGENTA = graphics.create_pen(255, 0, 255)
WHITE = graphics.create_pen(200, 200, 200)
GREY = graphics.create_pen(100, 100, 100)
DRKGRY = graphics.create_pen(20, 20, 20)
PINK = graphics.create_pen(40, 10, 0)

# PacMan
pman = [
    0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0,
    0,0,0,1,1,1,1,1,1,1,1,1,1,0,0,0,
    0,0,1,1,1,1,1,1,1,1,1,1,1,1,0,0,
    0,1,1,1,2,2,1,1,1,1,2,2,1,1,1,0,
    1,1,1,2,2,2,2,1,1,2,2,2,2,1,1,1,
    1,1,1,2,2,2,2,1,1,2,2,2,2,1,1,1,
    1,1,1,1,2,2,1,1,1,1,2,2,1,1,1,1,
    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
    1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
    1,1,1,1,1,0,1,1,1,1,0,1,1,1,1,1,
    0,1,1,1,0,0,0,1,1,0,0,0,1,1,1,0
    ]

def eye(xx,yy):
    graphics.set_pen(BLUE2)
    graphics.pixel(xx,yy)
    graphics.pixel(xx+1,yy)
    graphics.pixel(xx,yy+1)
    graphics.pixel(xx+1,yy+1)
        
def show_man(c,xx,yy,xoff,yoff):
    p = 0
    for row in range(11):
        for col in range(16):            
            v = pman[p]
            if v ==0:graphics.set_pen(BLACK)
            if v ==1:graphics.set_pen(c)
            if v ==2:graphics.set_pen(WHITE)
            graphics.pixel(xx+col,yy+row)
            p = p + 1
    eye(xx+4+xoff,yy++4+yoff)
    eye(xx+10+xoff,yy++4+yoff)

def munch0(xx):
    graphics.set_pen(BLACK)
    graphics.clear()
    graphics.set_pen(YELLOW)
    graphics.circle(xx,5,5)

def munch1(xx):
    munch0(xx)
    graphics.set_pen(BLACK)
    for x in range(xx,xx+6,1):
        graphics.pixel(x,5)        

def munch2(xx):
    munch1(xx)
    graphics.set_pen(BLACK)
    for x in range(xx+2,xx+6,1):
        graphics.pixel(x,4)
        graphics.pixel(x,6)
    
def munch3(xx):
    munch2(xx)
    graphics.set_pen(BLACK)
    for x in range(xx+4,xx+6,1):
        graphics.pixel(x,3)
        graphics.pixel(x,7)

d = 0.2
for z in range(-17,53+7,1):
    seq = z % 6
    if seq == 0: munch0(z)
    if seq == 1: munch1(z)
    if seq == 2: munch2(z)
    if seq == 3: munch3(z)
    if seq == 4: munch2(z)
    if seq == 5: munch1(z)
    show_man(RED2,z + 15,0,1,0)
    gu.update(graphics)
    time.sleep(d)

```

Video here: [PacMan - YouTube](https://youtu.be/73aL2VAV6KI)

---

_[View the full topic](https://forums.pimoroni.com/t/galactic-unicorn-animated-pacman/20809)._
