<?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/p3/feed.rss?Tag=%23game</link>
      <pubDate>Sun, 08 Aug 2021 20:38:54 +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>game over if collision detected with mouse. game over screen, click to play  screen</title>
      <link>https://forum.processing.org/two/discussion/12875/game-over-if-collision-detected-with-mouse-game-over-screen-click-to-play-screen</link>
      <pubDate>Wed, 07 Oct 2015 12:31:07 +0000</pubDate>
      <dc:creator>ali179</dc:creator>
      <guid isPermaLink="false">12875@/two/discussions</guid>
      <description><![CDATA[<p>int dia = 40;</p>

<p>float xPos;</p>

<p>float yPos;</p>

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

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

<p>int xdirection = 1;  // Left or Right</p>

<p>int ydirection = 1;  // Top to Bottom</p>

<p>int counter = 0;</p>

<p>////////////////</p>

<p>void setup() 
{</p>

<p>bg = loadImage("pug.jpg");</p>

<p>size(1366, 768);</p>

<p>frameRate(30);</p>

<p>rectMode(RADIUS);</p>

<p>// Set the starting position of the shape</p>

<p>xPos = width/2;</p>

<p>yPos = height/2;
}</p>

<p>/////////////////////////
void draw() {</p>

<p>background(bg);</p>

<p>text(counter, 100,100);</p>

<p>textSize(50);</p>

<p>xPos = xPos + ( velocityX * xdirection );</p>

<p>yPos = yPos + ( velocityY * ydirection );</p>

<p>fill(0, 255, 134);  //aqua green</p>

<p>ellipse(mouseX, mouseY, 50, 50);</p>

<p>if (xPos &gt; width-dia || xPos &lt; dia) {</p>

<pre><code>xdirection *= -1;
</code></pre>

<p>}</p>

<p>if (yPos &gt; height-dia || yPos &lt; dia) {</p>

<pre><code>ydirection *= -1;
</code></pre>

<p>}</p>

<p>rect (xPos, yPos, dia, dia);</p>

<p>rect (xPos-200,yPos+150,dia,dia);</p>

<p>rect (xPos+200,yPos-200,dia,dia);
}</p>

<p>/////////////</p>

<p>void mouseMoved (){</p>

<p>counter = counter +1;</p>

<p>if (counter &gt; 99999999) {</p>

<pre><code>counter = 0;
</code></pre>

<p>}
}</p>
]]></description>
   </item>
   <item>
      <title>How to create a airplane shooting game (retro arcade style)</title>
      <link>https://forum.processing.org/two/discussion/12815/how-to-create-a-airplane-shooting-game-retro-arcade-style</link>
      <pubDate>Sun, 04 Oct 2015 11:21:52 +0000</pubDate>
      <dc:creator>TryNTry</dc:creator>
      <guid isPermaLink="false">12815@/two/discussions</guid>
      <description><![CDATA[<p>Can anyone please give me some major guidelines on how to make these kinds of games? It would really help me a lot since it's required for our finals this semester. The game I would like to make looks similar to this <a href="http://static.giantbomb.com/uploads/original/15/157771/2312332-a7.jpg" target="_blank" rel="nofollow">http://static.giantbomb.com/uploads/original/15/157771/2312332-a7.jpg</a></p>
]]></description>
   </item>
   <item>
      <title>How do you program a name into a text-based-game?</title>
      <link>https://forum.processing.org/two/discussion/12744/how-do-you-program-a-name-into-a-text-based-game</link>
      <pubDate>Wed, 30 Sep 2015 01:49:59 +0000</pubDate>
      <dc:creator>Nikkehy</dc:creator>
      <guid isPermaLink="false">12744@/two/discussions</guid>
      <description><![CDATA[<p>Hey, I'm trying to make a text adventure based game!
I want it be where someone can type in their name and their name appear in a sentence for the rest of the game.
How would I be able to pull something like that off.</p>
]]></description>
   </item>
   <item>
      <title>Android game created at Space Apps</title>
      <link>https://forum.processing.org/two/discussion/12484/android-game-created-at-space-apps</link>
      <pubDate>Sat, 12 Sep 2015 18:30:15 +0000</pubDate>
      <dc:creator>boao987</dc:creator>
      <guid isPermaLink="false">12484@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys,
Some friends and I were at the Space Apps Hackathon in New York and we made this game. It's kind of fun and hope you enjoy it! Any feedback is appreciated.</p>

<p>Here's the APK link: <a rel="nofollow" href="http://bit.ly/1JuwjgR">bit.ly</a></p>

<p>And here's more information on the Space Apps hackathon: <a rel="nofollow" href="http://spaceappsnextgen.com/">spaceappsnextgen.com/</a></p>

<p>Our github repository: <a rel="nofollow" href="https://github.com/cdelano266/YDU">https://github.com/cdelano266/YDU</a>
Thanks!</p>
]]></description>
   </item>
   <item>
      <title>What are the advantages of using Processing?</title>
      <link>https://forum.processing.org/two/discussion/12412/what-are-the-advantages-of-using-processing</link>
      <pubDate>Sat, 05 Sep 2015 14:52:22 +0000</pubDate>
      <dc:creator>dinal22</dc:creator>
      <guid isPermaLink="false">12412@/two/discussions</guid>
      <description><![CDATA[<p>Hi all, I'm a new user to Processing and although I've enjoyed using it I'd like to understand more about its pros and cons in comparison to other programming languages and for its uses. I've used it to build a game for 6 year olds...</p>

<p>Many thanks</p>
]]></description>
   </item>
   <item>
      <title>How to have an image randomly appear</title>
      <link>https://forum.processing.org/two/discussion/12322/how-to-have-an-image-randomly-appear</link>
      <pubDate>Mon, 31 Aug 2015 18:21:04 +0000</pubDate>
      <dc:creator>dinal22</dc:creator>
      <guid isPermaLink="false">12322@/two/discussions</guid>
      <description><![CDATA[<p>Hello - apologies in advance if this query has already been answered or isn't in the right format etc. etc. - I'm new!</p>

<p>I'm building a game where an animal collects carrots and apples which then gains points for the user. Whats the best way to have the images of a carrot and an apple appear at random?</p>

<p>Thank you!</p>
]]></description>
   </item>
   <item>
      <title>Simple platformer game question</title>
      <link>https://forum.processing.org/two/discussion/11893/simple-platformer-game-question</link>
      <pubDate>Thu, 30 Jul 2015 03:16:29 +0000</pubDate>
      <dc:creator>zsiegel</dc:creator>
      <guid isPermaLink="false">11893@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I was working on a simple platformer game. The simple idea is that there are three arrays. Those arrays contain the obstacles.</p>

<p>One array for the x cord, one for the y cord, and one for the radius of the obstacle.</p>

<p>What i have working so far is the player to be able to go to the obstacles, and it will automatically move up. the issue is it is not moving down.</p>

