<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
      <title>Tagged with #pacman - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=%23pacman</link>
      <pubDate>Sun, 08 Aug 2021 19:26:28 +0000</pubDate>
         <description>Tagged with #pacman - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23pacman/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Using the Grid in a pacman based game</title>
      <link>https://forum.processing.org/two/discussion/26632/using-the-grid-in-a-pacman-based-game</link>
      <pubDate>Sun, 04 Mar 2018 02:17:20 +0000</pubDate>
      <dc:creator>InferNova</dc:creator>
      <guid isPermaLink="false">26632@/two/discussions</guid>
      <description><![CDATA[<p>So I as I understand how to load a grid file from a text file I come about to ask how do I make the player stop against these barriers properly ?</p>
]]></description>
   </item>
   <item>
      <title>Best way to make world borders for a game.</title>
      <link>https://forum.processing.org/two/discussion/26345/best-way-to-make-world-borders-for-a-game</link>
      <pubDate>Wed, 14 Feb 2018 11:11:04 +0000</pubDate>
      <dc:creator>InferNova</dc:creator>
      <guid isPermaLink="false">26345@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys so I play around with coding games but I am wondering what the best way to set boundaries for a player, the way I use now is using co-ordinates points when the player reaches them he can't pass but it becomes excruciating for bigger projects any ideas ? (I was looking at the Sprites library and noticed that the tank demo uses colors then overlaid with the map and I presume when the player interacts with those colors it triggers a certain action but still not sure how to use that).</p>
]]></description>
   </item>
   <item>
      <title>I need some help creating a Pacman snake.</title>
      <link>https://forum.processing.org/two/discussion/25583/i-need-some-help-creating-a-pacman-snake</link>
      <pubDate>Fri, 15 Dec 2017 17:20:07 +0000</pubDate>
      <dc:creator>galliardox</dc:creator>
      <guid isPermaLink="false">25583@/two/discussions</guid>
      <description><![CDATA[<p>I started making a variation of Pacman, with some changes to the original idea.
My Pacman is controlled by mouse and can move in any direction, and it's a snake.</p>

<p>My only problem is a mouth. I don't know, how to make it work.
I want it either be active all the time or only when snake moves, any solution will work. Can you help me?</p>

<p>Here is my code:<a href="https://gist.github.com/anonymous/d002d99b90b2288ee6f8f3a16ee49c2e" target="_blank" rel="nofollow">https://gist.github.com/anonymous/d002d99b90b2288ee6f8f3a16ee49c2e</a></p>
]]></description>
   </item>
   <item>
      <title>URGENT: Code Skipping Over Individual Paths</title>
      <link>https://forum.processing.org/two/discussion/25256/urgent-code-skipping-over-individual-paths</link>
      <pubDate>Tue, 28 Nov 2017 18:23:37 +0000</pubDate>
      <dc:creator>dangel3272</dc:creator>
      <guid isPermaLink="false">25256@/two/discussions</guid>
      <description><![CDATA[<p>Hi, I'm fairly new to Processing, and I'm having an issue where I have multiple paths, but it will skip through multiple to go to the last one. I'm fairly sure the issue is that the coordinates to go to the next path are the same for each one, but it's kind of necessary for my project, and I'd really love to know if there was some kind of work-around. Here is my code:</p>

<pre><code>PImage StartScreen;
PImage Text1;
PImage Text2;
PImage FinalText;
PImage Keep;
PImage Fire;
PImage Laverne;
PImage Chase;
PImage Lindsay;
PImage Riley;
int stage;
int path = 0;

void setup () {
  stage=1;
  size (960, 540);
  StartScreen = loadImage ("Start Screen.png");
  Text1 = loadImage ("Text card 1.png");
  Text2 = loadImage ("Text card 2.png");
  FinalText = loadImage ("Text card 3.png");
  Keep = loadImage ("KEEP Big.png");
  Fire = loadImage ("FIRE Big.png");
  Laverne = loadImage ("Laverne Waller.png");
  Chase = loadImage ("Chase Willoughby.png");
  Lindsay = loadImage ("Lindsay Holme.png");
  Riley = loadImage ("Riley Travis.png");
}

void draw () {
  println (mouseX, mouseY);
  //START SCREEN
  if (path == 0) {
    image (StartScreen, 0, 0);
    if ((mouseX &gt; 354) &amp;&amp; (mouseX &lt; 432) &amp;&amp; (mouseY &gt; 368) &amp;&amp; (mouseY &lt; 396) &amp;&amp; (mousePressed == true)) {
      path = 1;
    }
  }

  //FIRST TEXT
  else if (path == 1) {
    image (Text1, 0, 0);
    if ((mouseX &gt; 385) &amp;&amp; (mouseX &lt; 445) &amp;&amp; (mouseY &gt; 412) &amp;&amp; (mouseY &lt; 437) &amp;&amp; (mousePressed == true)) { 
      path = 2;
    }
  }

  //SECOND TEXT
  else if (path == 2) {
    image (Text2, 0, 0);
    if ((mouseX &gt; 382) &amp;&amp; (mouseX &lt; 443) &amp;&amp; (mouseY &gt; 372) &amp;&amp; (mouseY &lt; 397) &amp;&amp; (mousePressed == true)) {
      path = 3;
    }
  }

  //PATH 3
  else if (path == 3) { // Laverne
    background (0);
    imageMode (CENTER);
    image (Keep, 240, 405);
    image (Fire, 720, 405);
    image (Laverne, 480, 150);

    if ((mouseY &gt; 315) &amp;&amp; (mouseY &lt; 515) &amp;&amp; (mouseX &gt; 98) &amp;&amp; (mouseX &lt; 398) &amp;&amp; (mousePressed == true)) {
      path = 4;
    } else if ((mouseX &gt; 575) &amp;&amp; (mouseX &lt; 875) &amp;&amp; (mouseY &gt; 315) &amp;&amp; (mouseY &lt; 515) &amp;&amp; (mousePressed == true)) {
      path = 4;
    }
  }

  // PATH 4
  else if (path == 4) { // Chase
    image (Keep, 240, 405);
    image (Fire, 720, 405);
    image (Chase, 480, 150);

    if ((mouseY &gt; 315) &amp;&amp; (mouseY &lt; 515) &amp;&amp; (mouseX &gt; 98) &amp;&amp; (mouseX &lt; 398) &amp;&amp; (mousePressed == true)) {
      path = 5;
    } else if ((mouseX &gt; 575) &amp;&amp; (mouseX &lt; 875) &amp;&amp; (mouseY &gt; 315) &amp;&amp; (mouseY &lt; 515) &amp;&amp; (mousePressed == true)) {
      path = 5;
    }
  }                                                    

  // PATH 5
  else if (path == 5) { // Lindsay
    image (Keep, 240, 405);
    image (Fire, 720, 405);
    image (Lindsay, 480, 150);

    if ((mouseY &gt; 315) &amp;&amp; (mouseY &lt; 515) &amp;&amp; (mouseX &gt; 98) &amp;&amp; (mouseX &lt; 398) &amp;&amp; (mousePressed == true)) {
      path = 6;
    } else if ((mouseX &gt; 575) &amp;&amp; (mouseX &lt; 875) &amp;&amp; (mouseY &gt; 315) &amp;&amp; (mouseY &lt; 515) &amp;&amp; (mousePressed == true)) {
      path = 6;
    }
  }

  else if (path == 6) {
    image (Keep, 240, 405);
    image (Fire, 720, 405);
    image (Riley, 480, 150);

    if ((mouseY &gt; 315) &amp;&amp; (mouseY &lt; 515) &amp;&amp; (mouseX &gt; 98) &amp;&amp; (mouseX &lt; 398) &amp;&amp; (mousePressed == true)) {
      path = 7;
    } else if ((mouseX &gt; 575) &amp;&amp; (mouseX &lt; 875) &amp;&amp; (mouseY &gt; 315) &amp;&amp; (mouseY &lt; 515) &amp;&amp; (mousePressed == true)) {
      path = 7;
    }
  }

  else if (path == 7) {
    imageMode (CORNER);
    image (FinalText, 0, 0);
  }
}
</code></pre>

<p>Any help would be greatly appreciated!</p>
]]></description>
   </item>
   <item>
      <title>Pac man Game(Not completed) Asking for assistance</title>
      <link>https://forum.processing.org/two/discussion/11156/pac-man-game-not-completed-asking-for-assistance</link>
      <pubDate>Thu, 04 Jun 2015 17:38:07 +0000</pubDate>
      <dc:creator>ArcheryPrincess1452</dc:creator>
      <guid isPermaLink="false">11156@/two/discussions</guid>
      <description><![CDATA[<pre><code>//Variables
//user variables
int paxX=246, paxY=246;
//Gost variables
float gostX=245, gostY=245;
//Food Variables
int FoodX[] = new int [2401];
int FoodY[] = new int [2401];
//array used for eaten food
float foodeat[] = new float [2401];
//if food is in wall
int foodinwall;
//Level
int level=1;
//Lives
int lives=3;
//Score
int score=0;
int cupcake=0;
//Images
PImage Maz; //Maze image
PImage Food; //Food image
PImage Gost; //Gost image
//Setup for game
void setup(){
  //setup,basic
  frameRate(60);
  size(500,500);
  noStroke();
  smooth();
  //Load images
  Images();
  //Sets food/starting locations
  Food();
}//eND sETUP

void draw(){
  background(0);
  Gost();
  Maz();
  pax_user();

}
 //Food
 void Food(){
  for (int f=0; f &lt; 2401; f++) {
    //determination if food was eaten
    if (Foodeat[f]==0){
      //If food has not been eaten, draw
      image (Food, FoodX[f], FoodY[f]);
      foodinwall=get (FoodX[f]-1, FoodY[f]+1);
      //text(""+ foodinwall,100,200);
      if (foodinwall == -1.6777216E7){
        foodeat[f]=1;
        cupcake=cupcake+1;
      }

      if(paxX==FoodX[f] &amp;&amp; FoodY[f]==paxY){
        //if pax eats food
        foodeat[f]=1;
        //add score
        cupcake=cupcake+1;
        score=score+1;
      }

    }
  }
 }//End Food

 void foodsetup(){
   foodX[0]=6;
   foodY[0]=6;
   //other pieces of food
   for (int i=1; i &lt; 2401; i++){
     foodX[i]=foodX[i-1]+10;
     foodY[i]=foodY[i-1];
     //if at edge of screen, reset and layer is put down.
     if(foodX[i] ==496){
       foodX[i]=6;
       foodY[i]=foodY
   }

void Gost() {
  //gost is left of pax
  if(paxX&gt;GostX) {
    //moves towards pax at specific speed
    GostX=GostX+level-3;
  }
  //gost right of pax
  (paxX&lt;GostX) {
    //moves towards pax at spesific speed
    GostX=GostX-level+3;
  }
  //gost above pax
  (paxY&gt;GostY){
    //moves toward pax at specific speed
    GostY=GostY+level-3;
  }
  //gost be low pax
  (paxY&lt;GostY){
    //moves towards pax at specific speed
    GostY=GostY-level+3;
  }

  //Draw Gost
  image(Gost,GostX,GostY);
  //End gost
}

void images(){
 //Images load
 //Maze
 Maz = loadImage("Maz.jpg");
 //Food
 Food = loadImage("Food.jpg");

void Maz(){
//Draw Maze
if(playmaze==1){
  image(Maz,0,0);
}

}//End maz

void pax_user(){
  //user movement
  if (keyPressed) {
    if (key==CODED) {
      if (keyCode==RIGHT){
        paxX=paxY+5;
      }
      if(keyCode==LEFT){
        paxX=paxY-5;
      }
      if(keyCode==DOWN){
        paxY=paxX+5;
      }
      if(keyCode==UP){
        paxY=paxX-5;
      }
    }
  }
  //Drawimage
  image(pax,paxX,paxY);
}//end user draw
</code></pre>
]]></description>
   </item>
   <item>
      <title>Build a Pacman Game</title>
      <link>https://forum.processing.org/two/discussion/19724/build-a-pacman-game</link>
      <pubDate>Tue, 13 Dec 2016 17:34:27 +0000</pubDate>
      <dc:creator>shaunafitzgoo</dc:creator>
      <guid isPermaLink="false">19724@/two/discussions</guid>
      <description><![CDATA[<p>Hi everyone. I am a complete beginner with processing.
I have tried to build a pacman game. I assume i will need to build it with a grid and let the pacman follow the grid. However, I'm unsure about how I would create the little bits of food around the grid and the ghosts to move around it. Any help would be great. The only bit of code I have so far is creating the pacman and making the mouth move. Also is there a way to create walls in the game for the pacman to move around or would I need to use the grid and draw lines. Thanks.</p>

<pre><code>int radius = 12;
int direction = 1;
int direction2 = 0;

float x = 250;
float y = 250;


void setup() {
  size(500, 500);
  ellipseMode(RADIUS);
}

void draw() {
  background(255);
  fill (0, 175, 255);
  smooth ();
  noStroke();
  render();

}

void keyPressed() {
  if (key == CODED) {
    if (keyCode == LEFT) {
      x = x - 10;
      direction = -1;
      direction2 = 0;
    }
    else if (keyCode == RIGHT) {  
      x = x + 10;
      direction = 1;
      direction2 = 0;
    }
    else if (keyCode == UP) {
      y = y - 10;
      direction = 0;
      direction2 = -1;
    }
    else if (keyCode == DOWN) { 
      y = y + 10;
      direction = 0;
      direction2 = 1;
    }
  }
}


void render() {
  for ( int i=-1; i &lt; 2; i++) {
    for ( int j=-1; j &lt; 2; j++) {
      pushMatrix();
      translate(x + (i * width), y + (j*height));
      if ( direction == -1) { 
        rotate(PI);
      }
      if ( direction2 == 1) { 
        rotate(HALF_PI);
      }
      if ( direction2 == -1) { 
        rotate( PI + HALF_PI );
      }
      arc(0, 0, radius, radius, map((millis() % 500), 0, 500, 0, 0.52), map((millis() % 500), 0, 500, TWO_PI, 5.76) );
      popMatrix();
      // mouth movement //
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Trying to make PacMan and the Ghosts bounce around.</title>
      <link>https://forum.processing.org/two/discussion/24686/trying-to-make-pacman-and-the-ghosts-bounce-around</link>
      <pubDate>Sun, 22 Oct 2017 04:58:16 +0000</pubDate>
      <dc:creator>Silvestri78</dc:creator>
      <guid isPermaLink="false">24686@/two/discussions</guid>
      <description><![CDATA[<p>I'm having an issue where Processing is telling me that function move does not exist. I believe that this is linked to the other issue that I'm getting which is variable x and variable y do not exist. For the life of me, i am unable to see the issue. If any of you are able to show me what my issue is or even point me in the right direction I would be eternally grateful. Thank you for your time and advice. I apologize in advance there is a lot of code but I wasn't sure if the issue could be solved if I only posted bits and pieces.</p>

<pre><code>Ghost Blinky;
Ghost Inky; 
Ghost Pinky;
Ghost Clyde;

Pac Man;


void setup() {
  size(800, 800);
  smooth();

  Blinky = new Ghost(color(255, 0, 0), 0, 60, 2, 1); 
  Inky = new Ghost(color(0, 233, 252), 0, 60, 3, 2);
  Pinky = new Ghost(color(248, 0, 252), 0, 60, 1, 3);
  Clyde = new Ghost(color(252, 80, 0), 0, 60, 2, 4);

  Man = new Pac(color(254, 255, 8), 0, 60, 3, 1);
}

void draw() {
  background(255);
  Blinky.move();
  Blinky.display();
  Inky.move();
  Inky.display();
  Pinky.display();
  Pinky.move();
  Clyde.display();
  Clyde.move();

  Man.display();
  Man.move1();
}


class Ghost { 
  color c;
  float x = 80;
  float y = 60;
  float speedX;
  float speedY;


  Ghost(color vC, float Xpos, float Ypos, float Xspeed, float Yspeed) { 
    c = vC;
    x = Xpos;
    y = Ypos;
    speedX = Xspeed;
    speedY = Yspeed;
  }
}


class Pac {
  color b;
  float xX = 80;
  float yY = 60;
  float speedX;
  float speedY;

  Pac(color cB, float Xpos, float Ypos, float Xspeed, float Yspeed) { 
    b = cB;
    xX = Xpos;
    yY = Ypos;
    speedX = Xspeed;
    speedY = Yspeed;
  }
}

void display() {

  fill(c);

  // Ghost Body
  beginShape();
  vertex(x - 20, y - 50);
  vertex(x - 20, y - 40);
  vertex(x - 30, y - 40);
  vertex(x - 30, y - 30);
  vertex(x - 40, y - 30);
  vertex(x - 40, y - 25);
  vertex(x - 50, y - 25);
  vertex(x - 50, y - 13);
  vertex(x - 55, y - 13);
  vertex(x - 55, y + 51);
  vertex(x - 47, y + 51);
  vertex(x - 47, y + 60);
  vertex(x - 35, y + 60);
  vertex(x - 35, y + 51);
  vertex(x - 25, y + 51);
  vertex(x - 25, y + 43);
  vertex(x - 20, y + 43);
  vertex(x - 20, y + 51);
  vertex(x - 10, y + 51);
  vertex(x - 10, y + 60);
  vertex(x + 5, y + 60);
  vertex(x + 5, y + 51);
  vertex(x + 10, y + 51);
  vertex(x + 10, y + 43);
  vertex(x + 20, y + 43);
  vertex(x + 20, y + 51);
  vertex(x + 25, y + 51);
  vertex(x + 25, y + 60);
  vertex(x + 40, y + 60);
  vertex(x + 40, y + 51);
  vertex(x + 45, y + 51);
  vertex(x + 45, y);
  vertex(x + 40, y);
  vertex(x + 40, y - 10);
  vertex(x + 35, y - 10);
  vertex(x + 35, y - 30);
  vertex(x + 30, y - 30);
  vertex(x + 30, y - 40);
  vertex(x + 20, y - 40);
  vertex(x + 20, y - 50);
  vertex(x - 20, y - 50);
  endShape();

  fill(255, 255, 255);

  // Right EYE
  beginShape();
  vertex(x + 30, y - 40);
  vertex(x + 20, y - 40);
  vertex(x + 20, y - 30);
  vertex(x + 10, y - 30);
  vertex(x + 10, y - 10);
  vertex(x + 20, y - 10);
  vertex(x + 20, y);
  vertex(x + 30, y);
  vertex(x + 30, y - 10);
  vertex(x + 35, y- 10);
  vertex(x + 35, y - 30);
  vertex(x + 30, y - 30);
  vertex(x + 30, y - 40);
  endShape(); 

  fill(255, 255, 255);

  //LEFT EYE
  beginShape();
  vertex(x - 10, y - 30);
  vertex(x - 20, y - 30);
  vertex(x - 20, y - 40);
  vertex(x - 30, y - 40);
  vertex(x - 30, y - 30);
  vertex(x - 40, y - 30);
  vertex(x - 40, y - 10);
  vertex(x - 30, y - 10);
  vertex(x - 30, y);
  vertex(x - 20, y);
  vertex(x - 20, y - 10);
  vertex(x - 10, y - 10);
  vertex(x - 10, y - 30);
  endShape();

  fill(0, 0, 0);

  // LEFT PUPIL
  beginShape();
  vertex(x - 10, y - 30);
  vertex(x - 20, y - 30);
  vertex(x - 20, y - 20);
  vertex(x - 10, y - 20);
  vertex(x - 10, y - 30);
  endShape();

  fill(0, 0, 0);

  //RIGHT PUPIL
  beginShape();
  vertex(x + 35, y - 30);
  vertex(x + 25, y - 30);
  vertex(x + 25, y - 20);
  vertex(x + 35, y - 20);
  vertex(x + 35, y - 30);
  endShape();


  // Pac Man
  fill(230, 247, 5);

  beginShape();
  vertex(xX + 48, yY);
  vertex(xX + 48, yY - 10);
  vertex(xX + 42, yY - 10);
  vertex(xX + 42, yY - 15);
  vertex(xX + 36, yY - 15);
  vertex(xX + 36, yY - 23);
  vertex(xX + 25, yY - 23);
  vertex(xX + 25, yY - 30);
  vertex(xX - 29, yY - 30);
  vertex(xX - 29, yY - 22);
  vertex(xX - 37, yY - 22);
  vertex(xX - 37, yY - 15);
  vertex(xX - 45, yY - 15);
  vertex(xX - 45, yY - 7);
  vertex(xX - 55, yY - 7);
  vertex(xX - 55, yY + 2);
  vertex(xX - 61, yY + 2);
  vertex(xX - 61, yY + 60);
  vertex(xX - 55, yY + 60);
  vertex(xX - 55, yY + 70);
  vertex(xX - 47, yY + 70);
  vertex(xX - 47, yY + 75);
  vertex(xX - 40, yY + 75);
  vertex(xX - 40, yY + 85);
  vertex(xX - 29, yY + 85);
  vertex(xX - 29, yY + 95);
  vertex(xX + 25, yY + 95);
  vertex(xX + 25, yY + 85);
  vertex(xX + 30, yY + 85);
  vertex(xX + 30, yY + 75);
  vertex(xX + 43, yY + 75);
  vertex(xX + 43, yY + 68);
  vertex(xX + 48, yY + 68);
  vertex(xX + 48, yY + 60);
  vertex(xX + 35, yY + 60);
  vertex(xX + 35, yY + 50);
  vertex(xX + 20, yY + 50);
  vertex(xX + 20, yY + 43);
  vertex(xX + 10, yY + 43);
  vertex(xX + 10, yY + 35);
  vertex(xX - 5, yY + 35);
  vertex(xX - 5, yY + 25);
  vertex(xX + 10, yY + 25);
  vertex(xX + 10, yY + 18);
  vertex(xX + 20, yY + 18);
  vertex(xX + 20, yY + 8);
  vertex(xX + 30, y + 8);
  vertex(xX + 30, yY);
  vertex(xX + 48, yY);
  endShape();


  // Power Pellet

  fill(255);
  beginShape();
  vertex(xX + 90, yY + 20);
  vertex(xX + 80, yY + 20);
  vertex(xX + 80, yY + 30);
  vertex(xX + 70, yY + 30);
  vertex(xX + 70, yY + 40);
  vertex(xX + 80, yY + 40);
  vertex(xX + 80, yY + 50);
  vertex(xX + 90, yY + 50);
  vertex(xX + 90, yY + 40);
  vertex(xX + 100, yY + 40);
  vertex(xX + 100, yY + 30);
  vertex(xX + 90, yY + 30);
  vertex(xX + 90, yY + 20);

  endShape();
}

void move() {
  x = x + speedX;
  y = y + speedY;

  // SETS THE BOUNDARIES for Ghosts

  if ( x &gt; width)
  {
    speedX = - speedX;
  } else if ( x &lt; 1)
  {
    speedX = - speedX;
  } else if (  y &gt; height)
  {
    speedY = - speedY;
  } else if ( y &lt; 1)
  {
    speedY = - speedY;
  }
}


void move1() {
  xX = xX + speedX;
  yY = yY + speedY;

  // SETS THE BOUNDARIES for Ghosts

  if ( xX &gt; width)
  {
    speedX = - speedX;
  } else if ( xX &lt; 1)
  {
    speedX = - speedX;
  } else if (  yY &gt; height)
  {
    speedY = - speedY;
  } else if ( yY &lt; 1)
  {
    speedY = - speedY;
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Making a pacman and having a hard time with collisions</title>
      <link>https://forum.processing.org/two/discussion/23670/making-a-pacman-and-having-a-hard-time-with-collisions</link>
      <pubDate>Tue, 01 Aug 2017 21:01:08 +0000</pubDate>
      <dc:creator>NaZeta</dc:creator>
      <guid isPermaLink="false">23670@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I started a few months ago using processing and I'm also new to OOP. Now I'm doing a pacman, still have to code the ghosts and the pacman's food but I'm having problems with the walls. I've tried looking at other pacman codes so I know there are many ways to check collisions but I can't make it work on my code. I've also checked the jeffreythompson.org web but I still have problems.
To make it short I would like to know, how do I check the collisions? where is a the "right" place to check the collisions, map or pac? And since I'm new to code, if my logic or format is not good and wanna point that out, I'll be happy to learn. Thanks!</p>

<p>The map1 class</p>

<pre><code>class map1 {
  int SIDE = 30; //How big is the rectangle (30x30)
  PImage tile;
  char[][] map = {
  //Where X is a rectangle will be drawn. 
  //1,2,3 and 4 are for portals (which I didn't code yet). 
  //The A is an empty spot, seems like I can't leave the array empty so I filled it with A

    {'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', '1', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'X', 'X', 'X', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '2', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', ' ', 'X', ' ', 'X', 'X', 'X', 'X', 'X', ' ', 'X', 'X', 'X', ' ', 'X', 'X', 'X', ' ', 'X', 'X', 'X', ' ', 'X', 'X', 'X', 'X', 'X', ' ', 'X', ' ', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', ' ', 'X', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'X', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'X', ' ', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', ' ', 'X', ' ', 'X', 'X', 'X', ' ', 'X', ' ', 'X', 'X', ' ', 'X', ' ', ' ', ' ', 'X', ' ', 'X', 'X', ' ', 'X', ' ', 'X', 'X', 'X', ' ', 'X', ' ', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', ' ', 'X', ' ', ' ', ' ', ' ', ' ', 'X', ' ', 'X', 'X', ' ', 'X', 'X', 'X', 'X', 'X', ' ', 'X', 'X', ' ', 'X', ' ', ' ', ' ', ' ', ' ', 'X', ' ', 'X', 'X', 'X', 'X', 'X', 'X', 'X'}, 
    {'X', ' ', ' ', ' ', 'X', 'X', ' ', 'X', 'X', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'X', 'X', ' ', 'X', 'X', ' ', ' ', ' ', 'P', 'x', 'x', 'x', 'x', 'x', 'p'}, 
    {'X', ' ', 'X', ' ', 'X', 'X', ' ', 'X', 'X', ' ', 'X', ' ', 'X', 'X', 'X', ' ', 'X', 'X', 'X', ' ', 'X', ' ', 'X', 'X', ' ', 'X', 'X', ' ', 'X', ' ', 'X', 'X', 'X', 'X', 'X', 'X', 'X'}, 
    {'X', ' ', 'X', ' ', 'X', 'X', ' ', 'X', 'X', ' ', 'X', ' ', 'X', 'X', 'X', ' ', 'X', 'X', 'X', ' ', 'X', ' ', 'X', 'X', ' ', 'X', 'X', ' ', 'X', ' ', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', ' ', 'X', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'X', ' ', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', ' ', 'X', ' ', 'X', 'X', ' ', 'X', 'X', 'X', ' ', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', ' ', 'X', 'X', 'X', ' ', 'X', 'X', ' ', 'X', ' ', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', ' ', ' ', ' ', 'X', 'X', ' ', ' ', ' ', ' ', ' ', 'X', 'X', 'x', 'x', 'x', 'x', 'x', 'X', 'X', ' ', ' ', ' ', ' ', ' ', 'X', 'X', ' ', ' ', ' ', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', ' ', 'X', ' ', 'X', 'X', ' ', 'X', 'X', 'X', ' ', ' ', 'X', 'X', 'X', 'x', 'X', 'X', 'X', ' ', ' ', 'X', 'X', 'X', ' ', 'X', 'X', ' ', 'X', ' ', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', ' ', 'X', ' ', ' ', ' ', ' ', ' ', ' ', 'X', 'X', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'X', 'X', ' ', ' ', ' ', ' ', ' ', ' ', 'X', ' ', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', ' ', 'X', ' ', 'X', ' ', 'X', 'X', ' ', 'X', 'X', ' ', 'X', 'X', 'X', 'X', 'X', 'X', 'X', ' ', 'X', 'X', ' ', 'X', 'X', ' ', 'X', ' ', 'X', ' ', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', ' ', 'X', ' ', ' ', ' ', 'X', 'X', ' ', 'X', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'X', ' ', 'X', 'X', ' ', ' ', ' ', 'X', ' ', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', ' ', ' ', ' ', 'X', ' ', ' ', 'X', ' ', ' ', ' ', 'X', ' ', 'X', 'X', ' ', 'X', 'X', ' ', 'X', ' ', ' ', ' ', 'X', ' ', ' ', 'X', ' ', ' ', ' ', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', ' ', 'X', ' ', 'X', 'X', ' ', ' ', ' ', 'X', 'X', 'X', ' ', 'X', ' ', ' ', ' ', 'X', ' ', 'X', 'X', 'X', ' ', ' ', ' ', 'X', 'X', ' ', 'X', ' ', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', ' ', 'X', ' ', 'X', 'X', 'X', 'X', ' ', ' ', ' ', ' ', ' ', 'X', ' ', 'X', ' ', 'X', ' ', ' ', ' ', ' ', ' ', 'X', 'X', 'X', 'X', ' ', 'X', ' ', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', ' ', 'X', ' ', ' ', ' ', ' ', ' ', ' ', 'X', 'X', 'X', ' ', ' ', ' ', 'X', ' ', ' ', ' ', 'X', 'X', 'X', ' ', ' ', ' ', ' ', ' ', ' ', 'X', ' ', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', ' ', 'X', ' ', 'X', 'X', 'X', 'X', ' ', 'X', 'X', 'X', 'X', ' ', 'X', 'X', 'X', ' ', 'X', 'X', 'X', 'X', ' ', 'X', 'X', 'X', 'X', ' ', 'X', ' ', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', '3', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'X', 'X', 'X', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '4', 'X', 'A', 'A', 'A', 'A', 'A', 'A'}, 
    {'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'X', 'A', 'A', 'A', 'A', 'A', 'A'} };

  map1() {

    tile = loadImage("tile.jpg");
  }

  void display() {

    for (int i = 0; i&lt;23; i++) {

      for (int j = 0; j&lt;37; j++) { 

        if (map[i][j]=='X') { 

          image(tile, j*SIDE, i*SIDE); 
        }
      }
    }
  }
}
</code></pre>

<p>Pac class</p>

<pre><code>class pac {

  int x, y, R, speed = 2;
  String TOUP, TODOWN, TOLEFT, TORIGHT, direction = "TORIGHT";

  pac() {
    x = 465;
    y = 405;
    R = 15; 
  }

  void display() {

    ellipse(x,y,R*2,R*2);
  }

  void move() {

    switch (direction) {

      case "TORIGHT":
          x+=speed;
      break;
      case "TOLEFT":
          x-=speed;
      break;
      case "TOUP":
          y-=speed;
      break;
      case "TODOWN":
          y+=speed;
      break;
      case "NOMOVE":
          //Stop moving if hits a wall
      break;      
    }

    if (keyCode == LEFT) {
      direction = "TOLEFT";
    }
    if (keyCode == RIGHT) {
      direction = "TORIGHT";
    }
    if (keyCode == DOWN) {
      direction = "TODOWN";
    }
    if (keyCode == UP) {
      direction = "TOUP";
    }

  }

  void collision() {


  }

}
</code></pre>

<p>How the game looks so far if helps, don't pay attention to the numbers, I was just trying to make collisions work.
<img src="https://puu.sh/wZ2tr/7151b4a2f1.png" alt="" /></p>
]]></description>
   </item>
   <item>
      <title>Continuous movement?</title>
      <link>https://forum.processing.org/two/discussion/23128/continuous-movement</link>
      <pubDate>Mon, 19 Jun 2017 06:17:32 +0000</pubDate>
      <dc:creator>jenn184</dc:creator>
      <guid isPermaLink="false">23128@/two/discussions</guid>
      <description><![CDATA[<p>Hi, so I'm making a version of Pacman where you play as the ghosts instead of Pacman, and your goal is to try and catch Pacman. My problem right now is that when you press the arrow keys to move, the ghost will move over 1 cell on the grid, but it won't go all the way to the end. So for example, how it should work is that if you are at the bottom left corner and you press the right arrow key, it should move to the right until it detects a wall. Right now, if I press the right arrow key, it would just move one space over and that's it. Any ideas why this is happening?</p>

<p>Here is some of the code: (I am not sure what is the issue so I just posted a section of the stuff I wrote, but let me know if you need more information/code.)</p>

<pre><code>  void setup() {
    size(448, 576);
    //size(448, 726);
    //surface.setResizable(true);
    background(255);
    mazeimg = loadImage("mazeimg.png");
    image(mazeimg, 0, 0);

  rectColor = color(0);
  rectHighlight = color(51);
  rectX = 0;
  rectY = 0;


    //////////System.out.println(start);
    int cols = 28;
    String[] lines = loadStrings("MainMaze.txt");
    //String[] mazeLines = new String[lines.length];
    maze = new Location[36][28];

    for (int r = 0; r &lt; lines.length; r ++) { 
      for (int c = 0; c &lt; lines[0].length(); c ++) { 
        //////////System.out.println("row: " + r + " col: " + c);
        if (lines[r].charAt(c) == '0') { 
          maze[r][c] = new Wall (r, c); 
        } else {
          maze[r][c] = new EmptySpace(r,c); 
        }
        }
      }
      int x1 = 0, y1 = 0; 
      int c;
      for (int r = 0; r &lt; maze.length; r ++) {
        for (c =  0; c &lt; maze[r].length; c ++) { 
          y1 = (width / 28) * r; //+75;
          x1 = (height / 36) * c; 
          if (!maze[r][c].isValid()) { // if it's wall
            noFill();
            rect (x1, y1, (width/ 28), (height/36));
          } 
          else if (maze[r][c].isValid()){ // if it's an open space
          //////////System.out.println ("x: " + r + " y: " + c);

            fill(#000000); 
            //noStroke(); (add this in later when we're done)
            rect (x1, y1, (width/ 28), (height/36));
            // for tiny dots


          }
        }   
      }

    pac = new Pacman (); 
    locPac = maze[pac.getR()][pac.getC()]; 
    ellipse (pac.xPixel(), pac.yPixel() , 16, 16);

    redd = new RedGhost("red");
    locRed = maze[redd.getR()][redd.getC()]; 
    redd.moveTo(maze[16][12]);
    ellipse ( redd.xPixel() , redd.yPixel(), 16, 16);


    pink = new RedGhost("pink");
    locPink = maze[pink.getR()][pink.getC()]; 
    pink.moveTo(maze[16][15]);
     ellipse (pink.xPixel() , pink.yPixel(), 16, 16);

    blue = new RedGhost("blue");
    locBlue = maze[blue.getR()][blue.getC()]; 
    blue.moveTo(maze[18][12]);
    ellipse ( blue.xPixel() , blue.yPixel(), 16, 16);

    orange = new RedGhost("orange");
    locOrange = maze[orange.getR()][orange.getC()]; 
    orange.moveTo(maze[18][15]);
     ellipse (orange.xPixel() , orange.yPixel(), 16, 16);

     n = redd;

  }

  void draw() {

    //////////System.out.println (n);
     a++; 


    if (called &amp;&amp; a == 40) { 
      //System.out.println (true);
      redd.moveRandom(); 
         pink.moveRandom(); 
         blue.moveRandom(); 
         orange.moveRandom();
         called = false;
    } 

    update(mouseX, mouseY);
    if (rectOver) {
    fill(rectHighlight);
     } else {
    fill(rectColor);
  }
  stroke(255);
  rect(rectX, rectY, rectSize, rectSize);


    color col = color(0, 255, 0);
    fill(col);
    noStroke();
    y = locPac.getR() * (width / 28) + 16;
    x = locPac.getC() * (height/ 36) + 8;
      background (0); 



    background(255);
    mazeimg = loadImage("mazeimg.png");
    image(mazeimg, 0, 0);
    for (int r = 0; r &lt; maze.length; r ++) { 
      for (int c = 0; c &lt; maze[r].length; c ++) { 
        if (maze[r][c].isValid() &amp;&amp; maze[r][c].hasDot()){ 
           fill(#FFEC00);
              noStroke();
              ellipse(maze[r][c].xPixel(), maze[r][c].yPixel(), 8, 8);

        } 
        }


         rectColor = color(#000000 );
  rectHighlight = color(51);
  rectX = 0;
  rectY = 0;
    fill (color(0,255,0));
    locPac = maze[pac.getR()][pac.getC()]; 
    ellipse (pac.xPixel() , pac.yPixel() , 16, 16);


    fill (color(255,0,0));
    locRed= maze[redd.getR()][redd.getC()]; 
    ellipse (redd.xPixel(), redd.yPixel(), 16, 16);


    fill (#FFC0CB) ;
    locPink = maze[pink.getR()][pink.getC()];
    ellipse (pink.xPixel(), pink.yPixel(), 16, 16);


    fill(#0000FF);
    locBlue = maze[blue.getR()][blue.getC()]; 
    ellipse (blue.xPixel(), blue.yPixel(), 16, 16);

    fill (#FFA500) ;
    locOrange = maze[orange.getR()][orange.getC()]; 
    ellipse (orange.xPixel(), orange.yPixel(), 16, 16);

   }

  if (locRed.equals(locPac) || locBlue.equals(locPac) || locOrange.equals(locPac) || locPink.equals(locPac)){ 
    background(0);
    println("game over: " + pac.score + " points earned");
    noLoop();
    try {
        Thread.sleep(1000);
    } catch (Exception e) {exit();}
    exit();
      } 

        }

void update(int x, int y) {
  if ( overRect(rectX, rectY, rectSize, rectSize) ) {
    rectOver = true;
  } else {
    rectOver = false;
  }
}

void mousePressed() {

  if (rectOver) {
    draw(); 
  }
}

boolean overRect(int x, int y, int width, int height)  {
  if (mouseX &gt;= x &amp;&amp; mouseX &lt;= x+width &amp;&amp; 
      mouseY &gt;= y &amp;&amp; mouseY &lt;= y+height) {
    return true;
  } else {
    return false;
  }
}

      void keyPressed() {

      // 1 = red, 2 = pink, 3 =  orange, 4 = blue;

      if (key == '1') { 

        n = redd; 
      } else if (key == '2') { 
        n = pink; 
      } else if (key == '3') { 
        n = orange;       
      } else if (key == '4') { 
        n = blue;
      } 

      locN = maze[n.getR()][n.getC()];
      ////////System.out.println(locN);

      //////////System.out.println(n.getLocation());
        if (key == CODED) {

      if (keyCode == UP) {

        if (n.getR() &gt; 0 &amp;&amp; maze[n.getR() -1][n.getC()].isValid()) 

        locN = maze[n.getR()- 1][n.getC()];
        ////////System.out.println(locN);
            //////////System.out.println(n.getLocation());
      } else if (keyCode == DOWN) {
        if (n.getR() &lt; 35 &amp;&amp; maze[n.getR() + 1][n.getC()].isValid()) 
        locN = maze[n.getR()+1][n.getC()];
            //////////System.out.println(n.getLocation());
      } else if (keyCode == RIGHT) { 
        if (n.getC() &lt; 27 &amp;&amp; maze[n.getR()][n.getC() + 1].isValid()) { 
          //////////System.out.println ("true");
        locN = maze[n.getR()][n.getC() + 1];
            //////////System.out.println(n.getLocation());
        }
        //////////System.out.println ("false");
      } else if (keyCode == LEFT) { 
        if (n.getC() &gt; 0 &amp;&amp; maze[n.getR()][n.getC() - 1].isValid()) 
        locN = maze[n.getR()][n.getC() - 1];
            //////////System.out.println(n.getLocation());
      }

           ArrayList&lt;Location&gt; neighbors = new ArrayList&lt;Location&gt;();
     neighbors.clear();

      for (int i = 0; i &lt; xShift.length; i ++) { 
         if(pac.getR() + xShift[i] &gt; 0 &amp;&amp; pac.getR() + xShift[i] &lt; 36 &amp;&amp; pac.getC() + yShift[i] &gt; 0 &amp;&amp; pac.getC() + yShift[i] &lt; 28) { 
         if ( maze[pac.getR() + xShift[i]][pac.getC() + yShift[i]].isValid()) { 
           neighbors.add(maze[pac.getR() + xShift[i]][pac.getC() + yShift[i]]); 
         } 
         }
      }


      for (Location n: neighbors) {

         int reddist= n.computeShortestPath(redd.getLocation()); 
         int pinkdist = n.computeShortestPath(pink.getLocation()); 
         int bluedist = n.computeShortestPath(blue.getLocation());
         int orangedist = n.computeShortestPath(orange.getLocation()); 

        n.setAvgDist((reddist + pinkdist + bluedist +orangedist)/5);
      }

       java.util.Collections.sort(neighbors);

       //for (Location local: neighbors) { 
         Location target = neighbors.get(0);

        for (Location n: neighbors) {
            if (locPac.hasDot()) { 

      locPac.setDot(new Dot("empty")); 
         pac.moveTo(n);
        }
        }
        n.moveTo(maze[locN.getR()][locN.getC()]);
        pac.setScore (pac.getScore() + 1);
        }
}
</code></pre>

<p>Our creature class looks like this:</p>

<pre><code>  abstract class  Creature {

  int r, c; 
  int xPixel () { 
      return c * 16  + 8;
    }
     int yPixel () { 
      return r * 16 + 8; 
    }  
  }
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to make Pacman eat dots?</title>
      <link>https://forum.processing.org/two/discussion/22951/how-to-make-pacman-eat-dots</link>
      <pubDate>Tue, 06 Jun 2017 03:59:31 +0000</pubDate>
      <dc:creator>SanchezLeslie</dc:creator>
      <guid isPermaLink="false">22951@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to make my pacman object eat the pac dots but i am not sure how to with my program help?</p>

<pre><code>public abstract class item
{
abstract void pacEatsDots();
}


public class Pacman extends item
{
  int x;
  int y;
  int radius = 15;
  int direction = 1;
  int direction2 = 0;

  public Pacman(int xn, int yn)
  {
    x = xn;
    y = yn;
  }

  void keyPressed() {//<a href="https://forum.processing.org/two/discussion/1573/spoof-of-pacman-game-for-project" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/1573/spoof-of-pacman-game-for-project</a>
    color white = color(255, 255, 255);
    color black = color(0, 0, 0);
    color c = pg.get(x+1, y);
    color d = pg.get(x, y+1);
    color e = pg.get(x-1, y);
    color f = pg.get(x, y-1);

    if (key == CODED)
    {
      if (e == white)
      {
        if (keyCode == LEFT) 
        {
          x = x - 2;
          direction = -1;
          direction2 = 0;
        }
      } 
      if ( c == white)
      {
        if (keyCode == RIGHT) 
        {  
          x = x + 2;
          direction = 1;
          direction2 = 0;
        }
      } 
       if ( f == white)
      {
         if (keyCode == UP) 
        {
          y = y - 2;
          direction = 0;
          direction2 = -1;
        }
      } 
      if ( d == white)
      {
         if (keyCode == DOWN) 
        { 
          y = y + 2;
          direction = 0;
          direction2 = 1;
        }
      }
    }
    render();
  }


  public void render() {//<a href="https://forum.processing.org/two/discussion/1573/spoof-of-pacman-game-for-project" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/1573/spoof-of-pacman-game-for-project</a>
    for ( int i=-1; i &lt; 2; i++) {
      for ( int j=-1; j &lt; 2; j++) {
        pushMatrix();
        translate(x +(i*width), y + (j*height) );
        if ( direction == -1) { 
          rotate(PI);
        }
        if ( direction2 == 1) { 
          rotate(HALF_PI);
        }
        if ( direction2 == -1) { 
          rotate( PI + HALF_PI );
        }

        arc(0, 0, radius*2.3, radius*2.3, map((millis() % 500), 0, 500, 0, 0.52), map((millis() % 500), 0, 500, TWO_PI, 5.76) );
        popMatrix();
        fill(255, 255, 0);
        // mouth movement //
      }
    }
  }




  void pacEatsDots()
  {

  }
  }



public class Dots  {
  float x, y;
  boolean isVisible;
  boolean on=true;
  Dots(float ix, float iy) {
    x = ix;
    y = iy;
    isVisible = true;
  }
  void display() {
    fill(#E5DA99);


    ellipse(x,y,12,12);


  }

  void displayBigDots()//<a href="https://processing.org/discourse/beta/num_1261323787.html" target="_blank" rel="nofollow">https://processing.org/discourse/beta/num_1261323787.html</a>
  {

  if(frameCount% 8== 0) {
    if(on)
  fill(255);
    else
  fill(0);
    on = !on;
  }
  ellipse(x,y,20,20);
  }
  //public void setup(
}

ArrayList&lt;Dots&gt; dots = new ArrayList();
Pacman pac;
PImage img;
PImage startscreen;
PGraphics pg;
boolean path = false;
Dots dotUpperLeftCorner;
Dots dotUpperRightCorner;
Dots dotLowerLeftCorner;
Dots dotLowerRightCorner;
void setup()
{
  background(0);

  size(723, 800);
  int y=40;
  int x = 40;
  dotUpperLeftCorner = new Dots(40, 40);
  dotUpperRightCorner = new Dots(683, 40);
  dotLowerLeftCorner = new Dots(40, 610);
  dotLowerRightCorner = new Dots(680,610);
  img = loadImage("psb2.jpg");
  pac = new Pacman(362, 610);
  pg = createGraphics(723, 800);

  for (int i =0; i&lt;28; i++)//long line left side
  {
    dots.add(new Dots(165, y+20)); 
    y+=23;
  }
  for(int i = 0;i&lt;5;i++)
  {
    dots.add(new Dots(x,y-645));
    y+=22;
  }
  for(int i = 0; i&lt;5;i++)
  {
    dots.add(new Dots(x,y-644));
    x+=26;
  }
  for(int i = 0;i&lt;11;i++)
  {
    dots.add(new Dots(x-110,y-755));
    x+=26;
  }
  for(int i = 0;i&lt;20;i++)
  {
    dots.add(new Dots(x-265,y-644));
    x+=26;
  }
   for(int i = 0;i&lt;3;i++)
  {
    dots.add(new Dots(x-935,y-620));
    y+=26;
  }
   for(int i = 0;i&lt;4;i++)
  {
    dots.add(new Dots(x-910,y-645.5));
    x+=26;
  }
  for(int i = 0;i&lt;3;i++)
  {
    dots.add(new Dots(x-837,y-695));
    y+=26;
  }
  for(int i = 0;i&lt;3;i++)
  {
    dots.add(new Dots(x-810,y-720));
    x+=26;
  }
  for(int i = 0;i&lt;3;i++)
  {
    dots.add(new Dots(x-760,y-720));
    x+=26;
  }
  for(int i = 0;i&lt;3;i++)
  {
    dots.add(new Dots(x-758,y-773));
    y+=26;
  }
  for(int i = 0;i&lt;5;i++)
  {
    dots.add(new Dots(x-837,y-990));
    y+=23;
  }
  for(int i = 0;i&lt;10;i++)
  {
    dots.add(new Dots(x-812,y-1105));
    x+=26;
  }
  for(int i = 0;i&lt;4;i++)
  {
    dots.add(new Dots(x-811,y-1080));
    y+=23;
  }
  for(int i = 0;i&lt;4;i++)
  {
    dots.add(new Dots(x-1175,y-1175));
    y+=23;
  }
  for(int i = 0;i&lt;3;i++)
  {
    dots.add(new Dots(x-811,y-1155));
    y+=26;
  }
  for(int i = 0;i&lt;4;i++)
  {
    dots.add(new Dots(x-915,y-1180));
    x+=26;
  }
  for(int i = 0;i&lt;4;i++)
  {
    dots.add(new Dots(x-1046,y-1345));
    y+=23;
  }
  for(int i = 0;i&lt;23;i++)
  {
    dots.add(new Dots(x-1044,y-1325));
    y+=23;
  }
  for(int i = 0;i&lt;5;i++)
  {
    dots.add(new Dots(x-1015,y-1500));
    x+=25;
  }
  for(int i = 0;i&lt;6;i++)
  {
    dots.add(new Dots(x-1320,y-1500));
    x+=25;
  }
  for(int i = 0;i&lt;3;i++)
  {
    dots.add(new Dots(x-1470,y-1480));
    y+=23;
  }
  for(int i = 0;i&lt;3;i++)
  {
    dots.add(new Dots(x-1555,y-1550));
    y+=23;
  }
  for(int i = 0;i&lt;6;i++)
  {
    dots.add(new Dots(x-1685,y-1638));
    x+=26;
  }
  for(int i = 0;i&lt;5;i++)
  {
    dots.add(new Dots(x-1990,y-1638));
    x+=26;
  }
  for(int i = 0;i&lt;14;i++)
  {
    dots.add(new Dots(x-1970,y-1554));
    x+=26;
  }
  for(int i = 0;i&lt;2;i++)
  {
   dots.add(new Dots(x-2484,y-1610));
    y+=26;
  }
  for(int i = 0;i&lt;2;i++)
  {
    dots.add(new Dots(x-2460,y-1604));
    x+=26;
  }
  for(int i = 0;i&lt;2;i++)
  {
   dots.add(new Dots(x-2485,y-1580));
    y+=26;
  }
  for(int i = 0;i&lt;5;i++)
  {
    dots.add(new Dots(x-2535,y-1585));
    x+=26;
  }
  for(int i = 0;i&lt;2;i++)
  {
   dots.add(new Dots(x-2665,y-1560));
    y+=26;
  }
  for(int i = 0;i&lt;26;i++)
  {
    dots.add(new Dots(x-2665,y-1565));
    x+=26;
  }
  for(int i = 0;i&lt;3;i++)
  {
   dots.add(new Dots(x-2692,y-1635));
    y+=26;
  }
  for(int i = 0;i&lt;2;i++)
  {
   dots.add(new Dots(x-2978,y-1695));
    y+=26;
  }
  for(int i = 0;i&lt;2;i++)
  {
   dots.add(new Dots(x-3065,y-1745));
    y+=26;
  }
  for(int i = 0;i&lt;3;i++)
  {
    dots.add(new Dots(x-2976,y-1818));
    x+=26;
  }
  for(int i = 0;i&lt;3;i++)
  {
    dots.add(new Dots(x-3196,y-1820));
    x+=26;
  }
  for(int i = 0;i&lt;3;i++)
  {
   dots.add(new Dots(x-3063,y-1870));
    y+=26;
  }
  for(int i = 0;i&lt;3;i++)
  {
   dots.add(new Dots(x-3294,y-1950));
    y+=26;
  }
  for(int i = 0;i&lt;3;i++)
  {
   dots.add(new Dots(x-2910,y-2047));
    y+=26;
  }
  for(int i = 0;i&lt;4;i++)
  {
    dots.add(new Dots(x-2964,y-2050));
    x+=28;
  }
  for(int i = 0;i&lt;1;i++)
  {
    dots.add(new Dots(x-2994,y-2126));
    x+=28;
  }
  for(int i = 0;i&lt;2;i++)
  {
   dots.add(new Dots(x-2995,y-2180));
    y+=28;
  }

}



void draw()
{
  stroke(0);
  image(img, 0, 0);
  fill(255);
  pg.beginDraw();
  pg.background(0);
  pg.stroke(255);
  pg.strokeWeight(21.0);
  pg.line(40, 40, 40, 225);//pathway
  pg.line(40, 225, 165, 225);//pathway
  pg.line(40, 40, 325, 40);//pathway
  pg.line(165, 40, 165, 685);
  pg.line(165, 685, 40, 685);
  pg.line(40, 685, 40, 755);
  pg.line(40, 755, 690, 755);
  pg.line(690, 755, 690, 685);
  pg.line(690, 685, 560, 685);
  pg.line(560, 685, 560, 40);
  pg.line(400, 40, 690, 40);
  pg.line(400, 40, 400, 145);
  pg.line(690, 40, 690, 145);
  pg.line(690, 145, 40, 145);
  pg.line(325, 40, 325, 145);
  pg.line(245, 145, 245, 225);
  pg.line(245, 225, 320, 225);
  pg.line(320, 225, 320, 300);
  pg.line(250, 300, 480, 300);
  pg.line(250, 300, 250, 375);
  pg.line(480, 300, 480, 375);
  pg.line(480, 375, 800, 375);
  pg.line(250, 375, 0, 375);
  pg.line(250, 375, 250, 525);
  pg.line(40, 525, 320, 525);
  pg.line(40, 525, 40, 610);
  pg.line(320, 525, 320, 610);
  pg.line(320, 610, 165, 610);
  pg.line(40, 610, 90, 610);
  pg.line(90, 610, 90, 685);
  pg.line(320, 610, 560, 610);
  pg.line(475, 610, 475, 685);
  pg.line(475, 685, 405, 685);
  pg.line(405, 685, 405, 755);
  pg.line(320, 755, 320, 680);
  pg.line(320, 680, 250, 680);
  pg.line(250, 680, 250, 610);
  pg.line(400, 610, 400, 525);
  pg.line(400, 525, 680, 525);
  pg.line(680, 525, 680, 610);
  pg.line(680, 610, 630, 610);
  pg.line(630, 610, 630, 685);
  pg.line(480, 375, 480, 525);
  pg.line(480, 455, 250, 455);
  pg.line(400, 300, 400, 225);
  pg.line(400, 225, 480, 225);
  pg.line(480, 225, 480, 145);
  pg.line(690, 145, 690, 220);
  pg.line(690, 220, 560, 220);
  pg.endDraw();
 //image(pg, 0, 0);


  for (int i =0; i&lt;dots.size (); i++)
  {
    dots.get(i).display();
  }

  dotUpperLeftCorner.displayBigDots();
  dotUpperRightCorner.displayBigDots();
  dotLowerLeftCorner.displayBigDots();
  dotLowerRightCorner.displayBigDots();
  pac.keyPressed();

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to make an object follow a pathway created by preset lines?</title>
      <link>https://forum.processing.org/two/discussion/22908/how-to-make-an-object-follow-a-pathway-created-by-preset-lines</link>
      <pubDate>Sat, 03 Jun 2017 23:49:30 +0000</pubDate>
      <dc:creator>SanchezLeslie</dc:creator>
      <guid isPermaLink="false">22908@/two/discussions</guid>
      <description><![CDATA[<p>I am making pacman and i used an image(its the pacman maze) as background and i made a pathway out of lines, is there a way to make the pacman object follow the path of lines?</p>

<pre><code>//Here is the code in my void setup and draw tab
    Pacman pac;
    PImage img;
    PImage startscreen;
    float x = 250.0;
    float y = 250.0;
    int direction = 1;
    int direction2 = 0;
    int radius = 15;



    void setup()
    {
      background(0);
      size(723, 800);
      pac = new Pacman(100, 200);
    }

    void draw()
    {
      // startscreen = loadImage("startscreen2.jpg");
      img = loadImage("psb2.jpg");
      stroke(0);
      image(img, 0, 0);
      pac.display();
      render();
      stroke(255);
      strokeWeight(3.0);
      line(40, 40, 40, 225);//pathway
      line(40, 225, 165, 225);//pathway
      line(40, 40, 325, 40);//pathway
      line(165, 40, 165, 685);
      line(165, 685, 40, 685);
      line(40, 685, 40, 755);
      line(40, 755, 690, 755);
      line(690, 755, 690, 685);
      line(690, 685, 560, 685);
      line(560, 685, 560, 40);
      line(400, 40, 690, 40);
      line(400, 40, 400, 145);
      line(690, 40, 690, 145);
      line(690, 145, 40, 145);
      line(325, 40, 325, 145);
      line(245, 145, 245, 225);
      line(245, 225, 320, 225);
      line(320, 225, 320, 300);
      line(250, 300, 480, 300);
      line(250, 300, 250, 375);
      line(480, 300, 480, 375);
      line(480, 375, 800, 375);
      line(250, 375, 0, 375);
      line(250, 375, 250, 525);
      line(40, 525, 320, 525);
      line(40, 525, 40, 610);
      line(320, 525, 320, 610);
      line(320, 610, 165, 610);
      line(40, 610, 90, 610);
      line(90, 610, 90, 685);
      line(320, 610, 560, 610);
      line(475, 610, 475, 685);
      line(475, 685, 405, 685);
      line(405, 685, 405, 755);
      line(320, 755, 320, 680);
      line(320, 680, 250, 680);
      line(250, 680, 250, 610);
      line(400, 610, 400, 525);
      line(400, 525, 680, 525);
      line(680, 525, 680, 610);
      line(680, 610, 630, 610);
      line(630, 610, 630, 685);
      line(480, 375, 480, 525);
      line(480, 455, 250, 455);
      line(400, 300, 400, 225);
      line(400, 225, 480, 225);
      line(480, 225, 480, 145);
      line(690, 145, 690, 220);
      line(690, 220, 560, 220);
    }




    void keyPressed() {//<a href="https://forum.processing.org/two/discussion/1573/spoof-of-pacman-game-for-project" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/1573/spoof-of-pacman-game-for-project</a>
      if (key == CODED) {
        if (keyCode == LEFT) {
          x = x - 10;
          direction = -1;
          direction2 = 0;
        } else if (keyCode == RIGHT) {  
          x = x + 10;
          direction = 1;
          direction2 = 0;
        } else if (keyCode == UP) {
          y = y - 10;
          direction = 0;
          direction2 = -1;
        } else if (keyCode == DOWN) { 
          y = y + 10;
          direction = 0;
          direction2 = 1;
        }
      }
    }


    void render() {//<a href="https://forum.processing.org/two/discussion/1573/spoof-of-pacman-game-for-project" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/1573/spoof-of-pacman-game-for-project</a>
      for ( int i=-1; i &lt; 2; i++) {
        for ( int j=-1; j &lt; 2; j++) {
          pushMatrix();
          translate(x + (i * width), y + (j*height));
          if ( direction == -1) { 
            rotate(PI);
          }
          if ( direction2 == 1) { 
            rotate(HALF_PI);
          }
          if ( direction2 == -1) { 
            rotate( PI + HALF_PI );
          }
          arc(0, 0, radius, radius, map((millis() % 500), 0, 500, 0, 0.52), map((millis() % 500), 0, 500, TWO_PI, 5.76) );
          popMatrix();
          // mouth movement //
        }
      }
    }


//***here is my pacman class
    public class Pacman  
    {
      float x;
      float y;
      int radius = 15;
      int direction = 1;
      int direction2 = 0;

      public Pacman(float xn, float xy)
      {
        x = xn;
        y = xy;
      }

      public void display()
      {
        //yellow circle
        ellipseMode(RADIUS);//<a href="https://forum.processing.org/two/discussion/1573/spoof-of-pacman-game-for-project" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/1573/spoof-of-pacman-game-for-project</a>
        smooth();
        noStroke();
        fill(255, 255, 0);
      }
    }

public interface Game
{
  public void move();
}

public class Enemies implements Game 
{
  public void move()
  {
  }

}

public abstract class Item 
{

}
</code></pre>

<p>Any help would be great thanks!!</p>
]]></description>
   </item>
   <item>
      <title>Making pacman how to create dots and have pacman eat them?</title>
      <link>https://forum.processing.org/two/discussion/22928/making-pacman-how-to-create-dots-and-have-pacman-eat-them</link>
      <pubDate>Mon, 05 Jun 2017 01:55:41 +0000</pubDate>
      <dc:creator>SanchezLeslie</dc:creator>
      <guid isPermaLink="false">22928@/two/discussions</guid>
      <description><![CDATA[<p>I am making Pacman for class and i am trying to make the dots that pacman has to eat but im not sure how to make the dots and how he is suppose to eat them, please help!!</p>

<pre><code>public abstract class Item 
{
  public void pacEatsDots();

}

public class Pacman extends Item
{
  int x;
  int y;
  int radius = 15;
  int direction = 1;
  int direction2 = 0;

  public Pacman(int xn, int yn)
  {
    x = xn;
    y = yn;
  }

void keyPressed() {//<a href="https://forum.processing.org/two/discussion/1573/spoof-of-pacman-game-for-project" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/1573/spoof-of-pacman-game-for-project</a>
  if (key == CODED) {
    if (keyCode == LEFT) {
      x = x - 5;
      direction = -1;
      direction2 = 0;
    } else if (keyCode == RIGHT) {  
      x = x + 5;
      direction = 1;
      direction2 = 0;
    } else if (keyCode == UP) {
      y = y - 5;
      direction = 0;
      direction2 = -1;
    } else if (keyCode == DOWN) { 
      y = y + 5;
      direction = 0;
      direction2 = 1;
    }
  }
}


  public void render() {//<a href="https://forum.processing.org/two/discussion/1573/spoof-of-pacman-game-for-project" target="_blank" rel="nofollow">https://forum.processing.org/two/discussion/1573/spoof-of-pacman-game-for-project</a>
  for ( int i=-1; i &lt; 2; i++) {
    for ( int j=-1; j &lt; 2; j++) {
      pushMatrix();
      translate(x + (i * width), y + (j*height));
      if ( direction == -1) { 
        rotate(PI);
      }
      if ( direction2 == 1) { 
        rotate(HALF_PI);
      }
      if ( direction2 == -1) { 
        rotate( PI + HALF_PI );
      }
      arc(0, 0, radius*2, radius*2, map((millis() % 500), 0, 500, 0, 0.52), map((millis() % 500), 0, 500, TWO_PI, 5.76) );
      popMatrix();
      fill(255, 255, 0);
      // mouth movement //
    }
  }
  }

  public void checkPixelsPacman()
  {
    color white = color(255, 255, 255);
    color black = color(0,0,0);
    color c = pg.get(x,y);
    if (c==white) {
      pac.keyPressed();
      pac.render();
    }
    else if(c == black)
   {
    pac.render();
   } 
  }
}

public class Dots extends Item {
  int[][] data = new int[][];
  int x;
  int y;
  public Dots(int xn,int yn)
  {
    x = xn;
    y = yn;
  }

  public void display()
  {

    fill(255); 
    ellipse(x,y,15,15);
  }
}


Pacman pac;
PImage img;
PImage startscreen;
int direction = 1;
int direction2 = 0;
int radius = 15;
PGraphics pg;
boolean path = false;
Dots dot;
void setup()
{
  background(0);
  size(723, 800);
  dot = new Dots(40,40);
  pac = new Pacman(100, 225);
  pg = createGraphics(723, 800);
  img = loadImage("psb2.jpg");
}


void draw()
{
  stroke(0);
  image(img, 0, 0);
   dot.display();


  pg.beginDraw();
  pg.background(0);
  pg.stroke(255);
  pg.line(40, 40, 40, 225);//pathway
  pg.line(40, 225, 165, 225);//pathway
  pg.line(40, 40, 325, 40);//pathway
  pg.line(165, 40, 165, 685);
  pg.line(165, 685, 40, 685);
  pg.line(40, 685, 40, 755);
  pg.line(40, 755, 690, 755);
  pg.line(690, 755, 690, 685);
  pg.line(690, 685, 560, 685);
  pg.line(560, 685, 560, 40);
  pg.line(400, 40, 690, 40);
  pg.line(400, 40, 400, 145);
  pg.line(690, 40, 690, 145);
  pg.line(690, 145, 40, 145);
  pg.line(325, 40, 325, 145);
  pg.line(245, 145, 245, 225);
  pg.line(245, 225, 320, 225);
  pg.line(320, 225, 320, 300);
  pg.line(250, 300, 480, 300);
  pg.line(250, 300, 250, 375);
  pg.line(480, 300, 480, 375);
  pg.line(480, 375, 800, 375);
  pg.line(250, 375, 0, 375);
  pg.line(250, 375, 250, 525);
  pg.line(40, 525, 320, 525);
  pg.line(40, 525, 40, 610);
  pg.line(320, 525, 320, 610);
  pg.line(320, 610, 165, 610);
  pg.line(40, 610, 90, 610);
  pg.line(90, 610, 90, 685);
  pg.line(320, 610, 560, 610);
  pg.line(475, 610, 475, 685);
  pg.line(475, 685, 405, 685);
  pg.line(405, 685, 405, 755);
  pg.line(320, 755, 320, 680);
  pg.line(320, 680, 250, 680);
  pg.line(250, 680, 250, 610);
  pg.line(400, 610, 400, 525);
  pg.line(400, 525, 680, 525);
  pg.line(680, 525, 680, 610);
  pg.line(680, 610, 630, 610);
  pg.line(630, 610, 630, 685);
  pg.line(480, 375, 480, 525);
  pg.line(480, 455, 250, 455);
  pg.line(400, 300, 400, 225);
  pg.line(400, 225, 480, 225);
  pg.line(480, 225, 480, 145);
  pg.line(690, 145, 690, 220);
  pg.line(690, 220, 560, 220);
  pg.endDraw();
 // image(pg, 0, 0);

  pac.checkPixelsPacman();

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>I´m in trouble ("like pacman")</title>
      <link>https://forum.processing.org/two/discussion/22093/i-m-in-trouble-like-pacman</link>
      <pubDate>Thu, 20 Apr 2017 04:48:11 +0000</pubDate>
      <dc:creator>Ely</dc:creator>
      <guid isPermaLink="false">22093@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to finish my final project of programming with processing and I have problems with my code, first I do not know how to go from the menu to the game with the selected character, second; I do not respect the re-drawn background, third, I do not know how to make my character eat "food" in my game are pens, fourth; Do not make lives (3 maximum) fifth; My character does not respect the limits of the labyrinth previously drawn and sixth, in the four corners of my game there are some letters and if my character ate those letters can eat the enemies and also how to program that, it is like a pacman but another Version ... and I have to deliver it in 3 days, could someone help me? please!</p>

<p><a rel="nofollow" href="https://www.openprocessing.org/sketch/421938">https://openprocessing.org/sketch/421938</a></p>
]]></description>
   </item>
   <item>
      <title>Pac-Man Game</title>
      <link>https://forum.processing.org/two/discussion/20916/pac-man-game</link>
      <pubDate>Tue, 21 Feb 2017 03:48:33 +0000</pubDate>
      <dc:creator>Griff</dc:creator>
      <guid isPermaLink="false">20916@/two/discussions</guid>
      <description><![CDATA[<p>Hello again, everyone,</p>

<p>I am trying to make a pacman game and am running into errors that I am unfamiliar with. I am trying to get pacman controllable with the keyboard.</p>

<p>Here is my code:</p>

<pre><code>int mv = 60;

void setup( ) {
  size(500, 200);
  background(0);
  stroke(0);
  smooth();
  fill(255);
  for (int i = 0; i &lt; 16; i++) {
    ellipse(100 + 25 * i, 100, 15, 15);
  }
}

void draw( ) {
  fill(0);
  arc(mv, 100, 80, 80, radians(50 - 2 * (1 + mv % 25)), radians(310 + 2 * (1 + mv % 25)));
  mv++;
  fill(255, 255, 0);
  arc(mv, 100, 80, 80, radians(50 - 2 * (1 + mv % 25)), radians(310 + 2 * (1 + mv % 25)));
}

void keyPresses() {
  if (key == CODED) {   // Get key pressed
    if (keyCode == RIGHT) {
      pDirX = pSpeed;  // set packman X to increase (+1)
      pDirY = 0;  // only move in x direction 
    } else if (keyCode == LEFT) {
      pDirX = -pSpeed;  // set Pacman X to decrease (-1)
      pDirY = 0;  // only move in X dir=ection
    } else if (keyCode == UP) {
      pDirY = -pSpeed;  //set pacman Y to decrease (-1)
      pDirY = 0;  //only move in y direction
    } else if (keyCode == DOWN) {
      pDirY = +pSpeed; // set pacman X to increase (+1)
      pDirX = 0;  //only move in Y direction
    }
  }
}
</code></pre>

<p>And this is the error message I am getting:
<a href="http://i346.photobucket.com/albums/p405/Griff-500/Screen%20Shot%202017-02-14%20at%201.32.44%20PM_zpsocj4lget.png" target="_blank" rel="nofollow">http://i346.photobucket.com/albums/p405/Griff-500/Screen Shot 2017-02-14 at 1.32.44 PM_zpsocj4lget.png</a></p>
]]></description>
   </item>
   <item>
      <title>Pacman in Processing</title>
      <link>https://forum.processing.org/two/discussion/20536/pacman-in-processing</link>
      <pubDate>Sun, 29 Jan 2017 16:38:43 +0000</pubDate>
      <dc:creator>andremar</dc:creator>
      <guid isPermaLink="false">20536@/two/discussions</guid>
      <description><![CDATA[<p>I've seen so many great works in this forum and I thought it would be good to share mine.
I developed this simple custom version of pacman. I'm still a beginner in programming so please excuse any bugs that you may come across :D
Feel free to give me your feedback.</p>

<p>Link to my GitHub repo (where you will find the game and all the necessary files to run it):</p>

<p><a rel="nofollow" href="https://github.com/andremourato/Pacman-in-Processing">https://github.com/andremourato/Pacman-in-Processing</a></p>

<p>Here are some previews of the game:</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/297/G12HWB5O0QK8.png" alt="pacman_preview_1" title="pacman_preview_1" />
<img src="https://forum.processing.org/two/uploads/imageupload/867/8LVQS5M0CEVN.png" alt="pacman_preview_2" title="pacman_preview_2" />
<img src="https://forum.processing.org/two/uploads/imageupload/058/XCTMHTS7RDHB.png" alt="pacman_preview_3" title="pacman_preview_3" /></p>
]]></description>
   </item>
   <item>
      <title>Maze Wall Detection</title>
      <link>https://forum.processing.org/two/discussion/20323/maze-wall-detection</link>
      <pubDate>Tue, 17 Jan 2017 17:29:15 +0000</pubDate>
      <dc:creator>wjsandbe</dc:creator>
      <guid isPermaLink="false">20323@/two/discussions</guid>
      <description><![CDATA[<p>Ok I did the Coding Challenge #10.1 - 10.4: Maze Generator with p5.js at <span class="VideoWrap"><span class="Video YouTube" id="youtube-HyK_Q5rrcr4"><span class="VideoPreview"><a href="http://youtube.com/watch?v=HyK_Q5rrcr4"><img src="http://img.youtube.com/vi/HyK_Q5rrcr4/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span> , but now I want to move an object (pacman) through the maze. I have created the object(pacman) and it can move using the keyPressed function, but I want the object (pacman) to first check if there are walls blocking its movement. Something like if(!cell.walls(top) &amp;&amp; keyCode === UP_ARROW) { move up. The issue I think i'm having is I do not understand how I can refer to the specific grid[] that my object is in and then have it check that specific grid for walls. My code so far is as follows:</p>

<pre><code>    var pacman;
    var w = 40;
    var cols, rows;
    //width of each square is 40
    var grid = [];
    var current;
    //the current cell being visited
    var stack = [];



    function setup() {
      createCanvas(400, 400);
      cols = floor(width / w);
      rows = floor(height / w);
      pacman = new Pacman(0, 0);
      for (var j = 0; j &lt; rows; j++) {
        for (var i = 0; i &lt; cols; i++) {
          var cell = new Cell(i, j);
          grid.push(cell);
        }
      }
      current = grid[0];

    }

    function draw() {
      background(0);
      pacman.show();
      pacman.borders();
      for (var i = 0; i &lt; grid.length; i++) {
        grid[i].show();
      }
      current.visited = true;
      var next = current.checkNeighbours();
      if (next) {
        next.visited = true;

        stack.push(current);

        removeWalls(current, next);

        current = next;
      } else if (stack.length &gt; 0) {
        current = stack.pop();
      }
    }

        function keyPressed() {
      if (keyCode === RIGHT_ARROW) {
        pacman.moveh(1);
      }
      if (keyCode === LEFT_ARROW) {
        pacman.moveh(-1);
      }
      if (keyCode === UP_ARROW) {
        pacman.movev(-1);
      }
      if (keyCode === DOWN_ARROW) {
        pacman.movev(1);
      }
    }


    function Pacman(x, y) {
      this.x = x + 20;
      this.y = y + 20;
      this.toDelete = false;
      this.r = w;
      this.top = false;


      this.show = function() {
        noStroke();
        fill(255, 146, 0);
        ellipseMode(CENTER);
        ellipse(this.x, this.y, this.r, this.r);
      }

      this.moveh = function(dir) {
        this.x += dir * w;
      }
      this.movev = function(dir) {
        this.y += dir * w;
      }
      this.borders = function() {
        if (this.x &gt; width - 1) {
          this.x = x + 20;
        }
        if (this.x &lt; 0) {
          this.x = width - 20;
        }

        if (this.y &gt; height - 1) {
          this.y = y + 20;
        }
        if (this.y &lt; 0) {
          this.y = height - 20;
        }
      }
    }

    function index(i, j) {
      if (i &lt; 0 || j &lt; 0 || i &gt; cols - 1 || j &gt; rows - 1) {
        return -1;
      }
      return i + j * cols;
    }

    function Cell(i, j) {
      this.i = i;
      this.j = j;
      //i = column number
      //j = row number
      this.walls = [true, true, true, true];
      //top, right, bottom, left
      //if true you see that side of the wall of each cell, if false you do not see the wall
      this.visited = false;


      this.checkNeighbours = function() {
        var neighbours = [];
  `  //top = walls[0]`
        var top = grid[index(i, j - 1)];
        var right = grid[index(i + 1, j)];
        var bottom = grid[index(i, j + 1)];
        var left = grid[index(i - 1, j)];

        if (top &amp;&amp; !top.visited) {
          neighbours.push(top);
        }
        if (right &amp;&amp; !right.visited) {
          neighbours.push(right);
        }
        if (bottom &amp;&amp; !bottom.visited) {
          neighbours.push(bottom);
        }
        if (left &amp;&amp; !left.visited) {
          neighbours.push(left);
        }
        if (neighbours.length &gt; 0) {
          var r = floor(random(0, neighbours.length));
          return neighbours[r];
        } else {
          return undefined;
        }

      }



      this.show = function() {
        var x = this.i * w;
        var y = this.j * w;
        stroke(255);
        if (this.walls[0]) {
          line(x, y, x + w, y);
        }
        if (this.walls[1]) {
          line(x + w, y, x + w, y + w);
        }
        if (this.walls[2]) {
          line(x + w, y + w, x, y + w);
        }
        if (this.walls[3]) {
          line(x, y + w, x, y);
        }

      }
    }

    function removeWalls(a, b) {
      var x = a.i - b.i;
      if (x === 1) {
        a.walls[3] = false;
        b.walls[1] = false;
      } else if (x === -1) {
        a.walls[1] = false;
        b.walls[3] = false;
      }
      var y = a.j - b.j;
      if (y === 1) {
        a.walls[0] = false;
        b.walls[2] = false;
      } else if (y === -1) {
        a.walls[2] = false;
        b.walls[0] = false;
      }
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>how to get the dots/food to disappear when pac man goes over it</title>
      <link>https://forum.processing.org/two/discussion/20304/how-to-get-the-dots-food-to-disappear-when-pac-man-goes-over-it</link>
      <pubDate>Mon, 16 Jan 2017 19:12:22 +0000</pubDate>
      <dc:creator>jkkjk</dc:creator>
      <guid isPermaLink="false">20304@/two/discussions</guid>
      <description><![CDATA[<p>this is what i got so far</p>

<p>int i=1;
int nxtx;
int nxty;
float ang=0;
float speed=10;
int posx=50;
int posy=300;
PVector[]dots=new PVector[50];
void setup(){
  background(128);
  size(800,600);
  frameRate(15);
  ellipseMode(RADIUS);
  fill(#FAF312);
 for(int i=0;i&lt;50;i++){
   dots[i]=new PVector(random(0,width),random(0,height));}
}
void draw() {
  background(128);
  stroke(10);
 strokeWeight(10);
 for(int i=0;i&lt;50;i++){
   point(dots[i].x,dots[i].y);}
   noStroke();
resetShader();
  //ang=atan2(mouseY-posy,mouseX-posx);
 nxtx=posx+=speed<em>cos(ang);
  nxty=posy+=speed</em>sin(ang);
  if(nxty&lt;=width<em>1) 
  if(nxty&lt;=height</em>1)
  translate(posx,posy);
  rotate(ang);
  arc(5,0,100,100,.4,6);
 if(i==1){arc(5,0,100,100,.7,6);
i=-i;}
else{ellipse(5,0,100,100);
i=-i;}
//if(keyPressed==){
 if(keyPressed==true){
  if(keyCode==UP){ang=-PI/2;}
  if(keyCode==DOWN){ang=PI/2;}
    if(keyCode==LEFT){ang=PI;}
      if(keyCode==RIGHT){ang=0;}
 }}</p>
]]></description>
   </item>
   <item>
      <title>Splicing an array of objects (Pacman)</title>
      <link>https://forum.processing.org/two/discussion/20307/splicing-an-array-of-objects-pacman</link>
      <pubDate>Mon, 16 Jan 2017 20:43:41 +0000</pubDate>
      <dc:creator>wjsandbe</dc:creator>
      <guid isPermaLink="false">20307@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to make a simple version of pacman. I'm having a problem using the splice() function. I have an array of ellipses (called Food) and as the orange ellipse (pacman) moves over the food, I want the food to disappear. The problem right now is that about 39 food disappear instead of a single ellipse. I'm not sure what I'm doing wrong. My code is below:</p>

<pre><code>    var foods = [];
    var pacman;
    var w = 40;


    function setup() {
      createCanvas(400, 400);
      var t = 0;
      pacman = new Pacman(0, 0);
      for (var f = 0; f &lt; 10; f++) {
        for (var g = 0; g &lt; 10; g++) {
          foods[t++] = new Food(g * 40 + 15, f * 40 + 15);
        }
      }
    }

    function draw() {
      background(51);
      pacman.show();
      pacman.borders();

      for (var i = 0; i &lt; foods.length; i++) {
        foods[i].cook();
        if (pacman.eats(foods[i])) {
          foods[i].eaten();
        }
      }
      for (var j = 0; j &lt; foods.length; j++) {
        if (foods[j].toDelete) {
          foods.splice(1, j);
          console.log(foods.length);
        }
      }
    }

    function Food(x, y) {
      this.x = x;
      this.y = y;
      this.r = 10;
      this.toDelete = false;

      this.cook = function() {
        fill(255);
        ellipseMode(CORNER);
        ellipse(this.x, this.y, this.r, this.r);
      }
        this.eaten = function() {
          this.toDelete = true;
      }
    }

    function keyPressed() {
      if (keyCode === RIGHT_ARROW) {
        pacman.moveh(1);
      }
      if (keyCode === LEFT_ARROW) {
        pacman.moveh(-1);
      }
      if (keyCode === UP_ARROW) {
        pacman.movev(-1);
      }
      if (keyCode === DOWN_ARROW) {
        pacman.movev(1);
      }
    }

    function Pacman(x, y) {
      this.x = x;
      this.y = y;
      this.toDelete = false;


      this.show = function() {
        noStroke();
        fill(255, 146, 0);
        ellipseMode(CORNER);
        ellipse(this.x, this.y, w, w);
      }

      this.moveh = function(dir) {
        this.x += dir * w;
      }
      this.movev = function(dir) {
        this.y += dir * w;
      }
      this.borders = function() {
        if (this.x &gt; width - 1) {
          this.x = 0;
        }
        if (this.x &lt; 0) {
          this.x = width - w;
        }

        if (this.y &gt; height - 1) {
          this.y = 0;
        }
        if (this.y &lt; 0) {
          this.y = height - w;
        }
      }
        this.eats = function(Food) {
        var d = dist(this.x, this.y, Food.x, Food.y);
        if (d &lt; Food.x) {
          console.log("eaten");
          return true;
        } else {
          return false;
        }
      }
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>how do you make dots in pac man dissapear if he goes over them</title>
      <link>https://forum.processing.org/two/discussion/20294/how-do-you-make-dots-in-pac-man-dissapear-if-he-goes-over-them</link>
      <pubDate>Mon, 16 Jan 2017 02:58:36 +0000</pubDate>
      <dc:creator>jkkjk</dc:creator>
      <guid isPermaLink="false">20294@/two/discussions</guid>
      <description><![CDATA[<p>i have the dots i just need to know how to make them disappear when he goes over them</p>
]]></description>
   </item>
   <item>
      <title>Pac Man beginner</title>
      <link>https://forum.processing.org/two/discussion/20070/pac-man-beginner</link>
      <pubDate>Wed, 04 Jan 2017 21:10:20 +0000</pubDate>
      <dc:creator>Garnuk</dc:creator>
      <guid isPermaLink="false">20070@/two/discussions</guid>
      <description><![CDATA[<p>I need to make this ellipse respond to my arrow keys and eat small orbs(pac man points) This is what ive done so far</p>

<pre><code>float ang = 0;
float speed = 10;
int posx = 50;
int posy = 300;
int i = 1;

void setup(){
  background (128);
  size(800, 600);
  frameRate(20);
  ellipseMode(RADIUS);
  fill(#FAF312);
  noStroke();
}

void draw() {
  background (128);
  ang = atan2(mouseY - posy, mouseX - posx);
  posx += speed * cos(ang);
  posy += speed * sin(ang);
  translate(posx, posy);
  rotate(ang);
  //arc(50,50,75,75,.51,5.02);

  if (i == 1){
    arc(50, 50, 50, 50, .51, 5.9);
    i = -i;
  } else {
    ellipse(50, 50, 50, 50);
    i = -i;
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>What is happening in this code? (Pacman ghost)</title>
      <link>https://forum.processing.org/two/discussion/19804/what-is-happening-in-this-code-pacman-ghost</link>
      <pubDate>Sun, 18 Dec 2016 11:44:36 +0000</pubDate>
      <dc:creator>shaunafitzgoo</dc:creator>
      <guid isPermaLink="false">19804@/two/discussions</guid>
      <description><![CDATA[<p>I'm not sure if this is the kind of question I can ask on here so if it isn't allowed just say. I have been given this piece of code by a lecturer in college but he hasn't really explained what it does. It is a ghost class in a pacman game so it is just creating the ghosts and making them chase the pacman and then killing it and turning colour when the pacman eats the super food. I dont exactly know how it's doing this though.</p>

<pre><code>class Ghost {

  int type;
  int x, y, tx, ty, ptx, pty;  
  int pgx, pgy;
  int d;  
  boolean is_scared;  
  boolean is_dead; 
  int trapped_timer;  

  Ghost(int itype) {
    type = itype % ghost_colors.length;
    x = 10 + 20 * 15;
    y = 10 + 20 * 14;
    tx = x;
    ty = y;
    ptx=tx;
    pty=ty;
    trapped_timer = 200 * type;
  }

  void dont_be_afraid() {
    if (is_scared) {
      is_scared = false;
      d=(d+2)%4;
      tx = ptx;
      ty = pty;
    }
  }

  void be_afraid() {
    if (!is_dead) {
      is_scared = true;
      d=(d+2)%4;
      tx = ptx;
      ty = pty;
    }
  }

  void draw() {
    simulate();
    render();
    if (!is_dead) kill_check();
  }

  void simulate() {
    trapped_timer--;
    if (trapped_timer &gt; 0) return;
    int px = x;
    int py = y;
    if (tx &lt; x) x--;
    if (tx &gt; x) x++;
    if (ty &lt; y) y--;
    if (ty &gt; y) y++;
    if (px==x&amp;&amp;py==y) {
      ptx = tx;
      pty = ty;
      int wall_count = 0;
      for (int w = 0; w &lt; 4; w++) {
        if ( grid.is_wall(x+decodeX[w], y+decodeY[w]) ) {
          wall_count++;
        }
      }
      if (wall_count == 4) { // &gt;:(
        d = 4;
        tx = x+decodeX[d];
        ty = y+decodeY[d];
        return;
      }
      if (wall_count == 3) {
        for (int w = 0; w &lt; 4; w++) {
          if ( !grid.is_wall(x+decodeX[w], y+decodeY[w]) ) {
            d = w;
          }
        }
        tx = x+decodeX[d];
        ty = y+decodeY[d];
        return;
      }
      if (wall_count == 2) {
        int result = 5;
        for (int w = 0; w &lt; 4; w++) {
          if ( !grid.is_wall(x+decodeX[w], y+decodeY[w]) ) {
            if ( w != (d+2)%4 ) {
              result = w;
            }
          }
        }
        d = result;
        tx = x+decodeX[d];
        ty = y+decodeY[d];
        return;
      }
      int gx = int(player.x); // RED - Go for pacman.
      int gy = int(player.y);
      if (!to_corners) {
        if (type == 1 ) { // PINK = Get in front of pacman.
          gx = int(player.x)+4*decodeX[player.d];
          gy = int(player.y)+4*decodeY[player.d];
          if ( player.d == 3 ) { // Classic pink ghost behaviour.
            gx = int(player.x-80);
          }
        }
        if ( type == 2 ) { // CYAN - Negative RED's positions, offset a couple of squares.
          float mpx = player.x+2*decodeX[player.d];
          float mpy = player.y+2*decodeY[player.d];
          if (player.d == 3) { // Classic cyan ghost behaviour.
            mpx = player.x - 40;
          }
          gx = int(2*mpx - ghosts[0].x);
          gy = int(2*mpy - ghosts[0].y);
        }
        if ( type == 3 ) { // ORANGE - Get close, then back off.
          if (dist(player.x, player.y, x, y) &lt; 160) {
            gx = 0;
            gy = height;
          }
        }
      } else {
        gx = width;
        gy = height;
        if ( type == 1 || type == 3 ) gx = 0; 
        if ( type == 1 || type == 0 ) gy = 0;
      }
      if (is_dead||is_scared) {
        gx = 10 + 20 * 15;
        gy = 10 + 20 * 14;
        if (is_dead &amp;&amp; x==gx &amp;&amp;y==gy) is_dead = false;
      }    
      pgx = gx;
      pgy = gy;
      float best = -1 ;
      int result = 5;
      for ( int w = 0; w &lt; 4; w++) {
        if ( w!=(d+2)%4 &amp;&amp; !grid.is_wall(x+decodeX[w], y+decodeY[w])) {
          float new_dist = dist(x+decodeX[w], y+decodeY[w], gx, gy);
          if ( best == -1 || new_dist &lt; best) {
            best = new_dist;
            result = w;
          }
        }
      }
      d = result;
      tx = x+decodeX[d];
      ty = y+decodeY[d];
      return;
    }
  }

  void render() {
    stroke(0);
    fill(is_scared?color(0, 0, 255):ghost_colors[type]);
    pushMatrix();
    translate(x, y);
    if (!is_dead) {
      rect(-11, -1, 22, 11);
      arc(0, 0, 22, 22, PI, TWO_PI);
      for (int i=0; i&lt;4; i++) {
        arc(-7+5*i, 10, 5, 5, 0, PI);
      }
    }
    fill(255);
    noStroke();
    ellipse(-4, 0, 4, 8);
    ellipse(4, 0, 4, 8);
    if (is_dead||!is_scared) {
      fill(0, 0, 255);
      int eyex = (d==2?-1:0)+(d==0?1:0);
      int eyey = (d==3?-3:0)+(d==1?3:0);
      ellipse(-4+eyex, eyey, 3, 3);
      ellipse(4+eyex, eyey, 3, 3);
    }
    popMatrix();
  }

  void kill_check() {
    if ( grid.kill_at(x, y) ) is_dead = true;
  }
}

int[] decodeX = {    20, 0, -20, 0, 0 }; 
int[] decodeY = {    0, 20, 0, -20, 0 };
</code></pre>
]]></description>
   </item>
   <item>
      <title>Need help getting object to leave trail</title>
      <link>https://forum.processing.org/two/discussion/19370/need-help-getting-object-to-leave-trail</link>
      <pubDate>Mon, 28 Nov 2016 21:04:07 +0000</pubDate>
      <dc:creator>MRoden1993</dc:creator>
      <guid isPermaLink="false">19370@/two/discussions</guid>
      <description><![CDATA[<p>I have a sketch where a Pacman character moves around the screen trying to eat cherries. I want Pacman to leave a trail of yellow dots as he moves and to then remove the dots when he comes back into contact with them. The problem at the moment though is that the dots are transmitted on Pacmans location and so he removes them before they show up on screen. I therefore need a way of transmitting the dots just behind Pacman instead. Any help would be much appreciated.</p>

<pre><code>    Pacman pacman = new Pacman(75); 

   void setup() {
  size(500, 500); //set the size of the page to 500pixels by 500pixels
  ellipseMode(CENTER); //set ellipse mode to center
  }

  void draw() {

  background(0); //set background to black
  pacman.update(); //use the function update() as written in class Pacman                               
  pacman.transmit(); //use the function transmit() as written in class Pacman 
  pacman.drawTrail(); //use the function drawTrail() as written in class Pacman
  pacman.collideTrail(); //use the function collideTrail() as written in class Pacman
  pacman.checkEdges();
  pacman.draw(); //use the function draw() as written in class Pacman
  }

  class Pacman {

  PVector location; 
  PVector velocity;                                                     
  PVector acceleration;                                                    
  PVector target; 
  float topspeed; 
  float tolerance = 15;      
  float direction = 0;

  float diameter; //declare diameter as float
  float MouthAngle = 0; //set MouthAngle to 0 (starting position closed)
  float OpeningAngle = PI * 2 / 180; 
  boolean MouthMovement = true; //set variable for MouthMovement
  ArrayList trail; // declare the use of trail as an Arraylist
  boolean MousePressed = false;


  Pacman(float dia) {

    diameter = dia;  
    trail = new ArrayList(); // assign trail as a function to create a new Arraylist
    location = new PVector(250,250);            
    velocity = new PVector(0, 0); 
    target = new PVector(width/2, height/2);                              
    topspeed = 3; //top speed is assigned a value of 3
  }

  void update() {


    PVector dir = PVector.sub(target, location);
    float distance = dist(location.x, location.y, target.x, target.y); 



    if (topspeed &gt; tolerance) {                                           
      topspeed *= 0.9;
    } else {
      topspeed = distance*0.05;
    }

    dir.normalize(); //normalize
    direction = dir.mag(); 
    acceleration = dir; // acceleration = direction                                               
    velocity.add(acceleration); 
    velocity.limit(topspeed);   //limit velocity to topspeed


    if (distance&lt;tolerance) { 
      target.x = random(width -100, width +100); 
      target.y = random(height -100, height +100);
    } else { //if the target hasn't been reached 
      location.add(velocity); //continue to move as normal

      if (mousePressed) {
        target.x = mouseX;
        target.y = mouseY;
      }
    }
  }

  void draw() {

    float dX = location.x - target.x; 
    float dY = location.y - target.y; 


    float angle = radians((atan2(dY, dX) * 180 / PI));


    if (dist(target.x, target.y, location.x, location.y) &gt; 0) {
      cherries();

      pushMatrix();
      translate(location.x, location.y);
      rotate(angle);
      if (MouthMovement == true) MouthAngle += OpeningAngle; 
      else MouthAngle -= OpeningAngle; 
      if (MouthAngle &gt; TWO_PI / 8 || MouthAngle &lt; 0) MouthMovement = ! MouthMovement;
      stroke(0);
      fill(255, 255, 0); // set fill to yellow
      arc(0, 0, diameter, diameter, HALF_PI*-2 + MouthAngle, HALF_PI*2 -MouthAngle); 
      fill (0); //set fill to black
      ellipse(0, 0 - diameter / 4, diameter/8, diameter/8);
      popMatrix();
    }
  }

  void checkEdges() {
    if (location.x  &gt; width -diameter/2 || location.x  &lt;0 +diameter/2 ) { 
      velocity.x *= -2; //its velocity is multiplied by -0.1
      target.x = random(width); 
      target.y = random(height);
    } 
    if (location.y +diameter/2&gt; height || location.y  &lt;0 +diameter/2 ) { 
      velocity.y *= -2; //its velocity is multiplied by -0.1
      target.x = random(width); 
      target.y = random(height);
    }
  }

  void transmit() {


    for (int i=0; i&lt;trail.size (); i++) { 
      if (trail.size() != 0) { 
        crumbs t = (crumbs) trail.get(i); 
        t.draw();
      }
    }
  }
  void drawTrail() {


    trail.add(new crumbs(new PVector(location.x, location.y), 10));
  }

  void collideTrail() {

    PVector crumbPos; 
    for (int i=0; i&lt;trail.size (); i++) {
      crumbs drop = (crumbs) trail.get(i);
      crumbPos = drop.loc;
      float d = location.dist(crumbPos); 
      if (d &lt; diameter/2) { //if Pacman is touching the crumbs                                
        trail.remove(i);
        // target.x = random(width); 
        //  target.y = random(height); 
        //velocity.x *= -2;
        //velocity.y *= -2;
      }
    }
  }


  void cherries() {
    stroke(0, 255, 0); //set stroke to green
    line (target.x -5, target.y+1, target.x-2.5, target.y-25); //draw line
    line (target.x +5, target.y-1, target.x-2.5, target.y-25); //draw line

    stroke(0);
    fill(255, 0, 0); //set fill to red
    ellipse(target.x-5, target.y-1, 15, 15); //draw ellipse 
    ellipse(target.x+5, target.y+1, 15, 15); //draw ellipse
   }
  }

   class crumbs { 

  PVector loc; //declare loc as a PVector 
  float diameter; //declare diameter as a float 



  crumbs(PVector loc_, float dia) {
    loc = loc_; 
    diameter=dia;
  }

  void draw () { 
    fill (255, 255, 0); 
    noStroke(); 

    ellipse(loc.x, loc.y, diameter, diameter);
    }
  }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Creating objects shrinks my sketch?</title>
      <link>https://forum.processing.org/two/discussion/18713/creating-objects-shrinks-my-sketch</link>
      <pubDate>Wed, 26 Oct 2016 01:42:33 +0000</pubDate>
      <dc:creator>wonkywoah</dc:creator>
      <guid isPermaLink="false">18713@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I'm very very new at Processing and trying to create an abbreviated version of Pac-man for class.</p>

<p>I have some parts moving, namely, a yellow dot that moves through a maze when the directional arrows are pressed.</p>

<p>This worked for the most part when coded basically in setup/draw, however as soon as I write a class for the exact same code (reorganized), the entire game shrinks!</p>

<p>I don't know what is triggering it, I think it has to do with the placement of the values that moved from the original version of setup(). I would appreciate any help. I noticed some behaviours in Processing change when written as a class (but I'm still new to this, so I can't tell if it's a quirk or my unfamiliarity).</p>

<p><strong>Code written as a class</strong></p>

<pre><code>Maze gameset = new Maze(); 

void setup() {
  size(1000, 500);
}

void draw() {
  gameset.displayMap();
  gameset.keyPressed();
}

class Maze {

  //Starting by using a 2D Array to map the maze.
  int [][]maze = new int[][]{
    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, //TOP WALL // ROW 1
    {-1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1}, // ROW 2
    {-1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1}, //ROW 3
    {-1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1}, //ROW 4
    {-1, 1, -1, 1, -1, -1, 1, -1, -1, 0, 0, -1, -1, 1, -1, -1, 1, -1, 1, -1}, //ROW 5
    {-1, 2, 1, 1, 1, 1, 1, -1, 0, 0, 0, 0, -1, 1, 1, 1, 1, 1, 1, -1}, //ROW 6
    {-1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1}, //ROW 7
    {-1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1}, //ROW 8  
    {-1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1}, //ROW 9
    {-1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1}, // ROW 10
    {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, //BOTTOM WALL // ROW 11
  };

  int rows = 11;
  int cols = 20;
  int minX, maxX, minY, maxY;
  int cellWidth, cellHeight;
  int pacX = 1, pacY = 6;

  Maze() {
    minX = 10;
    maxX = width;
    minY = 10;
    maxY = height;
    cellWidth = maxX/cols;
    cellHeight = maxY/rows;
  }

  void displayMap() {
    for (int i = 0; i &lt; cols; i++) {
      for (int j = 0; j &lt; rows; j++) {
        pushStyle();
        noStroke();
        int value = maze[j][i];
        if (value == -1) {
          fill(0, 0, 255);
        } else if (value == 0) {
          fill(0);
        } else if (value == 1) {
          fill(0, 255, 0);
        } else {
          fill(230, 190, 30);
        }
        rect(i * cellWidth, j * cellHeight, cellWidth, cellHeight);
        popStyle();
      }
    }
    println(pacX, pacY);
  }

  void keyPressed() {
    if (key == CODED) {
      int newX = pacX, newY = pacY;
      if (keyCode == RIGHT) {
        newX = pacX + 1;
        newY = pacY;
      } else if (keyCode == LEFT) {
        newX = pacX - 1;
        newY = pacY;
      } else if (keyCode == UP) {
        newX = pacX;
        newY = pacY - 1;
      } else if (keyCode == DOWN) {
        newX = pacX;
        newY = pacY + 1;
      }
      updatePacPosition(newX, newY);
    }
  }
  void updatePacPosition(int newX, int newY) {
    if (newX &lt; cols &amp;&amp; newX &gt;= 1 &amp;&amp; newY &gt;= 1 &amp;&amp; newY &lt; rows &amp;&amp; maze[newY][newX] != -1) {
      maze[pacY][pacX] = 0;
      pacX = newX;
      pacY = newY;

      maze[pacY][pacX] = 2;
    }
  }
}
</code></pre>

<p><strong>Code before class</strong></p>

<pre><code>//Starting by using a 2D Array to map the maze.


int [][]maze = new int[][]{
  {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, //TOP WALL // ROW 1
  {-1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1}, // ROW 2
  {-1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1}, //ROW 3
  {-1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1}, //ROW 4
  {-1, 1, -1, 1, -1, -1, 1, -1, -1, 0, 0, -1, -1, 1, -1, -1, 1, -1, 1, -1}, //ROW 5
  {-1, 2, 1, 1, 1, 1, 1, -1, 0, 0, 0, 0, -1, 1, 1, 1, 1, 1, 1, -1}, //ROW 6
  {-1, 1, -1, 1, -1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, -1, 1, -1, 1, -1}, //ROW 7
  {-1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, -1}, //ROW 8  
  {-1, 1, -1, -1, 1, -1, 1, -1, -1, -1, -1, -1, -1, 1, -1, 1, -1, -1, 1, -1}, //ROW 9
  {-1, 1, 1, 1, 1, -1, 1, 1, 1, 1, 1, 1, 1, 1, -1, 1, 1, 1, 1, -1}, // ROW 10
  {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}, //BOTTOM WALL // ROW 11
};

int rows = 11;
int cols = 20;
int minX, maxX, minY, maxY;
int cellWidth, cellHeight;
int pacX = 1, pacY = 6;

void setup() {
  size(1000, 500);
  minX = 10;
  maxX = width;
  minY = 10;
  maxY = height;
  cellWidth = maxX/cols;
  cellHeight = maxY/rows;
}

void draw() {
  //fill(0);
  //rect(0, 0, width, height);
  //fill(0);
  //rect(minX, minY, maxX-minX, maxY-minY);
  for (int i = 0; i &lt; cols; i++) {
    for (int j = 0; j &lt; rows; j++) {
      pushStyle();
      noStroke();
      int value = maze[j][i];
      if (value == -1) {
        fill(0, 0, 255);
      } else if (value == 0) {
        fill(0);
      } else if (value == 1) {
        fill(0, 255, 0);
      } else {
        fill(230, 190, 30);
      }
      rect(i * cellWidth, j * cellHeight, cellWidth, cellHeight);
      popStyle();
    }
  }
  println(pacX, pacY);
}

void keyPressed() {
  if (key == CODED) {
    int newX = pacX, newY = pacY;
    if (keyCode == RIGHT) {
      newX = pacX + 1;
      newY = pacY;
    } else if (keyCode == LEFT) {
      newX = pacX - 1;
      newY = pacY;
    } else if (keyCode == UP) {
      newX = pacX;
      newY = pacY - 1;
    } else if (keyCode == DOWN) {
      newX = pacX;
      newY = pacY + 1;
    }
    updatePacPosition(newX, newY);
  }
}

void updatePacPosition(int newX, int newY) {
  if (newX &lt; cols &amp;&amp; newX &gt;= 1 &amp;&amp; newY &gt;= 1 &amp;&amp; newY &lt; rows &amp;&amp; maze[newY][newX] != -1) {
    maze[pacY][pacX] = 0;
    pacX = newX;
    pacY = newY;

    maze[pacY][pacX] = 2;
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Pacman</title>
      <link>https://forum.processing.org/two/discussion/18604/pacman</link>
      <pubDate>Tue, 18 Oct 2016 03:20:09 +0000</pubDate>
      <dc:creator>theking</dc:creator>
      <guid isPermaLink="false">18604@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to make a pacman game with a pacman and a ghost but whenever I combine the codes I get told I'm mixing active and static modes and I don't know how so fix it. Please help</p>
]]></description>
   </item>
   <item>
      <title>We need help on our Pacman</title>
      <link>https://forum.processing.org/two/discussion/16164/we-need-help-on-our-pacman</link>
      <pubDate>Thu, 21 Apr 2016 13:12:22 +0000</pubDate>
      <dc:creator>chromatiques</dc:creator>
      <guid isPermaLink="false">16164@/two/discussions</guid>
      <description><![CDATA[<p>Hi, we are beginners on processing and for the exams this years we have a project to deliver. So with a friend we decided to make a PacMan (probably a lack of imagination). The program is quite simple but we have some problems making the ghost move, we did a little code but it just moving left and right. So we don't know who to ask and we came here. 
Could you please give us informations please ? I don't know how to post the code, ask me for my e-mail.</p>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>Pacman and ghost</title>
      <link>https://forum.processing.org/two/discussion/16176/pacman-and-ghost</link>
      <pubDate>Thu, 21 Apr 2016 20:39:41 +0000</pubDate>
      <dc:creator>alivi</dc:creator>
      <guid isPermaLink="false">16176@/two/discussions</guid>
      <description><![CDATA[<p>Hello people!</p>

<p>We are doing a pacman with some friends. Unfortunately we can't manage to find out how to program the death of the pacman. We have also the same problem for "eating the coins". We know where our error is ! But we don't know how to solve it 
We have the position of the pacman (positionX/positionY) and of the ghost (positionF1X/positionF1Y)</p>

<p>if(positionX==positionF1X &amp;&amp; positionY==positionF1Y){
    background(0);<br />
    textSize(40);
    text("GAME OVER",200,200);
    text("SCORE FINAL  ="+score,170,140);
    fill(255);
  }</p>

<p>if(positionX==positionF2X &amp;&amp; positionY==positionF2Y){
    background(0);<br />
    textSize(40);
    text("GAME OVER",200,200);
    text("SCORE FINAL  ="+score,170,140);
    fill(255);
  }</p>

<p>if(positionX==positionF3X &amp;&amp; positionY==positionF3Y){
    background(0);<br />
    textSize(40);
    text("GAME OVER",200,200);
    text("SCORE FINAL  ="+score,170,140);
    fill(255);
  }</p>

<p>if(positionX==positionF4X &amp;&amp; positionY==positionF4Y){
    background(0);<br />
    textSize(40);
    text("GAME OVER",200,200);
    text("SCORE FINAL  ="+score,170,140);
    fill(255);</p>

<p>BUT! the position of the pacman is never completely and just superpose with the ghost! So we would like to know if there is a way to create an "if" with an interval of values (for example if positionX is nearly as positionF1X, at 10 pixels near).</p>

<p>Is there a solution? 
Thanks you so much for your help!</p>

<p>TeamPac</p>
]]></description>
   </item>
   <item>
      <title>Please,we need some help. We are stuck. (Pacman)</title>
      <link>https://forum.processing.org/two/discussion/15798/please-we-need-some-help-we-are-stuck-pacman</link>
      <pubDate>Fri, 01 Apr 2016 08:57:11 +0000</pubDate>
      <dc:creator>TEAMpac</dc:creator>
      <guid isPermaLink="false">15798@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone, we are a group of students who are working on a processing projet about Pacman Game. We wanted to create, as similar as possible, the original game. Perhaps, it is getting more difficult than what we thought at the begining :(</p>

<p>Our first question is about the mouvement of ghosts.</p>

<p>How can we manage to make the ghost follow the pacman. We were thinking about creating two vectros, one which relies the position of the pacman and the ghost, and the oder which is a constant horizontal (1,0)</p>

<p>Then, calculate the angle between the two vectors.</p>

<p>If the angle is 0&lt; A &lt;PI/2 the ghost can go to the right and up.</p>

<p>If the angle is PI /2&lt; A &lt; PI the ghost can go the left and up.</p>

<p>If the angle is PI &lt; A &lt; 3PI/2 the ghost can go down and left.</p>

<p>If the angle is 3 PI/2 &lt; A &lt;0 the ghost can go right and down.</p>

<p>Is there any posibility to do it?</p>

<p>Thank you so so much in advance.</p>
]]></description>
   </item>
   <item>
      <title>Pacman: how to add ghosts and a general score?</title>
      <link>https://forum.processing.org/two/discussion/15024/pacman-how-to-add-ghosts-and-a-general-score</link>
      <pubDate>Sat, 20 Feb 2016 12:58:53 +0000</pubDate>
      <dc:creator>Emi6797</dc:creator>
      <guid isPermaLink="false">15024@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys,
I've to programm a game for a college project: I decided for Pacman and everything works except the ghosts and a general score.
It d be awesome if someone could help! Thanks in advance.</p>

<pre><code>class Pacman {

  int x;
  int y;
  int durchmesser;
  int state = 0;
  float animTimerSec = 0;
  float ANIM_CYCLE = .5;
      int score;
    int life;
    PFont font;
    boolean [] [] food = new boolean [20][15];

  Pacman(int d) {
    durchmesser = d;
    x = d/2;
    y = d/2;
  }

    ////start over the game every time pacman touches the X and Y walls
    void startOver () {
      if  ((pacman.x &gt; width) || (pacman.x &lt; 0) ||
        (pacman.y &gt; height) || (pacman.y &lt; 0)) {
    //    pacman = new pacman();     
        life-=1;
        score=0;
        background (0);
        textFont(font);
        println("You died");
        fill (0, 255, 255);
        text("You died", height/2, width/2);
      }
      if  (life==0)
      {
        println ("Game over");
        background (0);
        textFont(font);
        fill (0, 255, 255);
        text("GAME OVER ", height/2, width/2);
      }
      else if (score==100)
      {
        println ("YOU WON!!!");
        background (0);
        textFont(font);
        fill (0, 255, 255);
        text("YOU WON!!!", height/2, width/2);
      }
    }

  void draw() {
    noStroke();
    fill(#FFE624);
    animTimerSec += 1.0/frameRate;

    if (animTimerSec &gt;= ANIM_CYCLE) {
      animTimerSec = 0;
      state++;
      state = state % 2;
    }

    if (state == 0) {
      ellipse(x, y, durchmesser, durchmesser);
    } 
    else if (state == 1) {
      arc(x, y, durchmesser, durchmesser, radians(30), 
      radians(330));
    }

    fill(0);
    ellipse(x+durchmesser/6, y-durchmesser/3, 8, 8);
  }

  void moveLeft() {
    x -= durchmesser;
    x = constrain(x, durchmesser/2, width-durchmesser/2);
  }

  void moveRight() {
    x += durchmesser;
    x = constrain(x, durchmesser/2, width-durchmesser/2);
  }

  void moveUp() {
    y -= durchmesser;
    y = constrain(y, durchmesser/2, height-durchmesser/2);
  }

  void moveDown() {
    y += durchmesser;
    y = constrain(y, durchmesser/2, height-durchmesser/2);
  }
}

// Tastatursteuerung
void keyPressed() {
  if (keyCode == LEFT) {
    pacman.moveLeft();
  }
  if (keyCode == RIGHT) {
    pacman.moveRight();
  }
  if (keyCode == UP) {
    pacman.moveUp();
  }
  if (keyCode == DOWN) {
    pacman.moveDown();
  }
}
class Punkt {
  int x;
  int y;
  int wert = 5;
  boolean alive = true;

  Punkt(int px, int py) {
    x = px;
    y = py;
  }

  void draw() {
    // zeichne nur, wenn noch nicht gefressen
    if (alive) {
      noStroke();
      fill(#FF52F4);
      ellipse(x, y, 10, 10);
    }
  }
}
int score = 0;
int cellSize = 40;
Pacman pacman = new Pacman(cellSize);
Punkt[] punkte = new Punkt[30];

void setup() {
  size(400, 400);
  for (int i = 0; i &lt; punkte.length; i++) {
    int x = (int)random(0, 10) * cellSize + cellSize/2;
    int y = (int)random(0, 10) * cellSize + cellSize/2;
    punkte[i] = new Punkt(x, y);
  }
}



// Gibt true zurück, wenn Punkt erfolgreich gegessen

boolean tryToEat(Punkt p) {
  // Punkt ist bereits gegessen
  if (!p.alive) {
    return false;
  }

  // Wenn auf gleichem Feld: Punkt essen
  if (dist(pacman.x, pacman.y, p.x, p.y) &lt;= 2/2) {
    p.alive = false; 
    return true; // Erfolgreich gegessen!
  }

  return false; 
}
void draw() {
  background(0);
  pacman.draw();
  for (int i = 0; i &lt; punkte.length; i++) {
    boolean eaten = tryToEat(punkte[i]);

    if (eaten) {
      score += punkte[i].wert;
    }

    punkte[i].draw();
  }
}
class Geist {
  int x;
  int y;
  int durchmesser;

  Geist(int gx, int gy, int d) {
    x = gx;
    y = gy;
    durchmesser = d;
  }

  void draw() {
    noStroke();
    fill(#79D3FF);

    // Körper
    ellipse(x, y, durchmesser, durchmesser);
    rectMode(CORNER);
    rect(x-durchmesser/2, y, durchmesser, durchmesser/2);

    // Augen
    rectMode(CENTER);
    fill(0);
    rect(x-durchmesser/4, y, durchmesser/4, durchmesser/8);
    rect(x+durchmesser/4, y, durchmesser/4, durchmesser/8);
  }

  // Im Gegensatz zu Pacman wollen wir einen 
  // zufälligen Bewegungsschritt ausführen
  void move() {
    int richtung = (int)random(0, 4);
    if (richtung == 0) {
      moveLeft();
    }
    if (richtung == 1) {
      moveRight();
    }
    if (richtung == 2) {
      moveUp();
    }
    if (richtung == 3) {
      moveDown();
    }
  }

  void moveLeft() {
    x -= durchmesser;
    x = constrain(x, durchmesser/2, width-durchmesser/2);
  }

  void moveRight() {
    x += durchmesser;
    x = constrain(x, durchmesser/2, width-durchmesser/2);
  }

  void moveUp() {
    y -= durchmesser;
    y = constrain(y, durchmesser/2, height-durchmesser/2);
  }

  void moveDown() {
    y += durchmesser;
    y = constrain(y, durchmesser/2, height-durchmesser/2);
  }
}
// neue globale Variablen
Geist[] geister = new Geist[3];
int leben = 3;
void setup() {
  size(10*cellSize, 10*cellSize);
  for (int i = 0; i &lt; punkte.length; i++) {
    int x = (int)random(0, 10) * cellSize + cellSize/2;
    int y = (int)random(0, 10) * cellSize + cellSize/2;
    punkte[i] = new Punkt(x, y);
  }
  for (int i = 0; i &lt; geister.length; i++) {
    int x = (int)random(3, 10) * cellSize + cellSize/2;
    int y = (int)random(3, 10) * cellSize + cellSize/2;
    geister[i] = new Geist(x, y, cellSize);
  }
}
void manageGeister() {

  // Alle 50 Zyklen die Geister bewegen
  boolean move = false;
  if (timer &lt;= 0) {
    move = true;
    timer = 50;
  }
  timer--;

  for (int i = 0; i &lt; geister.length; i++) {
    if (move) {
      geister[i].move();
    }
    geister[i].draw();

    boolean eaten = geister[i].tryToEat(pacman);
    if (eaten) {
      leben--;

      // Pacman wieder oben links erscheinen lassen
      int x = cellSize/2;
      int y = cellSize/2;
      pacman.x = x;
      pacman.y = y;
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>PLEASE HELP US! (Pacman)</title>
      <link>https://forum.processing.org/two/discussion/15134/please-help-us-pacman</link>
      <pubDate>Fri, 26 Feb 2016 09:52:13 +0000</pubDate>
      <dc:creator>TEAMpac</dc:creator>
      <guid isPermaLink="false">15134@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone, we are a group of students who are working on processing to try to do a pacman game (it's a school project). As the original one, we were thinking about setting up a labyrinth, with a pacman and ghosts inside. However, we have some problems when trying to do the program in processing:</p>

<p>-How could we manage to make the pacman going through the labyrinth (white path) without getting a out of it (black stroke). I mean, the path would be colored in white, while the walls would be colored in black.</p>

<p>-How could we manage to know the ubication of a pixel ?(is there a processing fonction/reference that allows us to know it?)</p>

<p>We would be gratefull if you could help us.</p>
]]></description>
   </item>
   <item>
      <title>I need some help on eating dots in pacman game</title>
      <link>https://forum.processing.org/two/discussion/11169/i-need-some-help-on-eating-dots-in-pacman-game</link>
      <pubDate>Fri, 05 Jun 2015 15:03:20 +0000</pubDate>
      <dc:creator>lolnyancats</dc:creator>
      <guid isPermaLink="false">11169@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to initialize the dots, should i have them in an array? how do i remove the ones that i am on top of?</p>
]]></description>
   </item>
   </channel>
</rss>