SuperCollider PacMan

If anyone cares, I have recreated the game PacMan in SuperCollider. Still updating the ghost AI, adding a few more sound effects, and doing a few other GUI updates (adding the score tracker, etc). I had no idea where to put this post and I’m not even sure if it’s particularly useful information.

I have no idea if I’m allowed to put it on GitHub for educational purposes, but in case anyone was wondering if it’s possible to code Pac-Man in SC, the answer is “yes” and also without using any quarks or other externals.

It is almost fully functional, I’m mostly just finishing up the ghost AIs at this point. None of the sounds are from BufPlay either, I recreated the Namco wavetable in Ugen functions.

12 Likes

Wow. I want to check it out, and I definitely want to be able to show this to my students. I have no idea about the legality of sharing it though.

Sam

1 Like

I’ll show you it when I get to Baltimore! I’m one of the incoming comp DMA students.

Oh awesome. I look forward to hanging out for the next couple of years!

Welcome!

Sam

Impressive! I think it would be totally legit to post if you changed the artwork ? I’d love to see how you did the logic, how you broke the code down, etc.

Sure, let me think of a way to do this once it’s complete. I expect it should be within a week or two

@john-d-murphy :stuck_out_tongue_winking_eye:

(
s.waitForBoot({
	var sigs, bufSize=32, waveSamples=32;
	var waka, powerSound, deathSound, ghostDeathSound, siren, fruit;
	t = TempoClock(105/60);
	sigs = ([
		[7,9,10,11,12,13,13,14,14,14,13,13,12,11,10,9,7,5,4,3,2,1,1,0,0,0,1,1,2,3,4,5],
		[7,12,14,14,13,11,9,10,11,11,10,9,6,4,3,5,7,9,11,10,8,5,4,3,3,4,5,3,1,0,0,2],
		[7,10,12,13,14,13,12,10,7,4,2,1,0,1,2,4,7,11,13,14,13,11,7,3,1,0,1,3,7,14,7,0],
		[7,13,11,6,11,13,9,6,11,14,12,7,9,10,6,2,7,12,8,4,5,7,2,0,3,8,5,1,3,6,3,1],
		[0,8,15,7,1,8,14,7,2,8,13,7,3,8,12,7,4,8,11,7,5,8,10,7,6,8,9,7,7,8,8,7],
		[7,8,6,9,5,10,4,11,3,12,2,13,1,14,0,15,0,15,1,14,2,13,3,12,4,11,5,10,6,9,7,8],
		[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0],
		[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
	])/15;

	a = sigs.collect({
		arg item, i;
		b = Env(item, (1!32));
		c = b.asSignal(1024);
		d = c.asWavetable;
		e = Buffer.loadCollection(s, d);
	});

	SynthDef(\wt, {
		arg amp=0.5, out=0, freq=261.63, bufNum=0, dur;
		var sig, env;
		sig = Osc.ar(bufNum, freq);
		env = EnvGen.ar(
			Env([0,1,0], [0.01,0.8],\lin), timeScale:dur*(105/60),
			doneAction:2
		).round(1/16);
		sig = LeakDC.ar(sig);
		sig = (sig * amp * env)!2;
		Out.ar(out, sig)
	}).add;
	
	~themeTreble = PmonoArtic(\wt,
		\bufNum, 6,
		\dur, Pseq((0.25!4)++[1/8,3/8,1/2],3)++Pseq((0.125!2)++[0.25],3)++Pseq([0.5]),
		\root, Pseq((-1!7)++(0!7)++(-1!7)++[3,4,5,5,6,7,7,8,9,11]),
		\octave, 6,
		\degree, Pseq([0,7,4,2,7,4,2],3)++Pseq((0!10)),
		\amp, 0.5,
		\legato, 0.5
	);

	~themeBass = PmonoArtic(\wt,
		\bufNum, 1,
		\dur, Pseq([3/4,1/4],6)++Pseq([1/2],4),
		\root, Pseq((-1!4)++(0!4)++(-1!4)++[6,8,10,11]),
		\octave, 3,
		\degree, Pseq([0,7],6)++Pseq([0,0,0,0]),
		\amp, 0.25,
		\legato, 0.6
	);

	~theme = Ppar([
		~themeTreble,
		~themeBass
	]);

	
	s.sync;

	~waka = {
		LeakDC.ar(Osc.ar(2, (LFTri.ar(10/3, mul:2) * 60.midicps))) * 0.18!2 * EnvGen.ar(Env.triangle(1/3),doneAction:2);
	};
});
)
~waka.play;
~theme.play(t);

Super cool !!! I would be great play it!

This is incredible important work you’re doing :))))))))

3 Likes