<p>The way it checks is it has a for loop. the for loop runs through the array and detects if the x and y cord of the player overlap with the obstacle. the problem is when it is hitting one obstacle, that obstacle is telling it to go up but the other one is telling it to go down, so in the end nothing really happens. Heres the code.</p>

<pre lang="java">


//Start
int ex = 20;
int ey = 480;
int ew = 20;
int[] xo = {
  400, 
  200
};
int[] yo = {
  490, 
  490
};
int[] ro = {
  50, 
  50
};
//Define Obstacles
//Program
void setup() {
  size(750, 500);//--------------------------
}
void draw() {

  background(200, 200, 200);
  fill(0, 0, 255);
  ellipse(ex, ey, 20, 20);
  for (int i = 0; i &lt; xo.length; i++) {
    fill(255, 255, 255);
    ellipse(xo[i], yo[i], ro[i], ro[i]);
    if (dist(ex, ey, xo[i], yo[i]) &lt; ro[i]-ew/2) {
      println("up");
      ey--;
    }
  }
}


void keyPressed() {
  if (keyCode == UP) {
    ey-= 15;
  } 
  if (keyCode == LEFT) {
    ex-= 5;
  }
  if (keyCode == RIGHT) {
    ex+= 5;
  }
}
//end
</pre>

<p>If anybody could help out that would be great. thanks!</p>

