<?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 #game - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/p2/feed.rss?Tag=%23game</link>
      <pubDate>Sun, 08 Aug 2021 15:34:27 +0000</pubDate>
         <description>Tagged with #game - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23game/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Bullets and Characters</title>
      <link>https://forum.processing.org/two/discussion/16629/bullets-and-characters</link>
      <pubDate>Sun, 15 May 2016 21:52:30 +0000</pubDate>
      <dc:creator>Kraken</dc:creator>
      <guid isPermaLink="false">16629@/two/discussions</guid>
      <description><![CDATA[<p>So what I'm trying to do with my code is have continuous bullets shooting down from the guns that the soldiers are holding, and I want to create a character at the bottom of the wall that I can control with all four arrow keys and have it avoid the bullets coming from the guns. Because the goal is to have that character reach the top of the wall and then the wall should increase when my character reaches the top.</p>

<p>Please help! This is super important and I'm kinda new to Processing.</p>

<p>Here's my code so far with my brick wall and soldiers:</p>

<pre><code>PImage soldier;  
int numBrickRows = 10;
int pixelsize = 4;
int brickWidth = 50;
int brickHeight = 20;
int c = 16;
int d = 5; 
int e = 253;
int f = 60;
int g = 80;
ArrayList bullets = new ArrayList(); 

Brick[] bricks = new Brick[0];


void setup() {
  size(400,400);
  background(255); 
  soldier = loadImage("soldier.jpeg"); 
  soldier(); 
  smooth();  
  for (int j=0; j &lt; numBrickRows; j++) 
  { 

    int y = brickHeight * c + j * brickHeight;
    int offset = 0;
    if (j % 2 == 0) {
      offset = brickWidth / 2;
    }
    for (int i=offset; i &lt; width+brickWidth/2.0; i += brickWidth) { // columns
      bricks = (Brick[]) append(bricks, new Brick(i,y));
    }
  }
}

void draw() {
  for (int i=0; i &lt; bricks.length; i++) {
    if (bricks[i] != null) {
      bricks[i].draw();
    }
  }
}

class Brick {
  int xPosition;
  int yPosition;
  color c;

Brick(int x, int y) {
    xPosition = x;
    yPosition = y;
    c = color(107, 115, 117);
  }

  void draw() {
   rectMode(CENTER);
   fill(c);
   rect(xPosition, yPosition, brickWidth, brickHeight);   
  }  
}

void soldier()
{
  image(soldier,d,e,f,f); 
  image(soldier,d+g,e,f,f); 
  image(soldier,d+2*g,e,f,f); 
  image(soldier,d+3*g,e,f,f); 
  image(soldier,d+4*g,e,f,f); 

}
</code></pre>

<p>Image: <img src="http://cdn1.bigcommerce.com/n-yp39j5/3gukwsep/products/1034/images/1536/a6473ab13f36ea9dd1b33_l__60025.1383060465.190.250.jpg?c=2" alt="" /></p>
]]></description>
   </item>
   <item>
      <title>The book of making games with processing</title>
      <link>https://forum.processing.org/two/discussion/15761/the-book-of-making-games-with-processing</link>
      <pubDate>Wed, 30 Mar 2016 10:05:10 +0000</pubDate>
      <dc:creator>n_ryota</dc:creator>
      <guid isPermaLink="false">15761@/two/discussions</guid>
      <description><![CDATA[<p>Hello.
I wrote the book of making games with processing. 
(Japanese version only)</p>

<h2>Book (biginner)</h2>

<p><span class="VideoWrap"><span class="Video YouTube" id="youtube-ZXN9XD9o_4E"><span class="VideoPreview"><a href="http://youtube.com/watch?v=ZXN9XD9o_4E"><img src="http://img.youtube.com/vi/ZXN9XD9o_4E/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span>
Details: <a href="http://dev.eyln.com/book2.html" target="_blank" rel="nofollow">http://dev.eyln.com/book2.html</a></p>

<h2>Book (intermediate)</h2>

<p><span class="VideoWrap"><span class="Video YouTube" id="youtube-XHoAr1-ZwNg"><span class="VideoPreview"><a href="http://youtube.com/watch?v=XHoAr1-ZwNg"><img src="http://img.youtube.com/vi/XHoAr1-ZwNg/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span>
Details: <a href="http://dev.eyln.com/book.html" target="_blank" rel="nofollow">http://dev.eyln.com/book.html</a></p>

<p>I am a game developer.
Macross VO, Naval Ops: Warship Gunner, Super Smash Bros. Brawl X. ...etc.</p>

<p>Thanks.</p>
]]></description>
   </item>
   <item>
      <title>Is it possible to deploy a processing module onto a website?</title>
      <link>https://forum.processing.org/two/discussion/15768/is-it-possible-to-deploy-a-processing-module-onto-a-website</link>
      <pubDate>Wed, 30 Mar 2016 15:28:19 +0000</pubDate>
      <dc:creator>AmyM</dc:creator>
      <guid isPermaLink="false">15768@/two/discussions</guid>
      <description><![CDATA[<p>I am required for one of my projects to deploy the game I created in processing onto my website. I am using nodejs to build the site.</p>
]]></description>
   </item>
   <item>
      <title>Help with space invaders game</title>
      <link>https://forum.processing.org/two/discussion/14897/help-with-space-invaders-game</link>
      <pubDate>Sat, 13 Feb 2016 22:19:48 +0000</pubDate>
      <dc:creator>Jim1597</dc:creator>
      <guid isPermaLink="false">14897@/two/discussions</guid>
      <description><![CDATA[<pre><code>//NOT PROPERLY WORKING ARRAY
int cols= 3; 
int rows=2; 
//int cols_select; 
//int rows_select; 

Alien[][] aliens = new Alien[cols][rows]; 

PImage background;
int y=0;
int bulletX;
int bulletY;
int score=0;
int alienx;
int alieny;

final int NORMAL=0;
final int CRASHED=1;
int gameMode=NORMAL;

//calling the constractors
   //!ALIENS!
   //Alien alien1=new Alien(200,30);
   //Alien alien2=new Alien(400,30);
   //Alien alien3=new Alien(600,30);
   //Alien alien4=new Alien(200,130);
   //Alien alien5=new Alien(400,130);
   //Alien alien6=new Alien(600,130);

   //!DEFENDER!
   Defender defender1;

   //!BULLET!
   bullet  bullet1;

void setup()
{
  bulletX=0;
  bulletY=-100;
  size(1000,800);
  background=loadImage("bg1.jpg");
  image(background,0,0);
  background.resize(width,height);//resize the image to the size of my background
 // bullets=new ArrayList();

    //NOT PROPERLY WORKING ARRAY
    //creating the array
     for (int i=0; i&lt; cols; i++){ 
      for (int j=0; j&lt;rows; j++){ 
        aliens[i][j] = new Alien(alienx,alieny); 
        alienx=alienx+70;
        alieny=alieny+20;
       }
      } 
  bullet1=new bullet(bulletX,bulletY);
  defender1=new Defender(320,450);  

}//end of setup

void draw()
{
  if (gameMode==NORMAL)
  {
    background(255);
    image(background,0,y);
    image(background,0,y+height);
    y=y-10;

    if (y==-background.height)
    {
      y=0;
    }

  //  for (int i=0; i&lt;bullets.size(); i++)
    //{
      //bullet.update();
    //}

    //alien1.update();
    //alien2.update();
    //alien3.update();
    //alien4.update();
    //alien5.update();
    //alien6.update();

    //NOT WORKING PROPERLY ARRAY
   for (int i=0; i&lt; cols; i++){ 
    for(int j=0; j&lt;rows; j++){ 
      aliens[i][j].update();
   }
    }    


   // boolean AlienOnScreen;
   // AlienOnScreen=alien1.update();
    //AlienOnScreen=alien2.update();
    //AlienOnScreen=alien3.update();


    //  if (AlienOnScreen==false)
      //{
        //alien1=new Alien(200,30);
        //alien2=new Alien(400,30);
        //alien3=new Alien(600,30);
      //}

      defender1.render();
      bullet1.update();

      textSize(30);
      fill(255);
      text("SCORE:"+score,30,30);

      if (defender1.crash()||(bullet1.crash())==true)
      {
        //fill(255);
        //text("YOUR SCORE IS:",score,220,420);

        fill(255,0,0);
        textSize(30);
        text("GAME OVER PRESS R TO TRY AGAIN",240,400);
        gameMode=CRASHED;
      }    

       if (defender1.crash()||(bullet1.crash())==true)
      {
        score=score+50;
      }
  }
}

  void keyPressed()
  {
    if (key==CODED)
    {
      if (keyCode==UP &amp;&amp; defender1.y&gt;=400)
      {
        defender1.y=defender1.y-10;
      }
      else if (keyCode==DOWN &amp;&amp; defender1.y&lt;=height-260)
      {
        defender1.y=defender1.y+10;
      }
      else if (keyCode==RIGHT &amp;&amp; defender1.x&lt;width-130)
      {
        defender1.x=defender1.x+20;
      }
      else if (keyCode==LEFT &amp;&amp; defender1.x&gt;15)
      {
       defender1.x=defender1.x-20;
      }
    }
          if (key=='r' &amp;&amp; gameMode==CRASHED)
          {
              gameMode=NORMAL;

             // alien1=new Alien(200,30);
             // alien2=new Alien(400,30);
             // alien3=new Alien(600,30);
              //alien4=new Alien(200,130);
              //alien5=new Alien(400,130);
              //alien6=new Alien(600,130);

              //aliens[i][j].update();    

          bullet1=new bullet(bulletX+1000,bulletY+1000);
          defender1=new Defender(320,450);

         }

    if (key==' ')
    {
      bulletX=defender1.x+75;
      bulletY=defender1.y;

      bullet1=new bullet(bulletX, bulletY);
     // bullet2=new bullet(bulletX, bulletY);

    }  
} 
</code></pre>

<p>Here is my alien class:</p>

<pre><code>class Alien 
{
  int y=100;
  int x=10;
  int v=5;

  Alien (int x ,int y)
  {
    this.x=x;
    this.y=y;
  }

//boolean move()
//{
  //y=y+1;
  //x=x;

  //if (y&gt;=0)
  //{
    //return true;
  //}
  //else 
 // {
   //return false;

  //}
//}//end of the boolean

   void move ()
  {

    x=x+v;  // which direction the alien is moving

    if(x&gt; width - 25)

    { 
      v = -5;
      y = y+30;
    }
    if (x==25)
    {
      v =+5;
      y= y+30;
    }

  }//end of move

void create()
{
    fill(255,255,255);
    ellipse(x,y,45,50);
    fill(255,0,0);
    ellipse(x,y,60,25);
}

void update()
{
  create();
  move();
  //y=y+50;

}
}//end of class
</code></pre>

<p>i want to get 3 columns with 2 rows of aliens in fixed place with a simple moving pattern for some reason tho i cant get them to display properly with are going diagonally and the other problem that i have is when i try to press "r" and restart the game and set the aliens in the same place where they start it wont work they just keep going from where they left</p>

<p>Any help would be appreciated thanks in advance can put all the code if someone wants to check it</p>
]]></description>
   </item>
   <item>
      <title>Working with spritesheets and if statement (Solved)</title>
      <link>https://forum.processing.org/two/discussion/14399/working-with-spritesheets-and-if-statement-solved</link>
      <pubDate>Mon, 11 Jan 2016 18:18:11 +0000</pubDate>
      <dc:creator>keijioch</dc:creator>
      <guid isPermaLink="false">14399@/two/discussions</guid>
      <description><![CDATA[<p>Hi! I just started with processing and I am trying to make a game. Now I have added two sprite sheets. One to let my character walk and one for letting him wield a sword. That went pretty fine, but now I have trouble with switching between these spritesheets. I want to let the guy stand still when he is not swinging a sword and is not moving, so I created an if-statement. But this one does not seem to work, and I do not know why. If I run the code, the guy is standing still as it use to and I can swing the sword by pressing spacebar. I want him to stop swinging the sword when spacebar is released, but then the guy dissappears. It seems to me that the boolean for swinging is never set to false again.</p>

<p>Can someone please help me with this? I would be so happy (:</p>

<pre><code>class Player {
  float x, y;
  PImage spriteSheet1;
  PImage spriteSheet2;
  PImage [][] movement; // two dimensional array
  PImage [][] slash;
  boolean moving, slashing;
  int direction;
  float currentFrame, currentFrame2, beginSlashingFrame;


  final int DOWN = 0, LEFT = 1, UP = 2, RIGHT = 3; // cannot be changed

  Player() {
    moving = false;
    slashing = false;
    direction = 1; //facing to the left
    currentFrame = 0;
    x = 300;
    y = 300;

    setupSprites();
  }

  void setupSprites() {
    movement = new PImage[4][9]; // 4 rows and 9 columns
    spriteSheet1 = loadImage("movement2.png");
    for (int i = 0; i &lt; 9; i++) {
    movement[0][i] = spriteSheet1.get(2 + 30 * i, 0, 18, 26);
    movement[1][i] = spriteSheet1.get(0 + 30 * i, 30, 22, 29);
    movement[2][i] = spriteSheet1.get(0 + 30 * i, 63, 20, 26);
    movement[3][i] = spriteSheet1.get(0 + 30 * i, 94, 22, 29);
    movement[0][i].resize (0, 40);
    movement[1][i].resize (0, 40);
    movement[2][i].resize (0, 40);
    movement[3][i].resize (0, 40);
    }

    slash = new PImage[4][5];
    spriteSheet2 = loadImage("slash3.png");
    for (int i = 0; i &lt; 5; i++) {
    slash[0][i] = spriteSheet2.get(33 * i, 0, 30, 32);
    slash[1][i] = spriteSheet2.get(32 * i, 35, 30, 29);
    slash[2][i] = spriteSheet2.get(32 * i, 65, 29, 30);
    slash[3][i] = spriteSheet2.get(32 * i, 97, 33, 33);
    slash[0][i].resize (0, 50);
    slash[1][i].resize (0, 42);
    slash[2][i].resize (0, 44);
    slash[3][i].resize (0, 50);    
   }    
  }

void drawPlayer() { // a guy with fancy footwork
  if(moving)
        image(movement[direction][1 + int(currentFrame)], x, y); 
      else if (moving == false &amp;&amp; slashing == false) 
        image(movement[direction][0], x, y);



}   


  void updatePlayer(int xDelta, int yDelta) {
   currentFrame = (currentFrame + 0.2) % 8;
   currentFrame2 = (currentFrame2 + 0.15)% 4;
   moving = true; 

    if(xDelta == 0 &amp;&amp; yDelta == 0) 
      moving = false;  
    else if(xDelta == -1) 
      direction = LEFT;
    else if(xDelta == 1)
      direction = RIGHT;
    else if(yDelta == -1)
      direction = UP;
    else if(yDelta == 1)
      direction = DOWN;


    x = x + xDelta;
    y = y + yDelta;
  }

  void Slash() {
  beginSlashingFrame = 0;

   if(currentFrame2 &lt; beginSlashingFrame + 4 ) {
         slashing = true;    
         image(slash[direction][1 + int(currentFrame2)], x - 12, y);   
   }         
      else
      slashing = false; 
      // it does not see it as false?
  }

  }





boolean [] keys = new boolean[128]; //ASCII -&gt; all the different keys
Player player;


void setup() {
  size(600, 600);
  player = new Player();
  keys = new boolean[128]; // initialize inside setup
  frameRate(60);
}

void draw() {
  background(99);
  move();
  player.drawPlayer();
}

void move() {
  int xDelta = 0; // change in movement
  int yDelta = 0; 

  if (keys['a'])
  xDelta--;

  if (keys['d'])
  xDelta++;

  if (keys['w'])
  yDelta--;

  if (keys['s'])
  yDelta++;

  if (keys[' ']) 
  player.Slash();



  player.updatePlayer(xDelta, yDelta);
}

void keyPressed() {
  keys[key] = true; // key is also decimal
}

void keyReleased() {
  keys[key] = false;

 }
</code></pre>

<p><img src="https://forum.processing.org/two/uploads/imageupload/965/0573K75QX6VX.png" alt="movement2" title="movement2" /></p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/381/MGMLO6VHI2CF.png" alt="slash3" title="slash3" /></p>
]]></description>
   </item>
   <item>
      <title>How do I let the rocket move correctly?</title>
      <link>https://forum.processing.org/two/discussion/14394/how-do-i-let-the-rocket-move-correctly</link>
      <pubDate>Mon, 11 Jan 2016 14:28:40 +0000</pubDate>
      <dc:creator>immmie</dc:creator>
      <guid isPermaLink="false">14394@/two/discussions</guid>
      <description><![CDATA[<p>Uhm, hey. Well I am new to processing and for a school project we need to make something interactive. I want to make a rocket that moves from the left to the right and blows up meteorites that come falling from above. (Sorry, for bad english btw).</p>

<p>I do not have a lot of code right at the moment, because I do not know how to fix what I already have. I got to questions:</p>

<ol>
<li><p>How do I fix that the rocket still moves after it reached the ends of the frame?</p></li>
<li><p>How do I fix that the rocket won't leave the frame? The rocket stops when I told him to stop, but if I press the keys again it will slowly leave. Because my dX changes from 0 to 5.</p></li>
</ol>

<p>Can someone please help me?</p>

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

<pre><code>//The picture of the galaxy was found on <a href="https://en.wikipedia.org/wiki/Carina_Dwarf_Spheroidal_Galaxy" target="_blank" rel="nofollow">https://en.wikipedia.org/wiki/Carina_Dwarf_Spheroidal_Galaxy</a>. It is a picture of a Carina Dwarf Speroidal Galaxy. It was discovered in 1977.
//The picture of the rocket was found on <a href="http://pics-about-space.com/nasa-space-ship-clip-art?p=2" target="_blank" rel="nofollow">http://pics-about-space.com/nasa-space-ship-clip-art?p=2</a>.


PImage galaxy;    //image of a galaxy I used
PImage rocket;    //image of a rocket I used
int x=250;  //beginning of the rocket when first clicked on play
int dX = 5; //the number used for dX

void setup(){
  size(750,900); //the size of the frame

  //the galaxy image
  galaxy = loadImage("galaxy background.jpg"); //the image I am going to use as a galaxy background needs to be loaded
  galaxy.resize(750,900); //the image has to have the same size as the file, so I resized the image

  //the rocket image
  rocket = loadImage("spaceship.png"); //the image I am going to use as therocket needs to be loaded
  rocket.resize(300,250); //the image needs to be resized
}

void draw(){
    background(galaxy); //the file has a galaxy background
  //the rocket
  image(rocket,x,650); //the x is variable, so the rocket can move. 

  keyPressed(); //i don't know why this is here, but a friend of me told me to put it there
}

void keyPressed(){ //everything in here happens when a key is pressed
  if (key == CODED){  //now I can go code some keys
    if (keyCode == RIGHT){ //the arrow to the right is now coded
      x = x + dX; //this is the formula of the x
    }
    if (x+200&gt;width || x+100&lt;0){ //the rocket won't leave the frame 
      dX=0; //--&gt; there must be something else to stop my rocket from moving
    } 
    if (keyCode == LEFT){ //the arrow to the left is now coded
      x = x - dX; //this is the formula of the x
    }
    if (x+200&gt;width || x+100&lt;0){ //the rocket won't leave the frame
      dX=0; //--&gt; there must be something else to stop my rocket from moving
    }
  }

}

void keyReleased(){ //everything in here happens when a key is released
  if (key == CODED){
    if (keyCode == RIGHT){
      x=x+dX;
      dX=0;
    }
    else{ 
       dX=5;
  }
  if (keyCode == LEFT){
    dX=0;
  }
  else {
    dX=5;
  }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Help resetting game</title>
      <link>https://forum.processing.org/two/discussion/14384/help-resetting-game</link>
      <pubDate>Sun, 10 Jan 2016 20:18:19 +0000</pubDate>
      <dc:creator>AmazingSuperDry</dc:creator>
      <guid isPermaLink="false">14384@/two/discussions</guid>
      <description><![CDATA[<p>Really need some help with an IF statement that would restart this simple ball game after the ball leaves the screen.</p>

<pre><code>float x = 200;
float y = 200;
float spdX = random (3, 5); 
float spdY = random (3, 5); 
float r = random (20, 255); 
float g = random (20, 255); 
float b = random (20, 255); 
int sky; 
int chop = 200; 
float BOP; 
boolean animation =false; 



void setup() { 
  size (1250, 500); 

  smooth(); 
}

void draw() { 
  background(0, 0, 0);
  sky=20; 
  ellipse(x, y, sky, sky); 

  fill(r, g, b); 
  rect(0, 0, 20, height); 
  fill(r, g, b); 
  rect(width-30, mouseY-chop/2, 10, chop);


  if (animation) { 

    x = x + spdX; 
    y = y + spdY; 

    if (x&gt;width-30 &amp;&amp; x&lt;width -20 &amp;&amp; y&lt;mouseY+BOP &amp;&amp; y&gt;mouseY-chop/2) {
      spdX=spdX*-1; 
      x=x +spdX;

      BOP =random(60, 100); 
      chop=chop-20; 
      chop= constrain(chop, 10, 150);
    } else if (x&lt;25) { 
      spdX = spdX * -1.1;
      x = x + spdX;

      if (x &gt; width-2) { //THIS IS THE RESTART GAME IF STATEMENT THAT ISN'T WORKING!!!
        animation = false;
        x = 150;
        y = 150; 
        spdX = random(3, 5);
        spdY = random(3, 5);

         }

      if ( y &gt; height || y &lt; 0 ) {
        spdY = spdY * -1;
        y = y + spdY;
      }
    }
  }

  if (y+spdY&gt;height||y&lt;0) {
    spdY*=-1;
    r =random(0, 255);
    g =random(0, 255);
    b =random(0, 255);
  }
}
void mousePressed () { 
  animation=true;
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Erase Game</title>
      <link>https://forum.processing.org/two/discussion/14255/erase-game</link>
      <pubDate>Mon, 04 Jan 2016 15:13:59 +0000</pubDate>
      <dc:creator>cameyo</dc:creator>
      <guid isPermaLink="false">14255@/two/discussions</guid>
      <description><![CDATA[<p>This is a prototype...but i like it :)<br />
Erase the figure as fast as possible...<br />
<img src="https://forum.processing.org/two/uploads/imageupload/712/8K83BVTWGGFG.jpg" alt="forum" title="forum" /><br />
<a rel="nofollow" href="https://www.dropbox.com/s/vwhcdaelzedef4q/eraseGame2.zip?dl=0">Download (version 2)</a><br />
p.s. Tell me what you think (if you have time) ;)</p>
]]></description>
   </item>
   <item>
      <title>Basic Game</title>
      <link>https://forum.processing.org/two/discussion/14236/basic-game</link>
      <pubDate>Sun, 03 Jan 2016 16:56:15 +0000</pubDate>
      <dc:creator>rob88</dc:creator>
      <guid isPermaLink="false">14236@/two/discussions</guid>
      <description><![CDATA[<p>Hello!</p>

<p>I need some help creating a game if possible, I started taking lessons in processing at school recently and I had some team project where I recently found out that I am the only one that did his part and I kinda found myself short on time to finish it all by myself and I can't figure it out;
Here's what I managed to do untill now:</p>

<p><strong>1. Red Moving Bar(Arrow Keys)</strong></p>

<p>int px=350;
  int py=750;
  int taillex=100;
  int tailley=25;
  int level;</p>

<p>// PALET
void palet() {
  fill(255,0,0);
  rect(px,py,taillex,tailley);
}
// keyPressed
// LEFT RIGHT
void keyPressed() {
  if (key == CODED) {
    if(keyCode == LEFT) {
      px=px-5; }
    if(keyCode == RIGHT) {
      px=px+5; }
  }
  if (px&lt;0) {px=699;}
  if (px&gt;700) {px=0;}
// Q D
if (keyPressed) {
  if (key == 'q' || key == 'Q') {
    px=px-5; }
   if (key == 'd' || key == 'D') {
    px=px+5;}
 }
}</p>

<p>// BALL
void ball() {
 int ballx=400;
 int ballsize=25;
 int bally=50;
 float ballcolor=random(255);
fill (ballcolor);
ellipse(ballx,bally,ballsize,ballsize);
while(bally&lt;height) {bally=bally++;}</p>

<p>}
void setup () {
  size (800,800);
  background(255);
}
void draw () {
  background(255);
  palet ();
  keyPressed ();</p>

<p>}</p>

<p><strong>2.Switch Screen</strong></p>

<p>int level=0;
void draw () {
 if(level==0){
  open();
 }
else if(level==1){
 game();
}
else {gameover();
}
}</p>

<p>void open () {
if (buttonpressed()){
  level++;
}</p>

<p>}
boolean buttonPressed () {
 if (x&lt;mouseX et mouseX&lt;x+hy et y&lt;mouseY et mouseY&lt;y+hhy et mousePressed){
   return true;
 }
}</p>

<p>I'm basically trying to make a simple game where you have to either bounce balls off or avoid them, becoming a bit harder over time
The level part is basically trying to get a screen in the beginning with something like press here/any key to start and then game over, press here to try again</p>

<p>Thanks for the help!</p>
]]></description>
   </item>
   <item>
      <title>Creating A 2D and 3D Shapes Game</title>
      <link>https://forum.processing.org/two/discussion/14235/creating-a-2d-and-3d-shapes-game</link>
      <pubDate>Sun, 03 Jan 2016 14:40:12 +0000</pubDate>
      <dc:creator>Mohab87</dc:creator>
      <guid isPermaLink="false">14235@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys,</p>

<p>I'm working on developing an educational game using processing which will utilize 2D and 3D shapes</p>

<p>The game is for my Novel Interaction Design course. 
I know that this might be too specific but I hope someone can help with this.
I went through a lot of tutorials online but I can't seem to find anything specific to help with coding the game.</p>

<p>The game is a simple 3 stage game which will use Tracked Objects for 2 stages (1 stage for 2D and one for 3D) where the player will drag a shape onto the screen and the info about the shape will be presented (similar to the TUIO simulator model) and the final third stage would let the user play a game similar to the Food Catcher game template but with 2D and 3D shapes instead.</p>

<p>Any help will be greatly appreciated as I'm running close to deadline and cant seem to figure it out on my own.</p>
]]></description>
   </item>
   <item>
      <title>'shivering' of object when touching surface</title>
      <link>https://forum.processing.org/two/discussion/14212/shivering-of-object-when-touching-surface</link>
      <pubDate>Fri, 01 Jan 2016 03:04:02 +0000</pubDate>
      <dc:creator>Aeglos</dc:creator>
      <guid isPermaLink="false">14212@/two/discussions</guid>
      <description><![CDATA[<p>So I made a fairly simple maze game that prevents a dot from touching the 'walls' by checking if it within coordinates and then moving it towards the nearest edge. I have to move it away fairly quickly to counteract the speed that it is hitting the wall. This causes it to jump back and forth which doesn't look very nice. Any suggestions on fixing this?</p>

<p>code:</p>

<pre><code>//scene
int[] posX;
int[] posY;
int[] posW;
int[] posH;
int offX;
int offY;

//dot
int x = 320;
int y = 180;
int contX = 1;
int contY = 1;

//stats
int[] var;

void setup() {

  size(640, 360);
  fill(117, 117, 163);
  noStroke();
  orientation(LANDSCAPE);

  String[] tempX = loadStrings("world/posX.txt");
  posX = int(split(tempX[0],','));
  String[] tempY = loadStrings("world/posY.txt");
  posY = int(split(tempY[0],','));
  String[] tempH = loadStrings("world/posH.txt");
  posH = int(split(tempH[0],','));
  String[] tempW = loadStrings("world/posW.txt");
  posW = int(split(tempW[0],','));
  String[] tempV = loadStrings("world/var.txt");
  var = int(split(tempV[0],','));
}

void draw() {

  background(0, 0, 0);

  scene();

  check();

  movement();



}

void scene(){

  ellipse(x, y, 10, 10);

  for (int i = 0; i &lt; var[0]; i++) {
    rect(posX[i], posY[i], posW[i], posH[i]);
  }
}

void check() {
  for (int i = 0; i &lt; var[0]; i++) {

    int top = posY[i];
    int bottom = posY[i] + posH[i];
    int left = posX[i];
    int right = posX[i] + posW[i];

    if(x &gt; posX[i] &amp;&amp; x &lt; posX[i] + posW[i] &amp;&amp; y &gt; posY[i] &amp;&amp; y &lt; posY[i] + posH[i]) {

      int mT = y - top;
      int mB = bottom - y;
      int mL = x - left;
      int mR = right - x;

      if (mT &lt; mB &amp;&amp; mT &lt; mL &amp;&amp; mT &lt; mR) {
        contY = 0;
        offY = offY + 4;
      }
      if (mB &lt; mL &amp;&amp; mB &lt; mR &amp;&amp; mB &lt; mT) {
        contY = 0;
        offY = offY - 4;
      }
      if (mL &lt; mR &amp;&amp; mL &lt; mT &amp;&amp; mL &lt; mB) {
        contX = 0;
        offX = offX + 4;
      }
      if (mR &lt; mB &amp;&amp; mR &lt; mL &amp;&amp; mR &lt; mT) {
        contX = 0;
        offX = offX - 4;
      }
      else {
        offX = offX + 2;
        offY = offY - 2;
      }
    }
    else {
      contX = 1;
      contY = 1;
    }
  }
}

void movement() {
  if(mousePressed == true) {

    if (x &gt; mouseX) {
      offX = offX + var[1]*contX;
    }
    if (x &lt; mouseX) {
      offX = offX - var[1]*contX;
    }
    if (y &gt; mouseY) {
      offY = offY + var[1]*contY;
    }
    if (y &lt; mouseY) {
      offY = offY - var[1]*contY;
    }
  }

  for (int i = 0; i &lt; var[0]; i++) {
        posX[i] = posX[i] + offX;
        posY[i] = posY[i] + offY;
  }
    offX = 0;
    offY = 0;

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>problem in card game</title>
      <link>https://forum.processing.org/two/discussion/14215/problem-in-card-game</link>
      <pubDate>Fri, 01 Jan 2016 13:33:32 +0000</pubDate>
      <dc:creator>mahdidev</dc:creator>
      <guid isPermaLink="false">14215@/two/discussions</guid>
      <description><![CDATA[<p>i want to write a card game with processing but i have a problem in distribute cards,cards when distribute may be repeat a card for two players, and I dont know how check it, please help me.</p>

<pre><code>    cards[] player1=new cards[13];
    cards[] player2=new cards[13];
    int[] player1c=new int[13];
    int[] player2c=new int[13];
    int t1;
    int t2;
    int x=20;
    String check;
    void setup() {
      size(860, 650);
      for (int i=0; i&lt;13; i++) {
        t1=(int)random(0, 51);
        player1c[i]=t1;
      }
      for (int i=0; i&lt;13; i++) {
        t2=(int)random(0, 51);
        if(t2!=player1c[i]){
          player2c[i]=t2;
        }
      }
      for (int i=0; i&lt;13; i++) {
        player1[i]=new cards(player1c[i],x,100,0);
        x+=20;
      }
      for (int i=0; i&lt;13; i++) {
       player2[i]=new cards((int)random(0, 51),x,300,0);
       x+=20;
      }
    }

    void draw() {
      background(128,128,128);
       for(int i=0;i&lt;13;i++){
        player1[i].load();
      }
      noLoop();
      for(int i=0;i&lt;13;i++){
        player1[i].display();
      }
      loop();
         for(int i=0;i&lt;13;i++){
        player2[i].load();
      }
      noLoop();
      for(int i=0;i&lt;13;i++){
        player2[i].display();
      }
      loop();
    }
    void mousePressed(){
        for(int i=0;i&lt;13;i++){
          if(mouseX&gt;player1[i].x &amp;&amp; mouseX &lt; player1[i].x+20 &amp;&amp; mouseY&gt; player1[i].y &amp;&amp; mouseY&lt;player1[i].y+150){
            if(player1[i].counter==0){
            player1[i].y-=40;
            player1[i].counter=1;
            }
            else{
              player1[i].y+=40;
              player1[i].counter=0;
            }

          }
        }
      }




    class cards{
      int n;
      int tedad;
      PImage test;
      int x;
      int y;
      int counter;
      String[] cardName={"2d","3d","4d","5d","6d","7d","8d","9d","10d","ad","jd","qd","kd","2p","3p","4p","5p","6p","7p","8p","9p","10p","jp","qp","kp","ap","2kh","3kh","4kh","5kh","6kh","7kh","8kh","9kh","10kh","jkh","qkh","kkh","akh","2g","3g","4g","5g","6g","7g","8g","9g","10g","jg","qg","kg","ag"};

      cards(int n_,int x_,int y_,int counter_){
        n=n_;
        x=x_;
        y=y_;
        counter=counter_;
      }
      void load(){
          test=loadImage(cardName[n]+".png");
      }
      void display(){
        image(test,x,y);
      }

    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>How do I make objects stack in my game?</title>
      <link>https://forum.processing.org/two/discussion/14110/how-do-i-make-objects-stack-in-my-game</link>
      <pubDate>Tue, 22 Dec 2015 03:28:24 +0000</pubDate>
      <dc:creator>et47250</dc:creator>
      <guid isPermaLink="false">14110@/two/discussions</guid>
      <description><![CDATA[<p>I am making a game where I have a moving ice cream cone at the bottom of the screen that can be controlled using the left and right arrow keys. The point of the game is to catch randomly spawning ice cream scoops that fall from the top of the window. When the cone checks if the ice cream has hit, it increases the score. If it misses, then it is game over.</p>

<p><strong>Problem:</strong> When the ice cream falls from the top of the screen and the player successfully "catches" it, I want the ice cream to stay on the cone so that as the player continues to catch new ice cream scoops, they will stack on top of one another.</p>
]]></description>
   </item>
   <item>
      <title>Handling World's lifecycle with Hermes library: pause and multiple worlds</title>
      <link>https://forum.processing.org/two/discussion/13795/handling-world-s-lifecycle-with-hermes-library-pause-and-multiple-worlds</link>
      <pubDate>Sat, 05 Dec 2015 22:40:58 +0000</pubDate>
      <dc:creator>sonicdebris</dc:creator>
      <guid isPermaLink="false">13795@/two/discussions</guid>
      <description><![CDATA[<p>I'm prototyping a small multilevel game using Hermes.</p>

<p>I'm trying to figure out the best way to freeze a world when the user wants to pause the game: is there a smart way to do that?</p>

<p>Also, I'm thinking of organizing the game in several worlds (one for each level, plus the intro, and other sections). 
My Idea is that a level that ends will call a worlds "manager" in its shutdown() method, the manager knows what to do and juggles among the various worlds. Does this sound right?</p>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>Help Me With Maze Levels</title>
      <link>https://forum.processing.org/two/discussion/14010/help-me-with-maze-levels</link>
      <pubDate>Wed, 16 Dec 2015 04:53:59 +0000</pubDate>
      <dc:creator>Mlombino</dc:creator>
      <guid isPermaLink="false">14010@/two/discussions</guid>
      <description><![CDATA[<p>I've created a simple maze game. I'm trying to get it so after you reach the designated checkpoint and beat the first level, it loads the next picture and you start the next level. If anyone could help me that would be great. (P.S. the green square on the left is the checkpoint, the one on the right is just to throw people off).</p>

<pre><code>PImage Maze;
PImage Maze2;
PImage Maze3;

int page = 1;
final int maxlevel = 3;

int x = 15;
int y = 40;

void setup()
{
 Maze = loadImage("Maze design 1.png");
 Maze2 = loadImage("Maze Design 2.png");
 Maze3 = loadImage("Maze Design 3.png");
 size(640,480);
}
 void draw(){
 image(Maze,0,0);
  if((x &gt; 111) &amp;&amp; (x &lt; 131) &amp;&amp; (y &gt; 250) &amp;&amp; (y &lt; 270))
   if(page==1) {

 textSize(48);
 textAlign(CENTER);
 fill(250,0,0);
 text("YOU WIN!",width/2,height/2);
 }
 fill(250,0,0);
 noStroke();
 float touch = red(get(x,y));
 ellipse(x,y,10,10);
  fill(0, 250, 0);
  stroke(0);
 rect(320,110,20,20);
 rect(111,250,20,20);

 if(touch &lt;= 200)
 {
 x = 15;
 y = 40;
 }
 println(mouseX + "," + mouseY);
 }
void keyPressed(){
 if((key == CODED) &amp;&amp; (keyCode == UP))
 {
 y-=20;
 }
 if((key == CODED) &amp;&amp; (keyCode == DOWN))
 {
 y+=20;
 }
 if((key == CODED) &amp;&amp; (keyCode == RIGHT))
 {
 x+=20;
 }
 if((key == CODED) &amp;&amp; (keyCode == LEFT))
 {
 x-=20;
 }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How can I make a better cave generator?</title>
      <link>https://forum.processing.org/two/discussion/13987/how-can-i-make-a-better-cave-generator</link>
      <pubDate>Tue, 15 Dec 2015 07:08:58 +0000</pubDate>
      <dc:creator>Althalus7</dc:creator>
      <guid isPermaLink="false">13987@/two/discussions</guid>
      <description><![CDATA[<p>Can someone please help me make a better cave generator?  It would be much appreciated thank you.</p>

<pre><code>void setup() {
  size(800, 500);
}

void draw() {
}

void mouseClicked() {
  gen();
}

void gen() {
  background(0);
  translate(width/2, height/2);
  rotate(PI);
  int w = 10, h = 10;

  for (int i = -width/2; i &lt; width; i += w) {  //GROUND
    for (int j = -height/2; j &lt; int(random(0, h*2)); j += h) {
      fill(127);  //Rock
      rect(i, j, w, h);
    }
  }

  for (int i = -width/2; i &lt; width; i += w) {  //CAVE
    for (int j = -height/2; j &lt; int(random(0, h*2)); j += h) {
      fill(0);  //Cave
      int caveChance = 1000;
      int cave = int(random(caveChance + 1));
      if (cave == caveChance) {
        println(cave);
        for (int k = 0; k &lt; int(random(10, 25))*h; k += h) {
          for (int l = 0; l &lt; int(random(10, 25))*w; l += w) {
            rect(i + l + int(random(10))*w, j + k + int(random(10))*h, w, h);
          }
        }
      }
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Game Help</title>
      <link>https://forum.processing.org/two/discussion/13993/game-help</link>
      <pubDate>Tue, 15 Dec 2015 16:49:37 +0000</pubDate>
      <dc:creator>annmo</dc:creator>
      <guid isPermaLink="false">13993@/two/discussions</guid>
      <description><![CDATA[<p>I'm doing the game project of spaceship moving around the asteroids. The problem is that I can't figure out how make the collision work when the spaceship touches the asteroid and it will say Game Over. Here are the codes. Don't give me some complicated codes. I'm new to this. Thanks! :)</p>

<p>// Main class</p>

<p>PFont font;</p>

<p>Star s1;<br />
Spaceship sP1;
Asteroids a1;</p>

<p>void setup()
{
  size(900, 500);
  background(0);
  colorMode(HSB);</p>

<p>s1 = new Star();<br />
  sP1 = new Spaceship();
  a1 = new Asteroids();
}</p>

<p>void draw()
{
  background(0);
  s1.display();
  sP1.display();
  a1.move();
  a1.display();</p>

<p>if (hit(s))
  {
    println("Game Over");<br />
    youLose();
  }
}</p>

<p>void youLose()
{
  font = loadFont("AdobeFanHeitiStd-Bold-48.vlw");
  textFont(font);
  text("Game Over! Click Mouse to Restart", 26, 30, 260, 200);
}
void reset() 
{
  setup();
}</p>

<p>void mousePressed()
{
  reset();
}</p>

<p>///////////////////////////////////////////////////////
// Asteroids class</p>

<p>class Asteroids
{
  float diam;<br />
  float xPos;<br />
  float yPos;
  float xDir = random(-5, -1);</p>

<p>Asteroids()
  {
    xPos = random(width);<br />
    yPos = random(height);
    diam = random(30.0, 60.0);<br />
  }</p>

<p>void move()
  {
    xPos = xPos + xDir;
    if (xPos &lt; 0)
    {
      xPos = width;
    }
  }</p>

<p>void display()
  {
    fill(#FF0000);
    stroke(#000066);
    ellipse(xPos, yPos, diam, diam);
  }</p>

<p>boolean hit(Spaceship s)
  {
    float distance = dist (s.xPos, s.yPos, this.xPos, this.yPos);
    if (distance &lt; (s.diam + this.diam) / 2.0)
    {
      return true;
    } 
    else
    {
      return false;
    }
  }
}</p>
]]></description>
   </item>
   <item>
      <title>Absolute noob, need help with simple pong game.</title>
      <link>https://forum.processing.org/two/discussion/13985/absolute-noob-need-help-with-simple-pong-game</link>
      <pubDate>Tue, 15 Dec 2015 04:29:09 +0000</pubDate>
      <dc:creator>epichvs</dc:creator>
      <guid isPermaLink="false">13985@/two/discussions</guid>
      <description><![CDATA[<p>I am an absolute beginner at coding in any way shape of form. As a 15-year-old with barely any experience thanks to a bare bones high school class, I decided to take it up as a hobby and it really rubs me the right way. It's a hell of a lot of fun and I hope to someday get as talented as the individuals on this forum. :) My question here is, how do I get the ball to bounce off the right side pedal? It's probably some tiny mistake, but I can't seem to find it. I would highly appreciate any help and possibly tips for a nooby. Please excuse my messy code.</p>

<p>Ninja Edit: To begin each round, you click anywhere. Left is controlled with W and A, while Right is using UP and DOWN. It should go up to 7 points, but there's a bug in there where you can continue playing if you click enough times. :P</p>

<pre><code>float XCoor = (325);
float YCoor = (225);
float xspeed = 0;
float yspeed = 0;
float xspeed2 = xspeed;
float yspeed2 = yspeed;
float XCoor2 = 0;
float YCoor2 = 225;
float XCoor3 = 600;
float YCoor3 = 225;
int score1 = 0;
int score2 = 0;
PFont myFont;

void setup(){
  size(650,450);
  myFont = createFont("Courier Regular", 32);
  textFont(myFont);
  textAlign(CENTER);
}

void draw(){
  background(0);
  fill(255);
  ellipse(XCoor, YCoor, 50, 50);
  fill(255);
  rect(XCoor2, YCoor2, 50, 100);
  fill(255);
  rect(XCoor3, YCoor3, 50, 100);
  XCoor += xspeed;
  YCoor += yspeed;

   if(XCoor&gt;=625){
      xspeed*=-1;
   }
   if(YCoor&gt;=425||YCoor&lt;=25){
      yspeed*=-1;
   }
if(XCoor2 + 50 &gt;= XCoor - 25){
  if(YCoor&gt;=YCoor2 &amp;&amp; YCoor &lt;= YCoor2 + 100){
    xspeed *= -1;
  }
if(YCoor2 + 100 &gt;= YCoor - 25){
  if(XCoor &lt;= XCoor2 &amp;&amp; XCoor &gt;= XCoor2 + 100){
    yspeed *= -1;
 }
}
 if(XCoor3 - 50 &gt;= XCoor - 25){
   if(YCoor&gt;=YCoor3 &amp;&amp; YCoor &lt;= YCoor3 - 100){
     xspeed *= -1;
 }
}
if(YCoor3 - 100 &gt;= YCoor - 25){
  if(XCoor&gt;=XCoor3 &amp;&amp; XCoor &lt;= XCoor3 - 100){
    yspeed *= -1;
  }
 }
}
 if(XCoor+25&gt;=650){
     score1++;
     XCoor=325;
     YCoor=225;
     xspeed=0;
     yspeed=0;
   }

   if(XCoor-25&lt;0){
     score2++;
     XCoor=325;
     YCoor=225;
     xspeed=0;
     yspeed=0;
   }
   text(score1,(width/2)-30, height/12);
   text(score2,(width/2)+30, height/12);
   if(score1==7||score2==7){
   fill(255);
   rect(0,0,650,450);
   fill(0);
   text("Game Over!",width/2,200);
   text("Reboot game to play again",width/2,250);
   }
}

void keyPressed(){
 if(key == 'w'){
     YCoor2 -= 10;
  } 
 if(key == 's'){
    YCoor2 += 10;
  }
 if (key == CODED) {
   if (keyCode == UP) {
    YCoor3 -=10;
   }
   if(keyCode ==DOWN){
    YCoor3 +=10;
  }
 }
}

void keyReleased(){
  if(key == 'w'){
    YCoor2 -= 10;
  }
  if(key == 's'){
    YCoor2 += 10;
  }
    if (key == CODED) {
  if (keyCode == UP) {
    YCoor3 -=10;
  }
  if(keyCode ==DOWN){
    YCoor3 +=10;
  }
 }
}

void mousePressed(){
  if(mousePressed){
    xspeed-=3;
  yspeed+=3.1;
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to bounce ball with borders ?</title>
      <link>https://forum.processing.org/two/discussion/13959/how-to-bounce-ball-with-borders</link>
      <pubDate>Mon, 14 Dec 2015 13:57:23 +0000</pubDate>
      <dc:creator>Darius135</dc:creator>
      <guid isPermaLink="false">13959@/two/discussions</guid>
      <description><![CDATA[<p>Hello pro brothers,
I modified one of the game from proccessing game. But,now I want borders like this.
<a href="http://i76.photobucket.com/albums/j5/Darius25/Borders%20problem_zpsbbwhzq2i.jpg" target="_blank" rel="nofollow">http://i76.photobucket.com/albums/j5/Darius25/Borders problem_zpsbbwhzq2i.jpg</a>
But,how? I'm so noob and I just started to learn processing.Can you pro brothers help me out?
Thank you.</p>

<p>Here are my lines in processing:</p>

<pre><code>boolean gameover= false, right = false, left = false, up = false,down = false, d = false, a = false, w = false, s = false;
int topgoals=0;
int bottomgoals=0;
float changespeed=0;
Paddle bottom;
Ball football;
Paddle top;
void setup()
{
  frameRate(100);
  noStroke();
  football= new Ball();
  bottom=new Paddle();
  top=new Paddle();
  top.y=0;
  bottom.y = 754;
  size(720,760);
}
void keyPressed()
{
  if (keyCode == LEFT)
  {
    left = true;
  }
  if (keyCode == RIGHT)
  {
    right = true;
  }
  if(keyCode == UP)
  {
    up = true;
  }
  if(keyCode == DOWN)
  {
    down = true;
  }
  if (key == 'a')
  {
    a=true;
  }
  if (key == 'd' )
  {
    d=true;
  }
  if (key == 'w')
  {
    w = true;
  }
  if (key == 's')
  {
    s = true;
  }
}
void keyReleased()
{
  if (keyCode == LEFT)
  {
    left = false;
  }
  if (keyCode==RIGHT)
  {
    right = false;
  }
  if (keyCode == UP)
  {
    up = false;
  }
  if (keyCode == DOWN)
  {
    down = false;
  }
  if (key=='a')
  {
    a=false;
  }
  if (key=='d')
  {
    d=false;
  }
  if (key == 'w')
  {
    w = false;
  }
  if (key == 's')
  {
    s = false;
  }
}
void draw()
{
  if (gameover==false)
  {
    background(#00760F);
    fill(#FFFFFF);
    rect(0,0,4,850);
    rect(716,0,4,850);
    bottom.show();
    top.show();
    if (left==true)
    {
      bottom.moveleft();
    }
    if (right==true)
    {
      bottom.moveright();
    }
    if (a==true)
    {
      top.moveleft();
    }
    if (d==true)
    {
      top.moveright();
    }
    football.move();
    football.bounce();
    football.show();
    if (football.n&lt;-8)
    {
      gameover=true;
      bottomgoals++;
    }
    if (football.n&gt;850)
    {
      gameover=true;
      topgoals++;
    }
  }
  else //gameover==true
  {
    background(0);
    fill(255, 0, 0);
    changespeed=0;
    textSize(18);
    text("Top Player's goals: "+topgoals, 15, 290);
    text("Bottom Player's goals: "+bottomgoals, 15, 330);
    textSize(36);
    text("Game over! Click to restart.", 15, 250);
    if (mousePressed==true)
    {
      football.m=int(random(200, 301));
      football.n=int(random(200, 301));
      int xdirection=int(random(2));
      int ydirection=int(random(2));
      if (xdirection==0)
      {
        football.right=true;
      }
      else //xidrection==1
      {
        football.right=false;
      }
      if (ydirection==0)
      {
        football.up=true;
      }
      else //ydirection==1
      {
        football.up=false;
      }
      gameover=false;
    }
  }
}
class Paddle
{
  int x, y;
  Paddle()
  {
    x=360;
  }
  void show()
  {
    fill(#038BFF);
    rect(x, y, 80, 6);
  }
  void moveleft()
  {
    if (x&gt;=0)
    {
      x -= 5;//speed
    }
  }
  void moveright()
  {
    if (x&lt;=635)
    {
      x += 5;//speed
    }
  }
}
class Ball
{
  int m, n;
  boolean up, right;
  Ball()
  {
    m=425;
    n=360;
    up=true;
    right=true;
  }
  void move()
  {
    if (up==true)
    {
      n=int(n-2-changespeed/2);
    }
    else  //up==false
    {
      n=int(n+2+changespeed/2);
    }
    if (right==true)
    {
      m=int(m+2+changespeed/2);
    }
    else  //right==false
    {
      m=int(m-2-changespeed/2);
    }
  }
  void bounce()
  {
    if (get(int(m)-8, int(n))!=color(#00760F))
    {
      right=true;
    }
    if (get(int(m)+8, int(n))!=color(#00760F))
    {
      right=false;
    }
    if (get(int(m), int(n)-8)==color(#038BFF))
    {
      up=false;
    }
    if (get(int(m), int(n)+8)==color(#038BFF))
    {
      up=true;
      changespeed+=1.0/4;
    }
  }
  void show()
  {
    fill(#FF0324);
    ellipse(m, n, 16, 16);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How To Make One Image out of Pixels from Another Image?</title>
      <link>https://forum.processing.org/two/discussion/13879/how-to-make-one-image-out-of-pixels-from-another-image</link>
      <pubDate>Thu, 10 Dec 2015 14:44:31 +0000</pubDate>
      <dc:creator>GoonyKnightMan</dc:creator>
      <guid isPermaLink="false">13879@/two/discussions</guid>
      <description><![CDATA[<p>I have a small game which consists of the player moving around the screen collecting items. I'm working on graphics for each of the 70 items (plus 5 for the terrain and player), and feel that loading 75 images in setup() would look very cluttered.</p>

<p>My goal is to put all of the images on the same png (they're 32x32, so it shouldn't be too large), and have a method that sets the item variable in each point of the map (each is an object that has data pertaining to it's location, whether or not the player or items are on that node, etc.) to a 32x32 square of pixels on the larger image containing all items. Is there a way to do this?</p>
]]></description>
   </item>
   <item>
      <title>Creating a Puzzle Game</title>
      <link>https://forum.processing.org/two/discussion/13745/creating-a-puzzle-game</link>
      <pubDate>Wed, 02 Dec 2015 14:35:31 +0000</pubDate>
      <dc:creator>lwillms</dc:creator>
      <guid isPermaLink="false">13745@/two/discussions</guid>
      <description><![CDATA[<p>I am creating a puzzle game, except my pieces are not showing up on the level screen and when they do I am not able to drag them. Help please.</p>

<p>// Global Variables
import ddf.minim.*;
AudioPlayer player;
Minim minim;</p>

<p>PImage imgB1;
int value = 0;
int clickedCount = 0;
int x;
int y;
boolean shapeSelected;</p>

<p>boolean shapeGenerated = false;</p>

<p>int [] type = new int[100];
int [][] coordinate = new int[100][2];</p>

<p>int selectedSquare = -1;
Shape [] square = new Shape [100];</p>

<p>/*setup() sets the size of the window, and holds the backgorund image. */
void setup() 
{
  minim = new Minim(this);
  player = minim.loadFile("Jack's Mannequin - Dark Blue (8 bit).mp3", 2048);
  player.play();</p>

<p>for (int i = 0; i &lt; 100; i++)
  {
    square[i] = new Shape (0, 0, 0);
  }</p>

<p>size(600, 600);
  imgB1 = loadImage("puzzle.jpg");
}</p>

<p>// draw() includes all of the different backgrounds that will be used throughtout the code, each of which are defined below.
/* draw() is a continuous loop which will continue to redraw each of the backgrounds throughout the code*/
void draw() 
{
  if (clickedCount == 0)
  {
    mainScreen();
  }
  if (clickedCount == 1)
  {<br />
    ruleScreen();
  }</p>

<p>if (clickedCount == 2)
  {
  {
     if (shapeGenerated == false)
    {</p>

<pre><code>  square[22].numShape = 12;
  square[22].x = 20;
  square[22].y = 100;

  square[23].numShape = 0;
  square[23].x = 110;
  square[23].y = 100;

  square[24].numShape = 0;
  square[24].x = 180;
  square[24].y = 100;

  square[25].numShape = 1;
  square[25].x = 20;
  square[25].y = 190;

  square[26].numShape = 1;
  square[26].x = 65;
  square[26].y = 190;

  square[27].numShape = 1;
  square[27].x = 110;
  square[27].y = 190;

  square[28].numShape = 1;
  square[28].x = 155;
  square[28].y = 190;

  square[29].numShape = 1;
  square[29].x = 200;
  square[29].y = 190;

  square[30].numShape = 13;
  square[30].x = 20;
  square[30].y = 240;

  square[31].numShape = 14;
  square[31].x = 90;
  square[31].y = 240;

  square[32].numShape = 7;
  square[31].x = 140;
  square[31].y = 240;

  square[32].numShape = 7;
  square[32].x = 170;
  square[32].y = 240;

  square[33].numShape = 9;
  square[33].x = 200;
  square[33].y = 240;
}



shapeGenerated = true;
</code></pre>

<p>}
  Level1();
  }</p>

<p>if (clickedCount == 3)
{
  Level2();
  {</p>

<p>if (shapeGenerated == false)
  {</p>

<pre><code>square[0].numShape = 0;
square[0].x = 20;
square[0].y = 100;

square[1].numShape = 0;
square[1].x = 85;
square[1].y = 100;

square[2].numShape = 0;
square[2].x = 150;
square[2].y = 100;

square[3].numShape = 0;
square[3].x = 215;
square[3].y = 100;

square[4].numShape = 1;
square[4].x = 20;
square[4].y = 165;

square[5].numShape = 1;
square[5].x = 73;
square[5].y = 165;

square[6].numShape = 1;
square[6].x = 126;
square[6].y = 165;

square[7].numShape = 1;
square[7].x = 179;
square[7].y = 165;

square[8].numShape = 1;
square[8].x = 232;
square[8].y = 165;

square[9].numShape = 2;
square[9].x = 20;
square[9].y = 210;

square[10].numShape = 3;
square[10].x = 90;
square[10].y = 210;

square[11].numShape = 4;
square[11].x = 180;
square[11].y = 210;

square[12].numShape = 5;
square[12].x = 180;
square[12].y = 235;

square[13].numShape = 6;
square[13].x = 20;
square[13].y = 260;

square[14].numShape = 7;
square[14].x = 50;
square[14].y = 260;

square[15].numShape = 8;
square[15].x = 80;
square[15].y = 260;

square[16].numShape = 9;
square[16].x = 110;
square[16].y = 260;

square[17].numShape = 9;
square[17].x = 140;
square[17].y = 260;

square[18].numShape = 9;
square[18].x = 170;
square[18].y = 260;

square[19].numShape = 10;
square[19].x = 200;
square[19].y = 260;

square[20].numShape = 11;
square[20].x = 110;
square[20].y = 310;

square[21].numShape = 11;
square[21].x = 110;
square[21].y = 340;
</code></pre>

<p>}</p>

<p>shapeGenerated = true; 
}
}
}</p>

<p>//This sets the program up to be able to change backgrounds everytime a key is pressed.
void keyPressed() 
{
  clickedCount++;
}</p>

<p>//This is the code for the mainscreen background
void mainScreen()
{
  background(214);
  image(imgB1, 0, 0);</p>

<p>PFont font;
  font = createFont("BradleyHandITCTT-Bold", 50);
  textFont(font);
  textAlign(CENTER, CENTER);
  fill(255);
  text("Puzzle Buzzle", 300, 100);
  textAlign(CENTER);</p>

<p>font = createFont("BradleyHandITCTT-Bold", 30);
  textFont(font);
  textAlign(CENTER, BOTTOM);
  fill(0, 100, 300);
  text("press any key to begin", 300, 550);
}</p>

<p>//after a key is pressed the program will change to the next page, the rule page, which is setup as follows.
void ruleScreen()
{
  background(0, 150, 200);
  PFont font;
  font = createFont("BradleyHandITCTT-Bold", 50);
  textFont(font);
  font = createFont("BradleyHandITCTT-Bold", 40);
  textFont(font);
  fill(255);
  text("Rules", 300, 90);
  textAlign(CENTER);
  font = createFont("BradleyHandITCTT-Bold", 25);
  textFont(font);
  fill(255);
  text("Object: Fill the puzzle board with the given pieces.", 300, 130);
  textAlign(CENTER);
  text("Click once to pick up a piece, and click again to", 300, 180);
  textAlign(CENTER);
  text("drop the piece.", 300, 210);
  textAlign(CENTER);
  text("press any key to continue", 300, 420);
  textAlign(CENTER);
}</p>

<p>//The next screen will be the first level, which is setuip as follows.
void Level1()
{
  background(#06C8D1);
  PFont font;
  font = createFont("BradleyHandITCTT-Bold", 50);
  textFont(font);
  textAlign(CENTER, CENTER);
  fill(255);
  text("Level 1", 300, 50);</p>

<p>for (int x = 350; x &lt;= 550; x=x+20)
  {
    line(x, 250, x, 450);
  }</p>

<p>for (int y = 250; y &lt;= 450; y=y+20)
  {
    line(350, y, 550, y);
  }</p>

<p>font = createFont("BradleyHandITCTT-Bold", 30);
  textFont(font);
  textAlign(CENTER, BOTTOM);
  fill(255);
  text("press any key to skip level", 300, 550);<br />
}</p>

<p>//The final screen is the second level, which is setup as follows.
void Level2()
{
  background(#06C8D1);
  PFont font;
  font = createFont("BradleyHandITCTT-Bold", 50);
  textFont(font);
  textAlign(CENTER, CENTER);
  fill(255);
  text("Level 2", 300, 50);</p>

<p>for (int x = 350; x &lt;= 550; x=x+20)
  {
    line(x, 250, x, 450);
  }</p>

<p>for (int y = 250; y &lt;= 450; y=y+20)
  {
    line(350, y, 550, y);
  }
}</p>

<p>void mousePressed()
{
  for (int i = 0; i &lt; 22; i++)
  {
    if (mouseX &gt;= square[i].x &amp;&amp; mouseX &lt;= square[i].x + square[i].wSquare)
    {
      if (mouseY &gt;= square[i].y &amp;&amp; mouseY &lt;= square[i].y + square[i].hSquare)
      {
        selectedSquare = i;</p>

<pre><code>    break;
  }
}
</code></pre>

<p>}
}</p>

<p>void mouseDragged()
{
  if (selectedSquare != -1)
  {
    if (mouseX &gt; square[selectedSquare].x + square[selectedSquare].wSquare)
    {
      square[selectedSquare].x += 5;
    }
    if (mouseX &lt; square[selectedSquare].x)
    {
      square[selectedSquare].x -= 5;
    }
    if (mouseY &gt; square[selectedSquare].y + square[selectedSquare].hSquare)
    {
      square[selectedSquare].y += 5;
    }
    if (mouseY &lt; square[selectedSquare].y)
    {
      square[selectedSquare].y -= 5;
    }
  }
}</p>

<p>class Shape
{
  int numShape = 0;
  int x = 0;
  int y = 0;
  int wSquare = 0;
  int hSquare = 0;</p>

<p>Shape(int numS, int px, int py)
  {
    numShape = numS;
    x = px;
    y = py;</p>

<pre><code>if (numShape == 0)
{
  wSquare = 60;
  hSquare = 60;
}

if (numShape == 1)
{
  wSquare = 40;
  hSquare = 40;
}

if (numShape == 2)
{
  wSquare = 60;
  hSquare = 40;
}

if (numShape == 3)
{
  wSquare = 80;
  hSquare = 40;
}

if (numShape == 4)
{
  wSquare = 80;
  hSquare = 20;
}

if (numShape == 5)
{
  wSquare = 60;
  hSquare = 20;
}

if (numShape == 6) 
{
  wSquare = 20;
  hSquare = 100;
}

if (numShape == 7)
{
  wSquare = 20;
  hSquare = 80;
}

if (numShape == 8)
{
  wSquare = 20;
  hSquare = 60;
}

if (numShape == 9)
{
  wSquare = 20;
  hSquare = 40;
}

if (numShape == 10)
{
  wSquare = 20;
  hSquare = 20;
}

if (numShape == 11)
{
  wSquare = 60;
  hSquare = 20;
}

if (numShape == 12)
{
  wSquare = 80;
  hSquare = 80;
}

if (numShape == 13)
{
  wSquare = 60;
  hSquare = 100;
}

if (numShape == 14) 
{
  wSquare = 40;
  hSquare = 80;
}

if (numShape == 15)
{
  wSquare = 100;
  hSquare = 20;
}
</code></pre>

<p>}</p>

<p>void drawShape()
  {
    if (numShape == 0)
    {
      fill(#F59454);
      rect(x, y, 60, 60);
    }</p>

<pre><code>if (numShape == 1)
{
  fill(#71F554);
  rect(x, y, 40, 40);
}

if (numShape == 2)
{
  fill(#FA7EF2);
  rect(x, y, 60, 40);
}

if (numShape == 3)
{
  fill(#7EFAF7);
  rect(x, y, 80, 40);
}
if (numShape == 4)

{
  fill(#1D0CEA);
  rect(x, y, 80, 20);
}
if (numShape == 5)
{
  fill(#C10CEA);
  rect(x, y, 60, 20);
}
if (numShape == 6)
{
  fill(#FC0A27);
  rect(x, y, 20, 100);
}
if (numShape == 7)
{
  fill(#3B40FF);
  rect(x, y, 20, 80);
}
if (numShape == 8)
{
  fill(#F2EC31);
  rect(x, y, 20, 60);
}
if (numShape == 9)
{
  fill(#3EA516);
  rect(x, y, 20, 40);
}
if (numShape == 10)
{
  fill(#F76B48);
  rect(x, y, 20, 20);
}
if (numShape == 11)
{
  fill(#F022DB);
  rect(x, y, 60, 20);
}
if (numShape == 12)
{
  fill(#19F7F5);
  rect(x, y, 80, 80);
}
if (numShape == 13)
{
  fill(#F73719);
  rect(x, y, 60, 100);
}
if (numShape == 14)
{
  fill(#F8FF3B);
  rect(x, y, 40, 80);
}
if (numShape == 15)
{
  fill(#FFD071);
  rect(x, y, 100, 20);
}
</code></pre>

<p>}
}</p>
]]></description>
   </item>
   <item>
      <title>Game</title>
      <link>https://forum.processing.org/two/discussion/13742/game</link>
      <pubDate>Wed, 02 Dec 2015 06:36:45 +0000</pubDate>
      <dc:creator>lwillms</dc:creator>
      <guid isPermaLink="false">13742@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to create a puzzle game, I had my code working where there would be two level screens with a set of pieces that I could drag onto a grid, however for some reason the pieces are no longer showing up on my level screen and I can not drag them when they do show up. Any help would be greatly appreciated.</p>

<p>// Global Variables
import ddf.minim.*;
AudioPlayer player;
Minim minim;</p>

<p>PImage imgB1;
int value = 0;
int clickedCount = 0;
int x;
int y;
boolean shapeSelected;</p>

<p>boolean shapeGenerated = false;</p>

<p>int [] type = new int[100];
int [][] coordinate = new int[100][2];</p>

<p>int selectedSquare = -1;
Shape [] square = new Shape [100];</p>

<p>/*setup() sets the size of the window, and holds the backgorund image. */
void setup() 
{
  minim = new Minim(this);
  player = minim.loadFile("Jack's Mannequin - Dark Blue (8 bit).mp3", 2048);
  player.play();</p>

<p>for (int i = 0; i &lt; 100; i++)
  {
    square[i] = new Shape (0, 0, 0);
  }</p>

<p>size(600, 600);
  imgB1 = loadImage("puzzle.jpg");
}</p>

<p>// draw() includes all of the different backgrounds that will be used throughtout the code, each of which are defined below.
/* draw() is a continuous loop which will continue to redraw each of the backgrounds throughout the code*/
void draw() {
  if (clickedCount == 0)
  {
    mainScreen();
  }
  if (clickedCount == 1)
  {<br />
    ruleScreen();
  }</p>

<p>if (clickedCount == 2)
  {
    Level1();</p>

<pre><code>if (shapeGenerated == false)

  square[22].numShape = 12;
  square[22].x = 20;
  square[22].y = 100;

  square[23].numShape = 0;
  square[23].x = 110;
  square[23].y = 100;

  square[24].numShape = 0;
  square[24].x = 180;
  square[24].y = 100;

  square[25].numShape = 1;
  square[25].x = 20;
  square[25].y = 190;

  square[26].numShape = 1;
  square[26].x = 65;
  square[26].y = 190;

  square[27].numShape = 1;
  square[27].x = 110;
  square[27].y = 190;

  square[28].numShape = 1;
  square[28].x = 155;
  square[28].y = 190;

  square[29].numShape = 1;
  square[29].x = 200;
  square[29].y = 190;

  square[30].numShape = 13;
  square[30].x = 20;
  square[30].y = 240;

  square[31].numShape = 14;
  square[31].x = 90;
  square[31].y = 240;

  square[32].numShape = 7;
  square[31].x = 140;
  square[31].y = 240;

  square[32].numShape = 7;
  square[32].x = 170;
  square[32].y = 240;

  square[33].numShape = 9;
  square[33].x = 200;
  square[33].y = 240;




//shapeGenerated = true;
</code></pre>

<p>}</p>

<p>if (clickedCount == 3)
{
  Level2();
  {
  if (shapeGenerated == false)
  {</p>

<pre><code>square[0].numShape = 0;
square[0].x = 20;
square[0].y = 100;

square[1].numShape = 0;
square[1].x = 85;
square[1].y = 100;

square[2].numShape = 0;
square[2].x = 150;
square[2].y = 100;

square[3].numShape = 0;
square[3].x = 215;
square[3].y = 100;

square[4].numShape = 1;
square[4].x = 20;
square[4].y = 165;

square[5].numShape = 1;
square[5].x = 73;
square[5].y = 165;

square[6].numShape = 1;
square[6].x = 126;
square[6].y = 165;

square[7].numShape = 1;
square[7].x = 179;
square[7].y = 165;

square[8].numShape = 1;
square[8].x = 232;
square[8].y = 165;

square[9].numShape = 2;
square[9].x = 20;
square[9].y = 210;

square[10].numShape = 3;
square[10].x = 90;
square[10].y = 210;

square[11].numShape = 4;
square[11].x = 180;
square[11].y = 210;

square[12].numShape = 5;
square[12].x = 180;
square[12].y = 235;

square[13].numShape = 6;
square[13].x = 20;
square[13].y = 260;

square[14].numShape = 7;
square[14].x = 50;
square[14].y = 260;

square[15].numShape = 8;
square[15].x = 80;
square[15].y = 260;

square[16].numShape = 9;
square[16].x = 110;
square[16].y = 260;

square[17].numShape = 9;
square[17].x = 140;
square[17].y = 260;

square[18].numShape = 9;
square[18].x = 170;
square[18].y = 260;

square[19].numShape = 10;
square[19].x = 200;
square[19].y = 260;

square[20].numShape = 11;
square[20].x = 110;
square[20].y = 310;

square[21].numShape = 11;
square[21].x = 110;
square[21].y = 340;
</code></pre>

<p>}</p>

<p>shapeGenerated = true; 
}</p>

<p>}</p>

<p>}</p>

<p>//This sets the program up to be able to change backgrounds everytime a key is pressed.
void keyPressed() 
{
  clickedCount++;
}</p>

<p>//This is the code for the mainscreen background
void mainScreen()
{
  background(214);
  image(imgB1, 0, 0);</p>

<p>PFont font;
  font = createFont("BradleyHandITCTT-Bold", 50);
  textFont(font);
  textAlign(CENTER, CENTER);
  fill(255);
  text("Puzzle Buzzle", 300, 100);
  textAlign(CENTER);</p>

<p>font = createFont("BradleyHandITCTT-Bold", 30);
  textFont(font);
  textAlign(CENTER, BOTTOM);
  fill(0, 100, 300);
  text("press any key to begin", 300, 550);
}</p>

<p>//after a key is pressed the program will change to the next page, the rule page, which is setup as follows.
void ruleScreen()
{
  background(0, 150, 200);
  PFont font;
  font = createFont("BradleyHandITCTT-Bold", 50);
  textFont(font);
  font = createFont("BradleyHandITCTT-Bold", 40);
  textFont(font);
  fill(255);
  text("Rules", 300, 90);
  textAlign(CENTER);
  font = createFont("BradleyHandITCTT-Bold", 25);
  textFont(font);
  fill(255);
  text("Object: Fill the puzzle board with the given pieces.", 300, 130);
  textAlign(CENTER);
  text("Click once to pick up a piece, and click again to", 300, 180);
  textAlign(CENTER);
  text("drop the piece.", 300, 210);
  textAlign(CENTER);
  text("press any key to continue", 300, 420);
  textAlign(CENTER);
}</p>

<p>//The next screen will be the first level, which is setuip as follows.
void Level1()
{
  background(#06C8D1);
  PFont font;
  font = createFont("BradleyHandITCTT-Bold", 50);
  textFont(font);
  textAlign(CENTER, CENTER);
  fill(255);
  text("Level 1", 300, 50);</p>

<p>for (int x = 350; x &lt;= 550; x=x+20)
  {
    line(x, 250, x, 450);
  }</p>

<p>for (int y = 250; y &lt;= 450; y=y+20)
  {
    line(350, y, 550, y);
  }</p>

<p>font = createFont("BradleyHandITCTT-Bold", 30);
  textFont(font);
  textAlign(CENTER, BOTTOM);
  fill(255);
  text("press any key to skip level", 300, 550);
}</p>

<p>//The final screen is the second level, which is setup as follows.
void Level2()
{
  background(#06C8D1);
  PFont font;
  font = createFont("BradleyHandITCTT-Bold", 50);
  textFont(font);
  textAlign(CENTER, CENTER);
  fill(255);
  text("Level 2", 300, 50);</p>

<p>for (int x = 350; x &lt;= 550; x=x+20)
  {
    line(x, 250, x, 450);
  }</p>

<p>for (int y = 250; y &lt;= 450; y=y+20)
  {
    line(350, y, 550, y);
  }</p>

<p>class Shape
{
  int numShape = 0;
  int x = 0;
  int y = 0;
  int wSquare = 0;
  int hSquare = 0;</p>

<p>Shape(int numS, int px, int py)
  {
    numShape = numS;
    x = px;
    y = py;</p>

<pre><code>if (numShape == 0)
{
  wSquare = 60;
  hSquare = 60;
}

if (numShape == 1)
{
  wSquare = 40;
  hSquare = 40;
}

if (numShape == 2)
{
  wSquare = 60;
  hSquare = 40;
}

if (numShape == 3)
{
  wSquare = 80;
  hSquare = 40;
}

if (numShape == 4)
{
  wSquare = 80;
  hSquare = 20;
}

if (numShape == 5)
{
  wSquare = 60;
  hSquare = 20;
}

if (numShape == 6) 
{
  wSquare = 20;
  hSquare = 100;
}

if (numShape == 7)
{
  wSquare = 20;
  hSquare = 80;
}

if (numShape == 8)
{
  wSquare = 20;
  hSquare = 60;
}

if (numShape == 9)
{
  wSquare = 20;
  hSquare = 40;
}

if (numShape == 10)
{
  wSquare = 20;
  hSquare = 20;
}

if (numShape == 11)
{
  wSquare = 60;
  hSquare = 20;
}

if (numShape == 12)
{
  wSquare = 80;
  hSquare = 80;
}

if (numShape == 13)
{
  wSquare = 60;
  hSquare = 100;
}

if (numShape == 14) 
{
  wSquare = 40;
  hSquare = 80;
}

if (numShape == 15)
{
  wSquare = 100;
  hSquare = 20;
}
</code></pre>

<p>}</p>

<p>void drawShape()
  {
    if (numShape == 0)
    {
      fill(#F59454);
      rect(x, y, 60, 60);
    }</p>

<pre><code>if (numShape == 1)
{
  fill(#71F554);
  rect(x, y, 40, 40);
}

if (numShape == 2)
{
  fill(#FA7EF2);
  rect(x, y, 60, 40);
}

if (numShape == 3)
{
  fill(#7EFAF7);
  rect(x, y, 80, 40);
}
if (numShape == 4)

{
  fill(#1D0CEA);
  rect(x, y, 80, 20);
}
if (numShape == 5)
{
  fill(#C10CEA);
  rect(x, y, 60, 20);
}
if (numShape == 6)
{
  fill(#FC0A27);
  rect(x, y, 20, 100);
}
if (numShape == 7)
{
  fill(#3B40FF);
  rect(x, y, 20, 80);
}
if (numShape == 8)
{
  fill(#F2EC31);
  rect(x, y, 20, 60);
}
if (numShape == 9)
{
  fill(#3EA516);
  rect(x, y, 20, 40);
}
if (numShape == 10)
{
  fill(#F76B48);
  rect(x, y, 20, 20);
}
if (numShape == 11)
{
  fill(#F022DB);
  rect(x, y, 60, 20);
}
if (numShape == 12)
{
  fill(#19F7F5);
  rect(x, y, 80, 80);
}
if (numShape == 13)
{
  fill(#F73719);
  rect(x, y, 60, 100);
}
if (numShape == 14)
{
  fill(#F8FF3B);
  rect(x, y, 40, 80);
}
if (numShape == 15)
{
  fill(#FFD071);
  rect(x, y, 100, 20);
}
</code></pre>

<p>}</p>

<p>void mousePressed()
{
  for (int i = 0; i &lt; 22; i++)
  {
    if (mouseX &gt;= square[i].x &amp;&amp; mouseX &lt;= square[i].x + square[i].wSquare)
    {
      if (mouseY &gt;= square[i].y &amp;&amp; mouseY &lt;= square[i].y + square[i].hSquare)
      {
        selectedSquare = i;</p>

<pre><code>    break;
  }
}
</code></pre>

<p>}
}</p>

<p>void mouseDragged()
{
  if (selectedSquare != -1)
  {
    if (mouseX &gt; square[selectedSquare].x + square[selectedSquare].wSquare)
    {
      square[selectedSquare].x += 5;
    }
    if (mouseX &lt; square[selectedSquare].x)
    {
      square[selectedSquare].x -= 5;
    }
    if (mouseY &gt; square[selectedSquare].y + square[selectedSquare].hSquare)
    {
      square[selectedSquare].y += 5;
    }
    if (mouseY &lt; square[selectedSquare].y)
    {
      square[selectedSquare].y -= 5;
    }
  }
}
}
}</p>
]]></description>
   </item>
   <item>
      <title>Create an Operation Game style avoidance game</title>
      <link>https://forum.processing.org/two/discussion/13560/create-an-operation-game-style-avoidance-game</link>
      <pubDate>Thu, 19 Nov 2015 00:43:09 +0000</pubDate>
      <dc:creator>kindlelfuego</dc:creator>
      <guid isPermaLink="false">13560@/two/discussions</guid>
      <description><![CDATA[<p>I created a maze in Photoshop with two colors. Maze color (255, 0, 0) and Background color (0, 255, 00). I want to use the get() function to create a sketch where the mouse can only touch the maze color and if it touches the background color the sketch starts over.</p>
]]></description>
   </item>
   <item>
      <title>Add engine</title>
      <link>https://forum.processing.org/two/discussion/13546/add-engine</link>
      <pubDate>Tue, 17 Nov 2015 20:42:55 +0000</pubDate>
      <dc:creator>fakqcze</dc:creator>
      <guid isPermaLink="false">13546@/two/discussions</guid>
      <description><![CDATA[<p>Hello. I want to make a game same as PjsGameEngine - mario... with different things. But how can i use his engine?</p>
]]></description>
   </item>
   <item>
      <title>Kinect with processing and openNi</title>
      <link>https://forum.processing.org/two/discussion/13552/kinect-with-processing-and-openni</link>
      <pubDate>Wed, 18 Nov 2015 15:34:23 +0000</pubDate>
      <dc:creator>christina94</dc:creator>
      <guid isPermaLink="false">13552@/two/discussions</guid>
      <description><![CDATA[<p>I am using the kinect with processing using openNi.
I am supposed to make an interactive game with the character (skeleton) of the kinect but dont know how!! Can anyone please help me? Its kind of an emergency
Thank you :)</p>
]]></description>
   </item>
   <item>
      <title>Problem Using two Arduino and a Class...</title>
      <link>https://forum.processing.org/two/discussion/13259/problem-using-two-arduino-and-a-class</link>
      <pubDate>Sun, 25 Oct 2015 21:32:02 +0000</pubDate>
      <dc:creator>ulyssevanduinen</dc:creator>
      <guid isPermaLink="false">13259@/two/discussions</guid>
      <description><![CDATA[<p>Hello everyone, 
So I am trying to make this "light Bike" kind of game, where a point moves (according to values sent by 2 different arduinos) while leaving a trace behind itself, and the point is to stay the longest possible while not recrossing the line... Now I defined this point in a class, but can't seem to associate the values coming in from arduino with it properly... Anyone have any ideas what might do the trick? Thanks!</p>

<p>By the way here is my code:</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/318/DH64QW3EYIJ5.png" alt="1" title="1" />
<img src="http://forum.processing.org/two/uploads/imageupload/464/O22H74FRWB1T.png" alt="2" title="2" />
<img src="http://forum.processing.org/two/uploads/imageupload/284/N5S4C8HQ4FQU.png" alt="3" title="3" />
<img src="http://forum.processing.org/two/uploads/imageupload/613/PM61153IV03F.png" alt="4" title="4" />
<img src="http://forum.processing.org/two/uploads/imageupload/423/GPY83A3SGQ55.png" alt="5" title="Screen Shot 2015-10-25 at 10.33.39 PM" /></p>

<p>And the class...</p>

<p><img src="http://forum.processing.org/two/uploads/imageupload/593/VIB6ZEBAMX8K.png" alt="Class 1" title="Class 1" />
<img src="http://forum.processing.org/two/uploads/imageupload/261/LKQXSOKY75YX.png" alt="Class 2" title="Class 2" /></p>

<p>Thank you for Any Help you can give!!!</p>
]]></description>
   </item>
   <item>
      <title>Arkanoid_game</title>
      <link>https://forum.processing.org/two/discussion/13301/arkanoid-game</link>
      <pubDate>Tue, 27 Oct 2015 13:07:17 +0000</pubDate>
      <dc:creator>christina94</dc:creator>
      <guid isPermaLink="false">13301@/two/discussions</guid>
      <description><![CDATA[<p>So, i have this arkanoid game which is ready, but i need to do some extra things that i cannot do 
and i would like you to help me.</p>

<p>I have to:</p>

<p>-Set up a scoring system
-  When the ball is out of the screen, end the game
- The slider must to get smaller, in relation to time ( permanent deformation)</p>

<p>You could save me if you could help me</p>

<p>Thank you</p>
]]></description>
   </item>
   <item>
      <title>like a pool game</title>
      <link>https://forum.processing.org/two/discussion/13160/like-a-pool-game</link>
      <pubDate>Wed, 21 Oct 2015 21:37:11 +0000</pubDate>
      <dc:creator>Amy1995</dc:creator>
      <guid isPermaLink="false">13160@/two/discussions</guid>
      <description><![CDATA[<p>anyone knows how to make a simple program for a pool game . ( i only need 1 ball and 1 hole here).<br />
The ball will connect with a line and a mouse. 
the mouse will decide the direction for the ball to move to the hole.</p>
]]></description>
   </item>
   <item>
      <title>How to make object jump</title>
      <link>https://forum.processing.org/two/discussion/13119/how-to-make-object-jump</link>
      <pubDate>Mon, 19 Oct 2015 16:08:52 +0000</pubDate>
      <dc:creator>tanmimh</dc:creator>
      <guid isPermaLink="false">13119@/two/discussions</guid>
      <description><![CDATA[<p>I am making a little game using processing for one my little projects and need help trying to make the ball jump upon key or mouse press. The closest I got was making the ball move up in its y-axis upon mouse click but can't figure out how to make it come down by its own accord. Any help on this will be appreciated!</p>

<p>Also, how do I make it so that when the ball comes in contact with the red obstacle, the ball will be reset back to its initial starting point?</p>

<p>Code:</p>

<p>int x = -55;</p>

<p>void setup()
{
  size(1900,700);
  background(121,234,255);
}</p>

<p>void draw()
{
  background(121,234,255);</p>

<p>stroke(0,255,0);
  fill(0, 255, 0);
  rect(0, 490, 1900, 10);</p>

<p>stroke(188, 161, 72);
  fill(188, 161, 72);
  rect(0, 500, 1900, 700);</p>

<p>stroke(255, 0, 0);
  fill(255, 0, 0);
  rect(500, 410, 30, 80);</p>

<p>stroke(255, 0, 0);
  fill(255, 0, 0);
  rect(1350, 410, 30, 80);</p>

<p>stroke(245, 190, 7);
  fill(245, 190, 7);
  ellipse(x, 462, 55, 55);
  x = x + 2;</p>

<p>}</p>

<p>Thank you!</p>
]]></description>
   </item>
   <item>
      <title>collision ? game over &amp; start screen?</title>
      <link>https://forum.processing.org/two/discussion/12874/collision-game-over-start-screen</link>
      <pubDate>Wed, 07 Oct 2015 12:00:38 +0000</pubDate>
      <dc:creator>ali179</dc:creator>
      <guid isPermaLink="false">12874@/two/discussions</guid>
      <description><![CDATA[<p>hi i was trying to add a collision for my game so that when the mouse come in contact with the objets then a game over page will appear, i know that some how i must implement a boolean function for when it is in play mode and when it is game over , but im trying to mainly get the collision to work here is the code i have so far :</p>

<p>int dia = 40;        // Width of the shape
float xPos;    // Starting position of shape
float yPos;     // position of shape</p>

<p>float velocityX = 10;  // Speed of the shape
float velocityY = 10;  // Speed of the shape</p>

<p>int xdirection = 1;  // Left or Right
int ydirection = 1;  // Top to Bottom
float r = random(50);</p>

<p>void setup() 
{
  bg = loadImage("pug.jpg");
  size(1366, 768);
  frameRate(30);
  rectMode(RADIUS);
  // Set the starting position of the shape
  xPos = width/2;
  yPos = height/2;
}</p>

<p>void draw() 
{
  background(bg);</p>

<p>// Update the position of the shape
  xPos = xPos + ( velocityX * xdirection );
  yPos = yPos + ( velocityY * ydirection );
   fill(0, 255, 134);  //aqua green
   ellipse(mouseX, mouseY, 50, 50);
  // Test to see if the shape exceeds the boundaries of the screen
  // If it does, reverse its direction by multiplying by -1
  if (xPos &gt; width-dia || xPos &lt; dia) { // if the position of the shape is greater than width - 60 (shape size) or if the diameter is greater than the x then the below statement will execute both statements must be false in order for it to execute
    xdirection *= -1;
  }
  if (yPos &gt; height-dia || yPos &lt; dia) { 
    ydirection *= -1;
  }</p>

<p>// Draw the shape
  rect (xPos, yPos, dia, dia);
  rect (xPos-200,yPos+150,dia,dia);
  rect (xPos+200,yPos-200,dia,dia);
}</p>
]]></description>
   </item>
   </channel>
</rss>