//Constants
var SPEED = 3,
SIZE = 21,
COLS = floor(width/SIZE),
ROWS = floor(height/SIZE-1),
WEST = 1,
NORTH = 2,
EAST = 4,
SOUTH = 8,
PELLET = 16,
POWERUP = 32,
PELLET_POINTS = 10,
ENEMIES = 4;
//Variables
var g = {isDone:true,score:0};
var p = {x:0,y:0,d:EAST,n:EAST}; //Player
var e = []; //Enemies
var m; //Maze
//Functions
var canMove = function(m,p,d){
var c,r;
c=floor(p.x/SIZE);
r=floor(p.y/SIZE);
switch(d){
case WEST:
c+=p.x%SIZE?1:0;
if(p.y%SIZEm[r][c]&WEST){return false;}
break;
case NORTH:
r+=p.y%SIZE?1:0;
if(p.x%SIZEm[r][c]&NORTH){return false;}
break;
case EAST:
if(p.y%SIZEm[r][c]&EAST){return false;}
break;
case SOUTH:
if(p.x%SIZEm[r][c]&SOUTH){return false;}
break;
}
return true;
};
var keyPressed = function(){
var d = pow(2,keyCode-37);
if(canMove(m,p,d)){
p.d=d;
}
p.n=d;
};
var getGrid=function(){
var a=[],r,c;
for(r=0;r<ROWS;r++){
a.push([]);
for(c=0;c<COLS;c++){
a[r].push(31);
}
}
return a;
};
var generateMaze=function(){
var s = [{r:0,c:0}], r,c,u,d;
while(s.length){
r=s[s.length-1].r;
c=s[s.length-1].c;
u=[];
if(c>0 && m[r][c-1]%16===15){u.push(WEST);}
if(r>0 && m[r-1][c]%16===15){u.push(NORTH);}
if(c<COLS-1 && m[r][c+1]%16===15){u.push(EAST);}
if(r<ROWS-1 && m[r+1][c]%16===15){u.push(SOUTH);}
if(u.length){
d=u[round(random(u.length-1))];
switch(d){
case WEST:
m[r][c] -= WEST;
m[r][c-1] -= EAST;
s.push({r:r,c:c-1});
break;
case NORTH:
m[r][c] -= NORTH;
m[r-1][c] -= SOUTH;
s.push({r:r-1,c:c});
break;
case EAST:
m[r][c] -= EAST;
m[r][c+1] -= WEST;
s.push({r:r,c:c+1});
break;
case SOUTH:
m[r][c] -= SOUTH;
m[r+1][c] -= NORTH;
s.push({r:r+1,c:c});
break;
}
}
else{
s.pop();
}
}
};
var generateEnemies = function(e){
for(var i=0;i<ENEMIES;i++){
e.push({
x:floor(random(COLS))*SIZE,
y:floor(random(ROWS))*SIZE,
d:pow(2,round(random(3)))
});
}
};
var drawMaze=function(){
text(g.score,0,395);
var r,c;
for(r=0;r<ROWS;r++){
for(c=0;c<COLS;c++){
if(m[r][c]&PELLET){
stroke(255);
strokeWeight(3);
point(c*SIZE+(SIZE+1)/2,r*SIZE+(SIZE+1)/2);
}
stroke(0,255,0);
strokeWeight(1);
if(m[r][c]&WEST){
line(c*SIZE,r*SIZE,
c*SIZE,(r+1)*SIZE);
}
if(m[r][c]&NORTH){
line(c*SIZE,r*SIZE,
(c+1)*SIZE,r*SIZE);
}
if(m[r][c]&EAST){
line((c+1)*SIZE,r*SIZE,
(c+1)*SIZE,(r+1)*SIZE);
}
if(m[r][c]&SOUTH){
line(c*SIZE,(r+1)*SIZE,
(c+1)*SIZE,(r+1)*SIZE);
}
}
}
};
var movePlayer = function(m,p){
var c,r;
if(canMove(m,p,p.n)){
p.d=p.n;
}
if(!canMove(m,p,p.d)){
return;
}
switch(p.d){
case WEST:
p.x-=SPEED;
break;
case NORTH:
p.y-=SPEED;
break;
case EAST:
p.x+=SPEED;
break;
case SOUTH:
p.y+=SPEED;
break;
}
c=floor(p.x/SIZE);
r=floor(p.y/SIZE);
if(p.x%SIZE===0&&p.y%SIZE===0&&m[r][c]&PELLET){
g.score+=PELLET_POINTS;
m[r][c]-=PELLET;
}
};
var drawPlayer = function(p){
var theta;
switch(p.d){
case WEST:
theta=180;
break;
case NORTH:
theta=270;
break;
case EAST:
theta=0;
break;
case SOUTH:
theta=90;
break;
}
fill(255, 255, 0);
noStroke();
arc(p.x+(SIZE+1)/2+1,p.y+(SIZE+1)/2+1,SIZE-4,SIZE-4,
theta+sin(frameCount%9*40)*45,
theta+360-sin(frameCount%9*40)*45);
};
var moveEnemies = function(m,e){
var d;
for (var i=0;i<e.length;i++){
if(e[i].x%SIZE===0&&e[i].y%SIZE===0){
d = pow(2,(log(e[i].d)/log(2)+3)%4);
while(!canMove(m,e[i],d)){
d = pow(2,(log(d)/log(2)+1)%4);
}
e[i].d=d;
}
switch(e[i].d){
case WEST:
e[i].x-=SPEED;
break;
case NORTH:
e[i].y-=SPEED;
break;
case EAST:
e[i].x+=SPEED;
break;
case SOUTH:
e[i].y+=SPEED;
break;
}
}
};
var drawEnemies = function(e){
fill(255, 0, 0);
for (var i=0;i<e.length;i++){
ellipse(e[i].x+(SIZE+1)/2+1,e[i].y+(SIZE+1)/2+1,
SIZE-4,SIZE-4);
}
};
m = getGrid();
generateMaze();
generateEnemies(e);
var draw=function() {
movePlayer(m,p);
moveEnemies(m,e);
background(0);
drawMaze();
drawPlayer(p);
drawEnemies(e);
};
Pacman works when you use the joystick to move your character around the screen. The goal is to eat the food and avoid the ghosts.
to collect all the dots and not get captured by the ghosts
A man was eating Pizza took out a slice when bam it hit him it looks so cool then he used it as a character in his game and walla! Pacman was created.
Pokemon
My guess would be Assembler or some similar machine code.
HGTY-UTAH-TRWU trust me it will work
Pacman Jones goes by Pacman.
In the Mrs. Pacman game after stage 2.
mr Simon pacman
My mom said that mrs. Pacman has different parts!
Of course PacMan likes Ms. PacMan! After the first 2 levels, they *kiss*, and after the 9th level, they have a *baby*! Does he like her? He loves her!
it would be pacman because it was an arcade game but if you have a N64 you can buy it
Pacman is Adam "Pacman" Jones, even though he don't really wrestle
Pacman's birthday is May 22.
pacman is the oldest