Pac-Man clone in 1020 bytes created for Pico1K Jam 2024!

Controls

Always keep one (and only one) arrow key held down.

Ctrl-R to restart.


Ghosts

The thing I'm most proud about with this clone is that the four ghosts use the correct behavior. If you want details, I recommend reading the excellent Pac-Man Dossier.

Some offsets have been tweaked to fit the smaller board.

Here's the quick version:

  • Red (Blinky) always targets Pac-Man's location.
  • Pinky targets the space 3 tiles in front of Pac-Man.
  • Blue (Inky) has a complex target involving the space in front of Pac-Man and the vector delta between Blinky and that position.
  • Orange (Clyde) generally targets Pac-Man but if he has to make a decision when Pac-Man is nearby he will instead target the bottom left tile.

When ghosts need to make a decision about where to go, they look at all open tiles next to them and select the one with the shortest as-the-crow-flies distance to their target.

Ghosts are never allowed to backtrack.

Source Code

The full compressed source is below. Although I like to use Shrinko8 for reference, I prefer to do my own minimizing as I like to select variable names for readability. I find I can generally shave off a few extra characters doing it myself.

Here is a link to expanded source code with white space and comments. Note: the expanded code may differ in some very minor ways. I try to figure out all my shrinking before I really compress, but I often find small saves while I'm doing the shrink code.

This code was written in Pico-8 0.2.6b

a=abs r=rect
pal({0,10,8,9,14,13},1)cls(12)r(1,1,6,5,1)r(8,1,13,5)r(3,3,11,10)r(5,5,9,13)r(1,8,5,13)r(9,8,13,13)memcpy(0,24576,16384)s=pset
t=0g=1u=0l={}::_::?'⁶1⁶c'
sspr(0,0,16,16,-4,-4,144,144)q=band
b=btn()h=q(b,2)/2-q(b,1)v=q(b,8)/8-q(b,4)/4if(t%70<1and#l<5)add(l,{x=7,y=6,c=0,r=0})p=l[1]
for x=0,16do for y=0,16do
m=sget(x,y)==1if(m)s(x*9,y*9,7)if(p.x==x and p.y==y and m)sset(x,y,0)
end end
t+=g
u-=(g-1)/99f=6i=1for o in all(l)do
f+=2i+=1if t%f<g then
o.x+=o.c o.y+=o.r
j=p.x k=p.y
if(i==4and a(j-o.x)+a(k-o.y)<5)j,k=0,16
if(i>4)j,k=j+p.c*3,k+p.r*3
if(i>5)j,k=j+p.x-l[2].x,k+p.y-l[2].y
b=99for c=-1,1do
for r=-1,1do
x=o.x+c
y=o.y+r
d=a(j-x)+a(k-y)-sgn(o.c*c+o.r*r)*3if(c==h and r==v)d=-9
if(sget(x,y)<2and a(c+r)==1and d<b)b,m,n=d,c,r
end end o.c,o.r=m,n end
h=9k=t/f%1*9x=o.c*k+o.x*9y=o.r*k+o.y*9if(i<3)w,z=x,y
if(i>2and a(x-w)+a(y-z)<6)g=0
circfill(x,y,3,i)d=min(1,u+sin(t/9)/7)for e=-d,d,.01do
q=e+atan2(o.c,o.r)if(i<3)line(x,y,x+cos(q)*4,y+sin(q)*4,0)end
if(i>2)r(x-3,y,x+3,y+3)s(x-2,y,7)s(x+2,y,7)
end goto _

Comments

Log in with itch.io to leave a comment.

(+1)

how to play 2p

I might need some more chars to work with

hmm

interesting game!