<p>edit: I fixed it.</p>
]]></description>
   </item>
   <item>
      <title>Title page issue</title>
      <link>https://forum.processing.org/two/discussion/11764/title-page-issue</link>
      <pubDate>Mon, 20 Jul 2015 04:09:14 +0000</pubDate>
      <dc:creator>gmost</dc:creator>
      <guid isPermaLink="false">11764@/two/discussions</guid>
      <description><![CDATA[<p>I've been trying to make a decent title page for the past couple of days and i've tried many ways to do it and I can't seem to get it to work with my code, or it will work and stop other functions. i'm using global variable int for stage..and I'm using 2 if conditions the first stage for the title page and i copied and pasted the rest in the 2nd! Now the game itself isn't working. Please help me out, i can't seem to understand why!</p>

<pre><code>float gx = 300;
float gy = 100;
float gw = 50;
float gh = 5;
float gSpeed = 1;
int score = 0;
int miss = 3;
int stage;
int maxscore = 3;
PFont font;

/** Variables for Soccer Ball | b in the variable stands for ball
 ================================================================ */
float bx, by, bySpeed, bSpeed;

/** Increment the speed of the ball with each kick
 ================================================= */
float i = -6;
PImage soccerField, soccerBall, startGame;
// End Global Variables

/** Begin Setup
 ============== */
void setup() {
  size(600, 600);
  startGame = loadImage("startgame.png");
  image(startGame, width/2, height/2);
  //background(startGame);
  theBall = new Ball(bx, by);
  theGoalKeeper = new GoalKeeper(gx, gy);
  soccerField = loadImage("field.png");
  //image(soccerField, width/2, height/2);
  minim = new Minim(this);
  kick = minim.loadFile("kick.wav");
  block = minim.loadFile("block.wav");
  crowd = minim.loadFile("crowd.mp3");
  goal = minim.loadFile("goal.mp3");
  font = loadFont("Champagne&amp;Limousines-Bold-48.vlw");
}
/** End Setup
 ============ */

/** Draw
 ======= */
void draw() {
  // Title Screen
  background(startGame);
  textAlign(CENTER);
  textFont(font);
  text("PENALTY BOX", 300, 300);
  textSize(30);
  text("Press 's' to start game.", 300, 400);
  textSize(15);
  text("Click mouse to kick ball.", 120, 500);
  text("Use the spacebar to reset game.", 130, 530);

  if (key == 's') {
    background(soccerField);
    theBall.run();
    theGoalKeeper.run();
    fill(255);
    textAlign(CENTER);
    textSize(10);
    textSize(40);
    text("SCORE: " +score, 105, 520);
    text("LIVES: " + miss, 90, 580);
  }

  // Set the speed of Soccer Ball
  by = by + bySpeed;

  // Start the Goalie
  if (gx &gt; 221) {
    gx += gSpeed;
  }

  // Stop the Goalie on right side
  if (gx == 379) {
    gSpeed = 0;
    gx = 378;
  }

  // Reverse the Goalie
  if (gx &gt; 221 &amp;&amp; gSpeed == 0) {
    gx -= gSpeed--;
  }

  // Stop the Goalie on left side
  if (gx == 220 &amp;&amp; gSpeed == -1) {
    gSpeed = 0;
    gx = 221;
  }

  // Start the Goalie again
  if (gx == 221) {
    gSpeed = 1;
    gx += gSpeed;
  }

  // Reset the ball after kicked in net
  if (by &lt;= 53) {
    bySpeed = 0;
    by = 170 + bSpeed++ * 29;
  }

  // Blocking System
  if (gx &gt;= 264 &amp;&amp; gx &lt;= 334 &amp;&amp; by == 115 || gx &gt;= 264 &amp;&amp; gx &lt;= 334 &amp;&amp; by == 113 || gx == 300 &amp;&amp; by == 115 || gx == 300 &amp;&amp; by == 113) {
    block.play(0); // Blocking Sound
    bySpeed = 1;
  }

  if (bySpeed == 1 &amp;&amp; by == 160) {
    bySpeed = 0;
    miss--;
    by = 170 + bSpeed++ * 29;
  }

  // Scoring system
  if (gx &gt;= 335 &amp;&amp; by == 90 || gx &gt;= 335 &amp;&amp; by == 89) {
    score++;
  }

  if (gx &lt;= 263 &amp;&amp; by == 90 || gx &lt;= 263 &amp;&amp; by == 89) {
    score++;
  }

  // Maximum amount of Goals 
  if (score==3) { 
    fill(35, 193, 34);
    rect(0, 0, width, height);
    fill(0);
    textAlign(CENTER);
    textSize(80);
    text("WINNER !! ", width/2, height/2, width, height);
    noLoop();
    goal.play(0);
  }

  // Game Over
  if (miss == 0) {
    fill(35, 193, 34);
    rect(width/2, height/2, width, height);
    fill(255, 255, 255);
    text("End Game", 300, 200);
    text ("Reset: Spacebar", 300, 250);
    text ("Score: " + score, 300, 300);
    noLoop();
  }
}
/** End Draw
 =========== */

/** MouseClicked Function
 ======================== */
void mouseClicked() {
  kick.play(0);
  bySpeed = i;
}

/** KeyPressed Function
======================= */
void keyPressed() {
  if (key == ' ') {
    loop();
    by = 170;
    bySpeed = 0;
    bSpeed = 0;
    i = -3;
    score = 0;
    miss = 3;
  }

  if (key == 's') {
    crowd.play(0);
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to limit number of bullets in shooting game?</title>
      <link>https://forum.processing.org/two/discussion/11750/how-to-limit-number-of-bullets-in-shooting-game</link>
      <pubDate>Sat, 18 Jul 2015 13:51:52 +0000</pubDate>
      <dc:creator>kkesih</dc:creator>
      <guid isPermaLink="false">11750@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I'm just learning processing and trying to create a very simple shooting game. I need to know how to fire bullets from the location of a mouse click to random positions, and limit the number of bullets to 10. What is the best way to approach this?</p>
]]></description>
   </item>
   <item>
      <title>Objects</title>
      <link>https://forum.processing.org/two/discussion/11735/objects</link>
      <pubDate>Fri, 17 Jul 2015 04:52:08 +0000</pubDate>
      <dc:creator>juanClot</dc:creator>
      <guid isPermaLink="false">11735@/two/discussions</guid>
      <description><![CDATA[<p>If i have an array of object from this</p>

<pre><code>class Shot {
  PVector loc;
  PVector vel;  
  int r,g,b; 
  Shot (PVector loc, PVector direction, int r, int g, int b) {
    this.loc=new PVector ();
    vel=new PVector();
    this.loc = loc.get();
    vel= direction.get();
    vel.normalize();
    vel.mult(9);
    this.r=r;
    this.g=g;
    this.b=b;
  }
  void displayShot() {    
    loc.add(vel);
    noStroke();
    fill(r,g,b);
    ellipse(loc.x, loc.y, 4, 4);    
  }  
}
</code></pre>

<p>and i want to shoot them by ckicking. How could i make it work without shooting too many of those(by to many i mean one each draw). because my game works perfect but it shoots a lot, its nice but THERE ARE TO MANY GOING OUT.</p>
]]></description>
   </item>
   <item>
      <title>I can't make the jumping smooth, any ideas? This is object for jumping. since it's not going to fit.</title>
      <link>https://forum.processing.org/two/discussion/11724/i-can-t-make-the-jumping-smooth-any-ideas-this-is-object-for-jumping-since-it-s-not-going-to-fit</link>
      <pubDate>Thu, 16 Jul 2015 13:43:34 +0000</pubDate>
      <dc:creator>gmost</dc:creator>
      <guid isPermaLink="false">11724@/two/discussions</guid>
      <description><![CDATA[<pre><code>        class Players {
          float x = 0;
          float y = 0;
          float px = 100;
          float py = 20;
          float g = 0.1; // Gravity
          float s = 0; // Speed
          float speed = 9;
          float s1 = 1; // Acceleration
          boolean jumping = false;
          boolean can_jump = false;

          Players(float _x, float _y) {
            x = _x;
            y = _y;
          }

          void simulate() {
            if (jumping) {
              can_jump = false;
              py-=2;
              if (py&lt;height-50) {
                jumping = false;
              }
            }
            if (py&lt;height-20) {
              if (!jumping) {
                py+=2;
              }
            } else {
              can_jump = true;
            }
          }

          void display() {
            fill(255, 0, 0);
            noStroke();
            arc(x, y, 100, 100, -PI, 0);
            arc(x, y, 100, 10, -PI, 0);
          }

          void display2() {
            fill(0, 255, 0);
            noStroke();
            arc(x, y, 100, 100, -PI, 0);
            arc(x, y, 100, 10, -PI, 0);
          }

          /**void gravityPlayer() {
           y = y + s*2; // Assigning y to itself plus the speed
           s = s + g*2; // Assigning speed to itself plus the gravity
           }*/

          void moveP1Left() {
            // Move Left
            if (keyCode == LEFT) {
              x = x - 3;
            }
          }

          void moveP1Right() {
            // Move Left
            if (keyCode == RIGHT) {
              x     = x + 2;
                }
              }

              void moveP1Jump() {
                // Jump
                //gravityPlayer();
                /**if (y &gt;= height - 13) {
                 y = height - 13;
                 println(y);
                 }*/
              }

              void run() {
                display();
              }

              void run2() {
                display2();
              }
            }
</code></pre>
]]></description>
   </item>
   <item>
      <title>How would i make the ball keep moving back every time a goal is scored?</title>
      <link>https://forum.processing.org/two/discussion/11694/how-would-i-make-the-ball-keep-moving-back-every-time-a-goal-is-scored</link>
      <pubDate>Tue, 14 Jul 2015 23:43:18 +0000</pubDate>
      <dc:creator>gmost</dc:creator>
      <guid isPermaLink="false">11694@/two/discussions</guid>
      <description><![CDATA[<pre>
import ddf.minim.*; //sound 

Minim minim;
AudioPlayer player1, player2, player3, player4;
AudioInput input;

PImage bg, sball; 
float goalKeeper;
float xspeed = 4;
float ballX= 170;
float ballY= 170;
float ballYspeed=0;
int score=0;
int miss=3;
float goalieL=20;

void setup()
{
  size (600, 600);
  bg = loadImage("SoccerField.png");
  sball = loadImage("ball.jpg");
  minim = new Minim(this);
  player1 = minim.loadFile("kick.wav");
  goalKeeper=170;
}

void draw()
{
  if (mousePressed) {
    player1.play(0);
  }
  background(bg); 
  fill(255, 255, 255);
  textAlign(CENTER);
  textSize(10);

  textSize(40);
  text("SCORE: "+score, 90, 520);
  text("LIVES: " + miss, 80, 580);


  stroke(255, 0, 0);
  strokeWeight(4);

  //goalie moving back and forth
  line(goalKeeper, 100, goalKeeper+goalieL, 100);
  if (goalKeeper &gt;= 350-goalieL)
  {
    xspeed *= -1;
    goalKeeper= 200-goalieL;
  }
  if ( goalKeeper  &lt;= 80)
  {
    xspeed *= -1;
  }
  goalKeeper=goalKeeper+xspeed;



  //soccer ball
  imageMode(CENTER);
  image( loadImage("ball.png"), 300, ballY, 50, 30);
  ballY=ballY+ballYspeed;

  // println(ballY + ", " + ballYspeed);


  if (ballY &lt;=90)
  {
    ballYspeed = 0;
    ballY = 170;

    if (goalKeeper &lt;= 200 &amp;&amp; goalKeeper &gt;= 200-goalieL)
    {
      miss--;
    } else
    {
      score=score+1;
      if ( abs(xspeed) &lt; 20)
      {
        xspeed=xspeed*1.1;
        goalieL= goalieL+1;
      }
    }
  }
  if (miss==0)
  {
    fill(35, 193, 34);
    rect(0, 0, width, height);
    fill(255, 255, 255);
    text("End Game", 300, 200);
    text ("Reset: Spacebar", 300, 250);
    text("Score: " + score, 300, 300);
    noLoop();
  }
}

void mousePressed()
{
  ballYspeed = -7;
}


void keyPressed()
{
  if (key == ' ')
  {
    loop();
    ballY = 170;
    goalieL=20;
    score=0;
    miss=3;
    xspeed=4;
    goalKeeper=width/2;
  }
}
</pre>
]]></description>
   </item>
   <item>
      <title>I don't know why I keep getting an "unexpected token: private"</title>
      <link>https://forum.processing.org/two/discussion/11638/i-don-t-know-why-i-keep-getting-an-unexpected-token-private</link>
      <pubDate>Fri, 10 Jul 2015 01:14:13 +0000</pubDate>
      <dc:creator>gmost</dc:creator>
      <guid isPermaLink="false">11638@/two/discussions</guid>
      <description><![CDATA[<p>Someone please help me out. I really want to run this but it won't let me. This is the code:</p>

<p><a href="http://oneslime.net/two/Slime2P.java" target="_blank" rel="nofollow">http://oneslime.net/two/Slime2P.java</a></p>
]]></description>
   </item>
   <item>
      <title>How to make intro game credits</title>
      <link>https://forum.processing.org/two/discussion/11618/how-to-make-intro-game-credits</link>
      <pubDate>Wed, 08 Jul 2015 17:17:20 +0000</pubDate>
      <dc:creator>evilhatter</dc:creator>
      <guid isPermaLink="false">11618@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to make the intro game company game credits with millls but processing counts the time that the app uses the start up so some times the don't show is their a way to get the time of when the app is fully loaded or is their another way to show game credit before the menu?</p>

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


void intro(){
if ((millis()&lt;3000 &amp; millis()&gt;0)) {
    background(0);
    textSize(22);
    text("Project Developed With", width/2-120, 60);
  }
 if ((millis()&gt;3000 &amp; millis()&lt;5000)) {
    fill(#482E67);
    background(0);
    textSize(22);
    text("Project Designed by", width/2, 60);
    textSize(38);
    textAlign(CENTER);
    text("\n\n\n\n Evil Hatter\n\n\b Project Version .1", width/2, 60);
  }

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Flappy Code</title>
      <link>https://forum.processing.org/two/discussion/3580/flappy-code</link>
      <pubDate>Sun, 09 Mar 2014 19:10:17 +0000</pubDate>
      <dc:creator>Attarr</dc:creator>
      <guid isPermaLink="false">3580@/two/discussions</guid>
      <description><![CDATA[<p>Some flappy code for processing i have made. Currently 128 lines, it would be interesting to see how minimal the code could be and still be functional.</p>

<pre><code> //Flappy Code
    bird b = new bird();
    pillar[] p = new pillar[3];
    boolean end=false;
    boolean intro=true;
    int score=0;
    void setup(){
      size(500,800);
      for(int i = 0;i&lt;3;i++){
      p[i]=new pillar(i);
      }
    }
    void draw(){
      background(0);
      if(end){
      b.move();
      }
      b.drawBird();
      if(end){
      b.drag();
      }
      b.checkCollisions();
      for(int i = 0;i&lt;3;i++){
      p[i].drawPillar();
      p[i].checkPosition();
      }
      fill(0);
      stroke(255);
      textSize(32);
      if(end){
      rect(20,20,100,50);
      fill(255);
      text(score,30,58);
      }else{
      rect(150,100,200,50);
      rect(150,200,200,50);
      fill(255);
      if(intro){
        text("Flappy Code",155,140);
        text("Click to Play",155,240);
      }else{
      text("game over",170,140);
      text("score",180,240);
      text(score,280,240);
      }
      }
    }
    class bird{
      float xPos,yPos,ySpeed;
    bird(){
    xPos = 250;
    yPos = 400;
    }
    void drawBird(){
      stroke(255);
      noFill();
      strokeWeight(2);
      ellipse(xPos,yPos,20,20);
    }
    void jump(){
     ySpeed=-10; 
    }
    void drag(){
     ySpeed+=0.4; 
    }
    void move(){
     yPos+=ySpeed; 
     for(int i = 0;i&lt;3;i++){
      p[i].xPos-=3;
     }
    }
    void checkCollisions(){
     if(yPos&gt;800){
      end=false;
     }
    for(int i = 0;i&lt;3;i++){
    if((xPos&lt;p[i].xPos+10&amp;&amp;xPos&gt;p[i].xPos-10)&amp;&amp;(yPos&lt;p[i].opening-100||yPos&gt;p[i].opening+100)){
     end=false; 
    }
    }
    } 
    }
    class pillar{
      float xPos, opening;
      boolean cashed = false;
     pillar(int i){
      xPos = 100+(i*200);
      opening = random(600)+100;
     }
     void drawPillar(){
       line(xPos,0,xPos,opening-100);  
       line(xPos,opening+100,xPos,800);
     }
     void checkPosition(){
      if(xPos&lt;0){
       xPos+=(200*3);
       opening = random(600)+100;
       cashed=false;
      } 
      if(xPos&lt;250&amp;&amp;cashed==false){
       cashed=true;
       score++; 
      }
     }

    }
    void reset(){
     end=true;
     score=0;
     b.yPos=400;
     for(int i = 0;i&lt;3;i++){
      p[i].xPos+=550;
      p[i].cashed = false;
     }
    }
    void mousePressed(){
     b.jump();
     intro=false;
     if(end==false){
       reset();
     }
    }
    void keyPressed(){
     b.jump(); 
     intro=false;
     if(end==false){
       reset();
     }
    }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Shift cells down to fill gaps?</title>
      <link>https://forum.processing.org/two/discussion/11554/shift-cells-down-to-fill-gaps</link>
      <pubDate>Thu, 02 Jul 2015 21:19:07 +0000</pubDate>
      <dc:creator>anoncode</dc:creator>
      <guid isPermaLink="false">11554@/two/discussions</guid>
      <description><![CDATA[<p>This is the function I have to remove black cells and shift the rest down. Right now it is just moving down one row.</p>

<pre><code> void change(int i, int j){
        if(cellColor==#000000){
          for(f = 1; f &lt; j; f++){
            color co = bubbleArray[i][f-1].getColor();
            if(co==#ffffff){
              cellColor = #ffffff;
              newBub(f,cellColor);
              visited=false;
            }else if(co==#ff0000){
              cellColor = #ff0000;
              newBub(f,cellColor);
            }else if(co==#00ff00){
              cellColor = #00ff00;
              newBub(f,cellColor);
            }else if(co==#0000ff){
              cellColor = #0000ff;
              newBub(f,cellColor);
            }else if(co==#ffff00){
              cellColor = #ffff00;
              newBub(f,cellColor);
            }else if(co==#000000){
              newBub(f,#00ffff);
            }
          }
        }
      }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Making a Semi-Looping Method</title>
      <link>https://forum.processing.org/two/discussion/11500/making-a-semi-looping-method</link>
      <pubDate>Mon, 29 Jun 2015 15:04:57 +0000</pubDate>
      <dc:creator>Holtensen</dc:creator>
      <guid isPermaLink="false">11500@/two/discussions</guid>
      <description><![CDATA[<p>Hello Community!
I am trying to create a gameboard for a small game I started making, but I hav encountered a problem, I couldn't solve yet.
The gameboard ground consists of rectangles, filled with images ( 38x21 ). I want each rectangle to be filled with a randomized image, which is then saved and the same board redrawn in the methode draw() . So far it is always filling the rectangles with always new randomized images, which makes the gameboard look all weird (constant color changes). 
Here is the code I use to draw it:</p>

<pre><code>draw() {
    for (int j = 0; j &lt; 21; j ++) {
        squarePositionY[j] = squarePositionYVariable;
        squarePositionYVariable = squarePositionYVariable + 48;
        squarePositionXVariable = 48;
        for (int i = 0; i &lt; 38; i++) {
            squarePositionX[i] = squarePositionXVariable;
            squarePositionXVariable = squarePositionXVariable + 48;
            groundimagerandom = random(0, 100);
            if ( groundimagerandom &gt; 40) {
                image(groundLevelOne, squarePositionX[i], squarePositionY[j]);
            } else if ( groundimagerandom &lt; 41) {
                image(groundLevelOneRotten, squarePositionX[i], squarePositionY[j]);
            }
        }
    }
}
</code></pre>

<p>Thanks for a short answer!</p>
]]></description>
   </item>
   <item>
      <title>Object moving</title>
      <link>https://forum.processing.org/two/discussion/11461/object-moving</link>
      <pubDate>Fri, 26 Jun 2015 08:45:49 +0000</pubDate>
      <dc:creator>gesat03</dc:creator>
      <guid isPermaLink="false">11461@/two/discussions</guid>
      <description><![CDATA[<p>Hello am gonna make a game but i have a problem with my AI. İ want to make it moves as i want. How can i do the AI goes one point to another? For excample if it stops the point x0 and y0 (50,50) and i want to move it to x1 and y1 (70,80) with a spesific step excample it move one by one with a constant speed not teleporting. My map coordinates for x 0 - 1024 and for y 0 - 600. If you help me i would be happy thx.</p>
]]></description>
   </item>
   <item>
      <title>Questions about the PONG GAME</title>
      <link>https://forum.processing.org/two/discussion/11428/questions-about-the-pong-game</link>
      <pubDate>Wed, 24 Jun 2015 04:03:41 +0000</pubDate>
      <dc:creator>sapphiros</dc:creator>
      <guid isPermaLink="false">11428@/two/discussions</guid>
      <description><![CDATA[<p>Just want to ask some questions about this PONG GAME.
And here is the conditions:
1.the top paddle is controlled by the mouse, and the bottom is controlled by the keyboard.
2.If the ball passes the top or bottom paddle in the y direction, a point is scored (by console), and a new ball is generated.</p>

<p>Now I was stuck in the how to generate a new ball and how to consider if the ball hit the paddle or paddles missed it.</p>

<p>Here are the questions:
1.How can I make relationship between the coordinate of the center of the paddle to the center of the ball? 
   Should I add more conditions in the if block to change the speed of ball which it hits the paddles? 
2.How can I generate a new ball when the both paddles missed the ball? Should I add a boolean named collision and assign it to true? 
   And if it was false the program will generate a new ball? 
Was my method right or wrong? Could you guys give me some hints?</p>

<pre><code>float ballX = 250;
float ballY = 250;
float ballSize = 20;
float ballSpeedX = 3;
float ballSpeedY = 8;
float ballGenSpeed = 3;

float borderTop = 25;
float borderBottom = 450;
float borderLeft = 0;
float borderRight = 450;

float paddleH = 10;
float paddleW = 100;
float paddleSpeed = 15;
float paddleX;

void setup()
{
  size(500, 500);
  background(0);
}

void draw()
{
  background(0);
  ballX += ballSpeedX;
  ballY += ballSpeedY;

  if (ballX &lt; borderLeft || ballX &gt; borderRight)
  {
    ballSpeedX *= -1;
  }
  if (ballY &lt; borderTop+(paddleH*2) || ballY &gt; borderBottom-paddleH)
  {
    ballSpeedY *= -1;
  }

  ellipse(ballX, ballY, ballSize, ballSize);

  boolean collision = true;



  if (!collision) {
    for (int i = 0; i&lt;20; i++)
    {
      float theta = i/20 * 2 * PI;
      float ballDirectX = cos(theta)*ballGenSpeed;
      float ballDirectY = sin(theta)*ballGenSpeed;
      ellipse(ballDirectX, ballDirectY, ballSize, ballSize);
    }
  }

  rect(mouseX, borderTop, paddleW, paddleH);
  rect(paddleX, borderBottom, paddleW, paddleH);
  if (key == CODED) {
    if (keyCode == LEFT &amp;&amp; keyPressed) {
      paddleX -= paddleSpeed;
    } else if (keyCode == RIGHT &amp;&amp; keyPressed) {
      paddleX += paddleSpeed;
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Frogger Assignment.Super late causing me to fail.Help please!</title>
      <link>https://forum.processing.org/two/discussion/10899/frogger-assignment-super-late-causing-me-to-fail-help-please</link>
      <pubDate>Tue, 19 May 2015 17:33:58 +0000</pubDate>
      <dc:creator>ArcheryPrincess1452</dc:creator>
      <guid isPermaLink="false">10899@/two/discussions</guid>
      <description><![CDATA[<p>My frogger assignment is super late and i got 2 more assignments to do including exams.I would really appreciate if anyone could help me. :)</p>
]]></description>
   </item>
   <item>
      <title>How to call a function properly</title>
      <link>https://forum.processing.org/two/discussion/11033/how-to-call-a-function-properly</link>
      <pubDate>Wed, 27 May 2015 16:37:13 +0000</pubDate>
      <dc:creator>glenmcmurchy</dc:creator>
      <guid isPermaLink="false">11033@/two/discussions</guid>
      <description><![CDATA[<p>Hi,</p>

<p>I have made a simple game (flappy birds copy) to try and teach myself the basics of processing. I am currently trying to make a start screen, so that when I click start the game starts. I tried using different function names and calling theta different times to make this possible. However, it isn't working. Is this the way it should be done or is there a better way?</p>

<p>every time i press start on the game start screen it goes to the main game section BUT it cuts off once I release the button.
Ill copy and paste my code here and you can try play it, you'll see what I mean
`int xPos=650;
int xDir=3;
int yPos=150;
int yDir=3;
int Score = 0;
boolean gameover = false;</p>

<p>void setup()
{
 size(667,375);
  background(150,170,255);</p>

<p>fill(0);
  textSize(30);
}
void draw(){</p>

<p>//Start Screen</p>

<pre><code>background(45);
</code></pre>

<p>fill(255,10,10);
   text("Glen's Game",250,150);
   fill(235);
   rect(240,165,200,50);
   fill(150);
   text("Start",305,200);</p>

<p>if(mousePressed &amp;&amp; (240&lt;mouseX &amp;&amp; mouseX&lt;440) &amp;&amp; (165&lt;mouseY &amp;&amp; mouseY&lt;215) ){
     GameStart();
   }</p>

<p>}</p>

<p>void GameStart(){</p>

<p>background(150,170,255);
  fill(255);
  text("Score = "+Score, 500,50);<br />
  fill(112,233,165);
  ellipse(150,yPos,25,25);
  yPos+=4;
  fill(255); 
  rect(xPos,0,50,100);
  fill(100);
  rect(xPos,275,50,100);
  xPos-=3;
  }</p>

<p>void GameOver(){ 
 if(((0375))
 {<br />
  background(45);
  fill(255,10,10);
  text("GAME OVER",250,150);
  fill(200);
  text("Try Again",267,200); 
 }
 }</p>

<p>void Scoring(){
  if(xPos==152){
   Score++ ;
  } 
 }
 void MousePressed(){
  if(mousePressed){
    yPos= yPos - 12;
  }
  if(xPos&lt;1){
   xPos=650; 
  }
 }`</p>

<p>Help much appreciated :)</p>
]]></description>
   </item>
   <item>
      <title>How far can you push Processing?</title>
      <link>https://forum.processing.org/two/discussion/11087/how-far-can-you-push-processing</link>
      <pubDate>Sun, 31 May 2015 15:17:33 +0000</pubDate>
      <dc:creator>alphanerd132</dc:creator>
      <guid isPermaLink="false">11087@/two/discussions</guid>
      <description><![CDATA[<p>My friend challenged me to make Diablo 4 in Processing. Of course I would not call it Diablo 4 or have anything look like Diablo 4 but it would have a lot of the same mechanics of Diablo. My question is, can Processing handle it? My other friend who has had tones of coding experience in the past told me that Processing would not handle a top down 3D rendered game. Again the question is, is he right? Can Processing handle a top down 3D game?</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>
   <item>
      <title>[SOLVED] Is stroke applied after fill?</title>
      <link>https://forum.processing.org/two/discussion/11140/solved-is-stroke-applied-after-fill</link>
      <pubDate>Wed, 03 Jun 2015 19:45:19 +0000</pubDate>
      <dc:creator>khoma</dc:creator>
      <guid isPermaLink="false">11140@/two/discussions</guid>
      <description><![CDATA[<p>Hi</p>

<p>I'm creating a simple breakout game where in when a block is hit it moves out of the screen at a certain pace, and then disappears. I would like said block to be drawn on top of any block that is still stationary. It works only partially. For some reason the fill of the moving block is drawn on top of the fill of the stationary block, but the stroke of the stationary block shows through the moving block. Image here:
<img src="http://s11.postimg.org/dwxsombhf/processing_stroke_fill.png" alt="" /></p>

<p>The moving blocks are drawn after the stationary blocks. The code for drawing a block looks like this:</p>

<pre><code>    @ Override
    public void draw() {
        if (doomed) {
            x += velocity * cos(angle);
            y += velocity * sin(angle);
        }
        if (x &lt; 0 || x &gt; width || y &lt; 0 || y &gt; height) {
            dead = true;
        } else {
            strokeCap(SQUARE);
            fill(red, green, blue);
            stroke(0);
            rect(x, y, w, h);
            noStroke();
            fill(red + lowerColor, green + lowerColor, blue + lowerColor);
            triangle(x, y + blockHeight, x + blockWidth, y + blockHeight, x + blockWidth, y);
            fill(red + upperColor, green + upperColor, blue + upperColor);
            rect(x + bevel * cos(bevelAngle), y + bevel * sin(bevelAngle), blockWidth - 2 * bevel * cos(bevelAngle), blockHeight - 2 * bevel * sin(bevelAngle));
        }
    }
</code></pre>

<p>The main draw loop called by processing looks like this, where blockArray contain all the stationary blocks, and doomedBlockArray contains all the moving blocks:</p>

<pre><code>@ Override
public void draw() {
    if (firstRun &amp;&amp; frame != null) {                    // Lock frame size
        frame.setResizable(false);
        firstRun = false;
    }

    background(230);                                    // Clear frame

    if (blockArray.size() == 0) {
        levelUp();
    }

    blockIterator = blockArray.iterator();              // Draw stationary blocks
    while (blockIterator.hasNext()) {
        blockIterator.next().draw();
    }

    doomedBlockIterator = blockArrayOfDoom.iterator();  // Draw moving blocks
    while (doomedBlockIterator.hasNext()) {
        block = doomedBlockIterator.next();
        if (block.isDead()) {
            doomedBlockIterator.remove();               // Remove if block is outside screen
        } else {
            block.draw();
        }
    }

    drawableIterator = drawablesArray.iterator();       // Draw anything else
    while (drawableIterator.hasNext()) {
        drawableIterator.next().draw();
    }
}
</code></pre>

<p>As you can see, the "doomed" blocks are drawn after the regular blocks, and yet the stroke from the regular blocks overlap the doomed blocks. Is this normal, can it be avoided?</p>

<p>Any help much appreciated!</p>

<p>Edit:</p>

<p>Solved after changing from P3D to P2D renderer!</p>
]]></description>
   </item>
   <item>
      <title>Sizing a Game to Fit on Any Monitor</title>
      <link>https://forum.processing.org/two/discussion/11136/sizing-a-game-to-fit-on-any-monitor</link>
      <pubDate>Wed, 03 Jun 2015 15:14:12 +0000</pubDate>
      <dc:creator>NoodleMan</dc:creator>
      <guid isPermaLink="false">11136@/two/discussions</guid>
      <description><![CDATA[<p>So I have a game that I programmed on my own monitor and it apparently does not look the same on the monitors at school. I am confused as to how I would go about programming it to always appear the same way regardless of the monitor in use. I am sure there is an easy way to do this but I could use a push in the right direction.</p>
]]></description>
   </item>
   <item>
      <title>[Solved*] Low Performance, large program. (Typical solution: Reboot ... )</title>
      <link>https://forum.processing.org/two/discussion/11118/solved-low-performance-large-program-typical-solution-reboot</link>
      <pubDate>Tue, 02 Jun 2015 16:35:47 +0000</pubDate>
      <dc:creator>maral04</dc:creator>
      <guid isPermaLink="false">11118@/two/discussions</guid>
      <description><![CDATA[<p>Hi I'm new posting to the forum but I've been using a lot of useful information on it lately,</p>

<p>I'm developing a 2D platform game with processing 3.0a5 and Java 2.0 mode using PImages (most of them from kenney.nl) and SoundFile in the future.
When I started the project I made my character to move using the keyboard, running at the default frameRate, which if I'm not wrong is 60.
When the character movements were finished, added some platforms with collision (so it don't fall down)[still need to be polished], and after that, made a menu (New game, Load Game, Controls...).</p>

<p>After adding the menu, which is screen 0 and selecting New Game which sends us to screen 1, we can see the selected character and move it, but the performance by now decreases, it's like the program runs at 30fps or so (you see the character movements a bit clumsy).
If I execute the program changing screen 0 for 1 since the very beginning, it executes with normal performance.
The program has almost 1000 lines, but it's not finished yet.</p>

<p>To "clear" the screen I'm using background(img);, is it the best way to do it ?
How can I solve this performance problem ?</p>

<p><del>Link to Github repository.</del></p>

<p>Sorry for my english.
Thanks,
Maral.</p>

<p><strong>Sorry to bother you guys it seems a good reboot is all it needed... Windows 7.</strong></p>
]]></description>
   </item>
   <item>
      <title>Help in my first game (shooting with the ship).</title>
      <link>https://forum.processing.org/two/discussion/11093/help-in-my-first-game-shooting-with-the-ship</link>
      <pubDate>Mon, 01 Jun 2015 03:33:10 +0000</pubDate>
      <dc:creator>ganonnes</dc:creator>
      <guid isPermaLink="false">11093@/two/discussions</guid>
      <description><![CDATA[<p>Help in my first game (shooting with the ship).</p>

<p>Hello, Goodnight everyone!
My name is Gabriel Almeida, I am Brazilian and I started my studies in game design a short time, when my initial focus will be on schedule, I started to try a little game of spacecraft today in processing language and am having difficulties with the shot ship.
Remembering that I am using google translate to communicate and do not know if I published the question in the correct section of the forum, if in the wrong section please move my question to the appropriate place =)
The code I've written so far is as follows:</p>

<p>int vidaNave= 3;
int pxnave;
int pynave;
int posx= 400;
int posy= 300;
PImage nave;
PImage tiro_1;
PImage efeito_tiro;
PImage vidaNave1;
PImage vidaNave2;
PImage vidaNave3;
int tiroy;
boolean delay=true;
int b;
int c;</p>

<p>void setup() {
  size(800, 600);
  background(200, 200, 200);
  nave = loadImage("nave1.png");
  tiro_1 = loadImage("tiro1.png");
  efeito_tiro = loadImage("efeitotiro.png");
}</p>

<p>void draw() {
  background(200, 200, 200);
  image(nave, posx, posy);
  frameRate(60);
  movimento();
tiro();</p>

<p>}</p>

<p>void tiro(){</p>

<p>tiroy-=0;
   if(key == 'l' || key == 'L'){
int y=posy;
  image(tiro_1,posx+40,y+tiroy-5+(b-=5));
  image(efeito_tiro,posx+30,posy);
  c = (y+tiroy+(b-=5));
     }</p>

<p>}</p>

<p>void movimento() {
  int d=posx+40;
    if (keyPressed) {
    if (key == 'a' || key == 'A') {
       image(tiro_1,d,c);
       c-=5;
      posx -=10; 
      if (posx&lt;0) {
        posx +=10;
      }
    }
    if (key == 'd' || key == 'D') {
       image(tiro_1,d,c);
       c-=5;
      posx =posx+10;
      if (posx&gt;700) {
        posx -=10;
      }
    }
    if (key == 'w' || key == 'W') {
       image(tiro_1,d,c);
       c-=5;
      posy-=5;
      if (posy&lt;0) {
        posy+=5;
      }
    }
    if (key == 's' || key == 'S') {
       image(tiro_1,d,c);</p>

<pre><code>  posy+=5;
  if (posy&gt;500) {
    posy-=5;
  }
}
</code></pre>

<p>}
}</p>

<p>void vida_nave() {</p>

<p>}</p>

<p>"Sorry, not yet picked up the habit of using comments"</p>

<p>I would like to processing programming book recommendations aimed at games (in the case in the English language because I did not think in Portuguese), aid in relation to the method "shot" of my schedule and if possible a code that would make a shooting missiles using arrays (I'm still learning how to use arrays in processing) that is equal to this video:</p>

<p><span class="VideoWrap"><span class="Video YouTube" id="youtube-ANdctdSYLA0"><span class="VideoPreview"><a href="http://youtube.com/watch?v=ANdctdSYLA0"><img src="http://img.youtube.com/vi/ANdctdSYLA0/0.jpg" width="640" height="385" border="0" /></a></span><span class="VideoPlayer"></span></span></span></p>

<p>The author does not teach how to make this shot using arrays but advises that easy.</p>

<p>I thank the attention =)</p>
]]></description>
   </item>
   <item>
      <title>Where can I find a 2D game-engine for processing?</title>
      <link>https://forum.processing.org/two/discussion/10672/where-can-i-find-a-2d-game-engine-for-processing</link>
      <pubDate>Wed, 06 May 2015 15:48:09 +0000</pubDate>
      <dc:creator>OMG</dc:creator>
      <guid isPermaLink="false">10672@/two/discussions</guid>
      <description><![CDATA[<p>I'm trying to follow this tutorial to create a Mario Game: <a href="http://processingjs.nihongoresources.com/test/PjsGameEngine/docs/tutorial/mario.html" target="_blank" rel="nofollow">http://processingjs.nihongoresources.com/test/PjsGameEngine/docs/tutorial/mario.html</a> and its says that we need to use a "a library for writing 2D sprite-based games, using Processing.js". Do you know where can I find it?. I check this thread from April 2014 but there's no answer :(</p>

<p>Thank you so much.</p>
]]></description>
   </item>
   <item>
      <title>having a trail from my snake</title>
      <link>https://forum.processing.org/two/discussion/10635/having-a-trail-from-my-snake</link>
      <pubDate>Mon, 04 May 2015 15:20:03 +0000</pubDate>
      <dc:creator>thirdtimesa</dc:creator>
      <guid isPermaLink="false">10635@/two/discussions</guid>
      <description><![CDATA[<p>Hi, i'm creating a slightly different version of snake where everytime the food is eaten, the speed increases. However, i would like to Jazz it up a bit and add a trail that fades coming from the snake. I've tried adding a 4th number to my rect so that it would be transparent and fade but that doesn't work. Any suggestions? Here is my code. Thanks</p>

<pre><code>Snake snake;

int headx;
int heady;
int size = 20;
int speed = 10;
char direction;
boolean foodEaten;
int eatx;
int eaty;
int snakesize = 1;
int fps = 5;
PImage background;
int highScore;

void setup() {
  size(1900, 1000);
  rectMode(CENTER);
  smooth();
  foodEaten = false;
  eatx=(round(random(90))+1)*10;
  eaty=(round(random(70))+1)*10;
  snake = new Snake();
  background = loadImage("Tron background.jpg");
}

void draw() {
  background(background);
  frameRate(fps);
  displayFood();
  snake.display();
  checkCollision();
  drawScoreboard();
}

void drawScoreboard() {
  //draw scoreboard
  fill(#FFB2B2);
  textSize(30);
  text("Score: " + highScore, 800, 400);
  fill(#FFB2B2);
  textSize(40);
  text("High Score:" + highScore, 800, 500);
}


void displayFood() {
  fill(#E3D250);
  ellipse(eatx, eaty, size, size);
}

void checkCollision() {
  if (snake.headx == eatx &amp;&amp; snake.heady == eaty) {
    eatx=(round(random(90))+1)*10;
    eaty=(round(random(60))+1)*10;
    foodEaten = true;
    fps += 5;
  } 
  else {
    foodEaten = false;
  }
}

void keyPressed() {
  if (key == 'w') { //UP
    direction = 'w';
  } 
  else if (key == 'a') { //LEFT
    direction = 'a';
  } 
  else if (key == 's') { //DOWN
    direction = 's';
  } 
  else if (key == 'd') { //RIGHT
    direction = 'd';
  }
}

class Snake {

  int headx;
  int heady;
  int snakesize;

  Snake() {
    headx = width/2;
    heady = height/2;
    snakesize = 1;
  }

  void display() {
    fill(#87D9E3);
    noStroke();
    rect(headx, heady, size, size);
    checkMove();
    borders();
    checkCollision();
  }

  void moveUp() {
    heady -=speed;
  }
  void moveLeft() {
    headx -=speed;
  }
  void moveDown() {
    heady +=speed;
  }
  void moveRight() {
    headx +=speed;
  }

  void checkMove() {
    if (direction == 'w') {  // Move up
      snake.moveUp();
    } else if (direction == 'a') { // Move left
      snake.moveLeft();
    } else if (direction == 's') { // Move down
      snake.moveDown();
    } else if (direction == 'd') { // Move right
      snake.moveRight();
    }
  }

  void borders() {
    if (headx &gt; width) {
      //headx=0;
      exit();
    } else if (headx &lt; 0) {
      //headx = width;
      exit();
    } else if (heady &gt; height) {
      //heady = 0;
      exit();
    } else if (heady &lt; 0) {
      //heady = height;
      exit();
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Simon game for processing beginners</title>
      <link>https://forum.processing.org/two/discussion/10772/simon-game-for-processing-beginners</link>
      <pubDate>Tue, 12 May 2015 13:06:43 +0000</pubDate>
      <dc:creator>Tarrhen</dc:creator>
      <guid isPermaLink="false">10772@/two/discussions</guid>
      <description><![CDATA[<p>Hi, so here's the speech : A friend and I are working on a Simon memory game in processing. We are beginners (some would say "complete noobs"), for this project we have to use the basic processing library and we also have to use tables. The comments in our code are in french (sorry). Our idea is a Simon memory game in which you first have a pre-loaded sequence that plays when you hit the start button and if the colors you click (when it's your turn to play) are corect then the game move to a random sequence color and so on until you fail, and if you fail you have to restart the game. As I said we are complete noobs and we got to this point (of course this is mostly ideas and mainly nothing that works or you can launch), we would love some help it would already be awesome for us if we could launch the first sequence (even without player interaction) : You can download the file here --&gt; <a rel="nofollow" href="http://www.mediafire.com/download/v8v6yokgdpz42vs/Color_Sync.pde">Download</a></p>

<pre><code>//Color Sync , jeu de mémoire

//declarations

  //tableaux pour carrés, positions et couleurs

  PShape[] carres = new PShape[4];
  int x[] = {250, 500, 250, 500};
  int y[] = {250, 250, 500, 500};

  //couleur d'affichage prédéfini (fond de base)
  color couleursfond[] = new color[4];

  //couleurs pour les séries - plus intenses
  color couleurs[] = new color[4];


  //tableau pour sequence de couleur pré-enregistrée

  int sequence[] = new color[4];

//initialisation - sous-programmes natifs

void setup () { 

  //affichage de départ 

  size(1000, 1000, P2D); 
  background(255, 255, 255);

  //affichage titre
  String titre = "COLOR SYNC.";
  fill(50);
  textAlign(CENTER);
  textSize(70);
  text(titre, 0, 20, 1000, 100);

  //affichage description

  String description = "Inspiré du célèbre jeu pour enfant le 'Simon', Color Sync vous propose de tester votre capacité de mémorisation. ";
  fill(50);
  textSize(12);
  text(description, 0, 160, 1000, 30);

  //couleurs des quatre carrés à l'origine, sans animation. 

  couleursfond[0]=color(255, 100, 100);
  couleursfond[1]=color(100, 255, 100);
  couleursfond[2]=color(100, 100, 255);
  couleursfond[3]=color(255, 255, 100);

  //Bouton pour démarrer

  fill(255);
  stroke(0);
  rect(430, 760, 145, 60, 5);
  String lancer = "Lancer!";
  fill(0);
  textSize(30);  
  text(lancer, 500, 800);

  //Caractéristiques de la séquence pré-définie

  sequence[0]=0;
  sequence[1]=2;
  sequence[2]=1;
  sequence[3]=3;  

    //définition couleurs et tailles

    for(int i= 0; i&lt;4; i=i+1) {
      noStroke();
      fill(couleursfond[i]);    
      carres[i]=createShape(RECT, 0, 0, 240, 240);
    }

    //définition positions

    for(int i= 0; i&lt;4; i=i+1) {
      shape(carres[i], x[i], y[i]);     

    }
  //réduit la nombre d'image par seconde du draw (ici une image par seconde)  

  frameRate(1);

}

    //entrée de la variable permettant de faire la série de couleurs pré-définies 'i' 

    int i=0;

void draw(){


/*    //le joueur interagit avec le bouton pour démarrer la partie (interaction)  et affiche la séquence de couleur pré-enregistrée pour le premier niveau
  while (!(mousePressed &amp;&amp; mouseX&gt; 430 &amp;&amp; mouseX &lt;575 &amp;&amp; mouseY&gt; 760 &amp;&amp; mouseY &lt;820)) {

    }
*/

  //couleurs plus intense pour les série à afficher au joueur

  couleurs[0]=color(255, 0 , 0);
  couleurs[1]=color(0, 255, 0);
  couleurs[2]=color(0, 0, 255);
  couleurs[3]=color(255, 255, 0);  
  fill(couleurs[i]);

  //nous aide pour les tests à voir le fonctionnement de la série de couleurs prédéfinie

  background(0);

  int numerocouleur = sequence[i];
  shape(carres[numerocouleur], x[numerocouleur], y[numerocouleur]);  

  if(i&lt;3){
    i=i+1;
  }


/* 
  //après la séquence préenregistrée le jeu devient plus difficile et une couleur s'ajoute. Les couleurs sont choisies aléatoirement par la machine

    if(sequence[i]= sequence joueur ){
      sequence[i]= random;

      //augmentation de la difficulté en ajoutant une couleur en plus dans chaque séquence
      while(sequence[]=  sequence faite par le joueur ) {
        sequence[i]=sequence[i]+1;

        }

    }

    else {
      sequencePreenregistree();
    }
*/

} 


/* idée - 

if() {
  programme d'affichage automatique (appuyer sur ent pour activer l'animation)
} else {
  programme du jeu
}
</code></pre>
]]></description>
   </item>
   </channel>
</rss>