PAC MAN
How to play:
1. click the canvas below.
2. use arrow keys to start playing!
document.body.style.backgroundColor = “black”;
document.body.style.color = “white”;
document.body.style.fontFamily = “sans-serif”;
var txtEls = document.getElementsByClassName(“txt”);
var programCode = function(processingInstance) {
with (processingInstance) {
var actualSize = 900;
size(actualSize, actualSize);
// Paste code from Khan Academy here:
var tiles = [];
var restoreTiles = function() {
tiles = [{n: 0, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 1, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 1, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 1, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 1, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 0, d: 1, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}, {n: 1, d: 0, done: 0, pellet: 0, fruit: 0}];
};
restoreTiles();
tiles[411].pellet = 1;
tiles[471].pellet = 1;
tiles[254].pellet = 1;
tiles[145].pellet = 1;
tiles[509].fruit = 1;
tiles[248].fruit = 2;
tiles[353].fruit = 1;
tiles[132].fruit = 2;
var lives = 3;
var dead = false;
var round = function(n) {
return Math.round(n);
};
var sin = function(n) {
return Math.sin(n);
};
var cos = function(n) {
return Math.cos(n);
};
var powerPellet = false;
var pelletTimer = 0;
var FPS = 4;
var pelletCooldown = FPS * 10;
var w = 600;
var h = 600;
var s = actualSize/h;
var tileSize = 25;
var tileX = w/tileSize + 1;
var tileY = h/tileSize;
var player = 0;
var playerVel = 0;
var SPS = 1;
var fruitTimer = 0;
var ghosts = [];
for(var j = 0; j < 2; j ++) {
for(var i = 0; i < 3; i ++) {
ghosts.push({pos: floor(tileX/2) + floor(tileX * tileY/2) – 1 + i – j * tileX, dir: 0});
}
}
var keys = [];
var score = 0;
noStroke();
keyPressed = function() {
keys[keyCode] = true;
if(keys[UP] && playerVel !== tileX) {
playerVel = -tileX;
}
else if(keys[DOWN] && playerVel !== -tileX) {
playerVel = tileX;
}
if(keys[LEFT] && playerVel !== 1) {
playerVel = -1;
}
else if(keys[RIGHT] && playerVel !== -1) {
playerVel = 1;
}/*
var t = "var tiles = [";
for(var i = 0; i < tiles.length; i ++) {
t += "{n: " + tiles[i].n + ", d: " + tiles[i].d + ", done: 0, pellet: " + tiles[i].pellet + ", fruit: 0}";
if(i !== tiles.length-1) {
t += ", ";
}
}
t += "];";
println(t);
*/
if(tiles[261].n === 1) {
tiles[261].n = 0;
}
};
keyReleased = function() {
keys[keyCode] = false;
};
mousePressed = function() {
if(dead){
dead = false;
lives = 3;
restoreTiles();
playerVel = 0;
player = 0;
score = 0;
for(var j = 0; j < 2; j ++) {
for(var i = 0; i < 3; i ++) {
ghosts[k].pos = floor(tileX/2) + floor(tileX * tileY/2) – 1 + i – j * tileX;
k ++;
}
}
}
};
for(var i = 0; i < tileX; i ++) {
tiles.push({n: 1, d: 0, pellet: 0, done: 0});
}
var findId = function(x, y) {
var actualX = floor(x/tileSize/s);
var actualY = floor(y/tileSize/s);
return actualY * tileX + actualX;
};
var findPos = function(id) {
var y = floor(id / tileX);
var x = id % tileX;
return PVector.mult(new PVector(x, y), tileSize * s);
};
var drawTiles = function() {
for(var i = 0; i 0) {
if(tiles[i].fruit === 1) {
fill(255, 0, 0);
ellipse(pos.x + tileSize * 3/7, pos.y + tileSize * 3/7, tileSize * 2/5, tileSize * 2/5);
ellipse(pos.x + tileSize * 5/7, pos.y + tileSize * 4/7, tileSize * 2/5, tileSize * 2/5);
}
else if(tiles[i].fruit === 2) {
fill(255, 125, 0);
ellipse(pos.x + tileSize/2, pos.y + tileSize/2, tileSize * 3/4, tileSize * 3/4);
}
}
else {
ellipse(pos.x + tileSize/2, pos.y + tileSize/2, tileSize/4, tileSize/4);
if(tiles[i].pellet === 1) {
ellipse(pos.x + tileSize/2, pos.y + tileSize/2, tileSize/2, tileSize/2);
}
}
resetMatrix();
}
}
};
var stuff = function(d) {
var need = [{n: d, dir: 1000000000}];
for(var i = 0; i 0 && limit > 0) {
if(tiles[need[0].n].done === -1) {
tiles[need[0].n].done = need[0].dir;
for(var j = 0; j = 0 && t = 0) {
if(tiles[player].n===1) {
player = lastPlayer;
playerVel = 0;
}
}
else{
player = lastPlayer;
playerVel = 0;
}
if(playerVel !== 0) {
playerPos.add(new PVector(cos(radians(rotation)) * tileSize/2 * s, sin(radians(rotation)) * tileSize/2 * s));
}
}
fill(255,255,0);
translate(playerPos.x + tileSize/4*s, playerPos.y + tileSize/4*s);
rotate(radians(rotation));
beginShape();
var starting = floor(frameCount/2)%2;
vertex(0, 0);
for(var i = starting*30; i = 0; i –) {
if(ghosts[i].pos === player) {
if(powerPellet) {
ghosts[i].pos = floor(tileX/2) + floor(tileX * tileY/2);
score += 10;
}
else{
var k = 0;
for(var j = 0; j < 2; j ++) {
for(var i = 0; i < 3; i ++) {
ghosts[k].pos = floor(tileX/2) + floor(tileX * tileY/2) – 1 + i – j * tileX;
k ++;
}
}
playerVel = 0;
player = 0;
SPS = 1;
tiles[261].n = 1;
lives –;
if(lives = 0 && ghosts[i].pos < tiles.length) {
if(tiles[ghosts[i].pos].n === 1) {
ghosts[i].pos = lastGhost;
if(tiles[ghosts[i].pos].done === -1) {
ghosts[i].dir = Math.round(Math.random() * 4) * 90;
}
else{
if(tiles[ghosts[i].pos].done !== -1){
ghosts[i].dir = tiles[ghosts[i].pos].done + 180;
if(powerPellet) {ghosts[i].dir -= 180;}
}
}
}
else {
for(var k = 0; k = 0 && ghosts[i].pos < tiles.length) {
if(tiles[ghosts[i].pos].n === 1) {
ghosts[i].pos = lastGhost;
ghosts[i].dir = Math.round(Math.random() * 4) * 90;
}
else {
for(var k = 0; k < ghosts.length; k ++) {
if(ghosts[k].pos === ghosts[i].pos && i !== k) {
ghosts[i].pos = lastGhost;
if(tiles[ghosts[i].pos].done === -1) {
ghosts[i].dir = Math.round(Math.random() * 4) * 90;
}
}
}
}
}
else{
ghosts[i].pos = lastGhost;
ghosts[i].dir = Math.round(Math.random() * 4) * 90;
}
}
var ghostPos = findPos(ghosts[i].pos);
fill(lerpColor(color(255,0,255), color(0,255,255), i/ghosts.length));
if(powerPellet) {
fill(0, 0, 150);
if(pelletTimer <= 12 && frameCount % 2 === 0) {
fill(255);
}
}
translate(ghostPos.x + tileSize/2 * s, ghostPos.y + tileSize/2 * s);
scale(tileSize/110 * s);
beginShape();
for(var j = 0; j < 180; j ++) {
vertex(cos(radians(j)) * 50, -sin(radians(j)) * 50);
}
vertex(-50, 50);
var thing = 1;
for(var j = -50; j 0) {
SPS *= tiles[player].fruit + 1;
fruitTimer += FPS * 15;
}
}
if(powerPellet) {
pelletTimer –;
if(pelletTimer 0) {
fruitTimer –;
if(fruitTimer <= 0) {
SPS = 1;
}
}
}
else{
fill(0, 20);
rect(0, 0, width, height);
fill(255);
textSize(50 * s);
var t = "";
for(var i = 0; i < floor(score/50); i ++){
t += "!";
}
if(t === ""){
t = ". Sad.";
}
text("You Lost!\nClick to restart!\nFINAL SCORE: " + score + t, width/2, height/2);
}
};
}};
var clicked = function() {
for(var i = 0; i < txtEls.length; i ++){
txtEls[i].hidden = true;
}
};
// Get the canvas that ProcessingJS will use
var canvas = document.getElementById("mycanvas");
canvas.addEventListener("click", clicked);
// Pass the function to ProcessingJS constructor
var processingInstance = new Processing(canvas, programCode);