<?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 #state - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=%23state</link>
      <pubDate>Sun, 08 Aug 2021 18:26:48 +0000</pubDate>
         <description>Tagged with #state - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23state/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>How to make the timer start after a condition?</title>
      <link>https://forum.processing.org/two/discussion/27709/how-to-make-the-timer-start-after-a-condition</link>
      <pubDate>Sat, 07 Apr 2018 02:35:17 +0000</pubDate>
      <dc:creator>BioHazard</dc:creator>
      <guid isPermaLink="false">27709@/two/discussions</guid>
      <description><![CDATA[<pre><code>final int stateSampleGame = 0;
final int stateBoss = 1;
final int stateVictory = 2;

int state = stateSampleGame;

void setup () {
  size (960, 640);
  background(255);
}
 void draw () {
  background(255);
  switch (state) {
  case stateSampleGame:        
    gameScreen();
    break;
  case stateBoss:        
    bossScreen();
    break;
  case stateVictory:  
    victoryScreen();
    break;
  default:    // error
    println("Error number 939; unknown state : "
      + state 
      + ".");
    exit();
    break;
  } // switch
}

void keyPressed () {
  switch (state) {
  case stateSampleGame:        
    keyPressedForGameScreen();
    break;
  case stateBoss:        
    keyPressedForBossScreen();
    break;
  case stateVictory:  
    keyPressedForVictoryScreen();
    break;
  default:    // error
    println("Error number 939; unknown state : "
      + state 
      + ".");
    exit();
    break;
  } // switch
}

void mousePressed () {
  switch (state) {
  case stateSampleGame:        
    mousePressedForGameScreen();
    break;
  case stateBoss:        
    mousePressedForBossScreen();
    break;
  case stateVictory:  
    mousePressedForVictoryScreen();
    break;

  default:    // error
    println("Error number 939; unknown state : "
      + state 
      + ".");
    exit();
    break;
  } // switch
}

int score;

void gameScreen() {
  fill(0);
  text("Click the screen and score 100 to win", 200, 280);
  text(score, 200, 300);
  if (score &gt;= 100) {
    state = stateBoss;
  }
}
void keyPressedForGameScreen() {
}
void mousePressedForGameScreen() {
  if (mousePressed) {
    score = score + 5;
  }
}
int bossHp = 150;
int startTime;
int duration = 5000;
float xspeed = 5;
float yspeed= 3;
float x = 480; 
float y = -100;

void bossScreen() {
  text(bossHp, 600, 100);
  if (millis() &gt; duration) {
    boss();
  }

  if (millis() &lt; startTime+5*1000) //"timer"
   ///banner
    if (blink(20)) {
      fill(80, 80, 80, 100);
      rect(-1, height/3, width, height/4);
      fill(0);
      text("BOSS BATTLE", width/2, height/2);
    }
    ///banner
}

boolean blink(int span) {
  return frameCount%(span*2) &lt; span;
}

void keyPressedForBossScreen() {
}
void mousePressedForBossScreen() {
  if (mousePressed) {
    bossHp = bossHp - 10;
    if (bossHp &lt;=0) {
      state = stateVictory;
    }
  }
}

void boss() {
  ellipse(x, y, 100, 300);
  y=y+yspeed;
  if (y &gt;= height/2-10) {
    yspeed =0;
    x = x + xspeed;
    if ((x &gt; width - 105) || (x &lt; 105)) {
      xspeed = xspeed * -1;
    }
  }
}
void victoryScreen() {
  text("You Win", width/2, height/2); 
}

void keyPressedForVictoryScreen() {
}
void mousePressedForVictoryScreen() {
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Restarting Game by using keyPressed() not working</title>
      <link>https://forum.processing.org/two/discussion/27672/restarting-game-by-using-keypressed-not-working</link>
      <pubDate>Tue, 03 Apr 2018 10:10:08 +0000</pubDate>
      <dc:creator>PF201</dc:creator>
      <guid isPermaLink="false">27672@/two/discussions</guid>
      <description><![CDATA[<p>Hi, so I have an assignment where I have to create a game. 
I have succeeded in creating the game but I am having trouble with restarting the game. I currently have it so when you click the screen the game starts and you use the keys to move the character around the screen and when all of the enemies have been removed the game over screen appears but when I try to press a button to go back to the beginning again it does not work? 
I have tried adding in a restart() function having looked at other entries on the forum but none of those were using a class so it did not work for me.
I really need help as this is due in under a week and I have spent several days trying to figure it out.</p>

<p>I am using processing version 3.3.5</p>

<p>The code is shown below:</p>

<pre><code>PFont font;

int Score;
//int ScoreIncrease;

Alien oneAlien;

int numberofStars = 300;
Stars[] theStars = new Stars[numberofStars];

int numberOfEnemies = 2;
Enemy [] theEnemies = new Enemy[numberOfEnemies];
int enemySize = 30;

int enemiesRemaining = numberOfEnemies;

boolean GamePlaying = false;
boolean GameOver = true;

void setup(){
  size(1000,800);
  font = loadFont("Consolas-BoldItalic-48.vlw");

  oneAlien = new Alien (150,150, (int) random(width), (int) random(height));

  for(int loop = 0; loop&lt;theStars.length; loop++){
    theStars[loop] = new Stars((int) random(width), (int) random(height), 5,5 ,30);
  }

  for(int loop = 0; loop&lt;theEnemies.length; loop++){
    theEnemies[loop] = new Enemy((int) random(width), (int) random(height),enemySize);
  }

}//ends setup

void draw(){
  background(0);
  stroke(0);

//draws the stars for the background      
  for (int loop = 0; loop&lt;theStars.length;loop++){
    theStars[loop].drawStars();
  }
  //sets what is to be shown on the screen when the game is not in play
  if(!GamePlaying){
    //print
    textFont(font,48);
    textAlign(CENTER);
    fill(0,250,0);
    text("Click the screen to start", width/2, height/2);
  }

  //sets what is shown when the game is in play
  if (GamePlaying) {
   text("Score = " + Score, 800,750);
   text("Time " + millis(), 150,750);
   oneAlien.drawHead();
   oneAlien.drawBody();
   oneAlien.drawEyes();
   oneAlien.drawSpots();
   oneAlien.Bounce();

  for(int loop = 0; loop &lt; theEnemies.length; loop++) {
    theEnemies[loop].display();
  }

  for(int loop = 0; loop &lt; theEnemies.length; loop++) {
    theEnemies[loop].move();
  }

  for(int loop = 0; loop &lt; theEnemies.length; loop++) {
    if(theEnemies[loop].checkForOverlap(oneAlien)) {
      theEnemies[loop].Xloc = -100;
      theEnemies[loop].Yloc = -100;

      int timeBonus = int((20000.0 / millis()) * 15);
      Score = Score + 10 +timeBonus;
      enemiesRemaining --;
      if(enemiesRemaining == 0){
        //GameOverScreen();
        GameOver = !GameOver;
      }
      }
    }
   textSize(48);
   fill(255,0,0);
   text("Click screen to pause", width/2, height/16);

  }  //ends Game Playing instructions

  if (!GameOver){
    background(0);
    textSize(64);
    fill(0,128,0);
    text("You Won!", width/2 ,height/2);
    fill(255);
    text("Press Enter to play again" , width/2, height/2 + 120);
    text("Your score = "+Score, width/2, height/2 +200);
  }//ends Game Over instructions

}//ends draw
void restart(){
  GameOver = !GameOver;
  GamePlaying = !GamePlaying;
  Score = 0;
  setup();

}//ends restart


void mousePressed(){
  //check position
  GamePlaying = !GamePlaying;
}//ends mouse Pressed

void keyPressed(){
  if (key == CODED) {
    if(keyCode ==UP) {
       oneAlien.moveUp();
    };
    if(keyCode ==DOWN) {
      oneAlien.moveDown();
    };
    if(keyCode ==LEFT) {
      oneAlien.moveLeft();
    };
    if(keyCode ==RIGHT){
     oneAlien.moveRight(); 
    };
    if(keyCode ==ENTER) {
     restart();
     GameOver = !GamePlaying;
    };

    }//ends key==coded
}//ends key pressed

///////////first class/////////////

class Alien{

  //attributes
  int bodyW;
  int bodyH;
  int bodyXloc;
  int bodyYloc;

  int headW;
  int headH;
  int headXloc;
  int headYloc;

  int spotW;
  int spotH;
  int spotXloc;
  int spotYloc;

  int moveBy, moveBy2;

  Alien(){
    bodyW = 300;
    bodyH = 400;
    bodyXloc = 450;
    bodyYloc = 450;

    moveBy = 1;
    moveBy2 = 1;
  }//end Alien

  Alien(int bW, int bH, int xl, int yl){
    bodyW = bW;
    bodyH = bH;
    bodyXloc = xl;
    bodyYloc = yl;

    moveBy = 5;
    moveBy2 = 5;
  // do {
   //  moveBy = (int) random(-5,0);
   //  moveBy2 = (int) random(-5,5);
  // }while (moveBy == 0 || moveBy2 == 0);
  }//end

  void drawBody(){
    fill(66,149,244);
    rectMode(CENTER);
    rect(bodyXloc, bodyYloc, bodyW, bodyH);
  }//end draw body

  void drawHead(){
    fill(244,158,66);
    headW = bodyW / 2;
    headH = bodyH / 2;
    headXloc = bodyXloc;
    headYloc = (bodyYloc - (bodyH / 2) - (headH / 2));
    rect(headXloc, headYloc, headW, headH);
  }//ends draw head

  void drawEyes(){
    fill(0);
    rect (headXloc, headYloc, (headW/2), (headH/2));
    float r = random(255);
    float g = random(255);
    float b = random(255);
    fill(r,g,b);
    rect (headXloc, headYloc, (headW/4), (headH/4));    
  }//end eyes

  void drawSpots(){
    float r = random(255);
    float g = random(255);
    float b = random(255);
    fill(r,g,b);
    spotW = bodyW / 2;
    spotH = bodyH / 2;
    spotXloc = bodyXloc;
    spotYloc = (bodyYloc - (bodyH / 1500) - (spotH / 1500));
    ellipse(spotXloc, spotYloc, spotW, spotH);     
  }//end draw spots

  void Bounce(){
    //checking when hitting right side
    if(bodyXloc &gt;= (width - (bodyW/2))){
      //moveBy = moveBy * -1;
      bodyXloc = (width - (bodyW/2));
    }

    //checking when hitting left side
    if(bodyXloc &lt;= (0 +(bodyW / 2))){
     // moveBy = moveBy * -1;
     bodyXloc = (bodyW / 2);
    }

    //checking when hitting the top of screen
    if(bodyYloc &gt;= (height - (bodyH/2))){
     // moveBy2 = moveBy2 * -1;
      bodyYloc = (height - (bodyH/2));
    }
    //checking when hitting the bottom of screen
    if(bodyYloc &lt;= (0 +(bodyH / 2 +headH))){
      //moveBy2 = moveBy2 * -1
      bodyYloc = (bodyH / 2 +headH);
    }
  }//ends bounce

  void moveUp(){
    bodyYloc = bodyYloc - moveBy2;
  }//end moveUp

  void moveDown(){
    bodyYloc = bodyYloc + moveBy2;
  }//ends moveDown

  void moveLeft(){
   bodyXloc = bodyXloc - moveBy; 
  }//ends moveLeft

  void moveRight(){
    bodyXloc = bodyXloc + moveBy;
  }//ends moveRight

  void move(){
    bodyXloc = bodyXloc + moveBy;
    bodyYloc = bodyYloc + moveBy2;
  }//ends move

}//ends class


///////////starts a new class/////////////

class Enemy{

  //attributes
  int enemySize;
  int Xloc;
  int Yloc;
  int xSpeed, ySpeed;

  Enemy(int Xl, int Yl, int Size) {
    Xloc = Xl;
    Yloc = Yl;
    enemySize = Size;

    do{
      xSpeed = (int) random(-10,10);
      ySpeed = (int) random(-10,10);
    }while(xSpeed == 0 || ySpeed == 0);
  }//ends

  void display(){
    fill (255,247,0);
    ellipse(Xloc, Yloc, enemySize, enemySize);
  }//ends

  void move(){
    Xloc = Xloc + xSpeed;
    Yloc = Yloc + ySpeed;

    //checks to make sure that the object will bounce off the top and bottom of the screen
    if (Xloc &gt; width - (enemySize / 2) || Xloc &lt; 0 + (enemySize / 2)){
      xSpeed = xSpeed * -1;
    }

    //makes sure that the enemy bounces on the sides of the screen
    if (Yloc &gt; height - (enemySize / 2) || Yloc &lt; 0 + (enemySize / 2)){
      ySpeed = ySpeed * -1;
    }

  }//ends

  boolean checkForOverlap(Alien oneAlien){
    //System.out.println("Alien x is " +Xloc);
    //System.out.println("Alien y is " +Yloc);    
    //System.out.println("Enemy x is " +oneAlien.bodyXloc);  
    //System.out.println("Enemy y is " +oneAlien.bodyXloc);


    int alienX = oneAlien.bodyXloc;
    int alienY = oneAlien.bodyYloc;

    int distanceApart = (int) dist(Xloc, Yloc, alienX, alienY);
    //System.out.println(distanceApart);

    if (distanceApart &gt;(enemySize / 2) + (oneAlien.bodyW / 2) + (oneAlien.headW)){
     // System.out.println("Miss");
      return false;
    }
    else {
     // System.out.println("Crash");
     return true; 
    }

  }//end check for overlap

}//ends class

////////////starts last class/////////////

class Stars{

  int starX;
  int starY;
  int starSize;
  int starWidth;
  int starHeight;


  Stars(){
    starSize = 5;
  }

  Stars(int sX, int sY, int sW, int sH, int size){
   starX = sX;
   starY = sY;
   starWidth = sW;
   starHeight = sH;
   starSize = size;
  }

  void drawStars(){
    fill(255);
    ellipse(starX, starY, starWidth, starHeight);
  }
}//end of the class
</code></pre>
]]></description>
   </item>
   <item>
      <title>Sound gets distorted when runned in processing</title>
      <link>https://forum.processing.org/two/discussion/25905/sound-gets-distorted-when-runned-in-processing</link>
      <pubDate>Wed, 10 Jan 2018 21:02:54 +0000</pubDate>
      <dc:creator>Faffie</dc:creator>
      <guid isPermaLink="false">25905@/two/discussions</guid>
      <description><![CDATA[<p>Hello World, I have written a processing code and have implemented a sound file. When I play it on a common player, a cleat woman voice comes out. If I run my code processing is distorting her voice into a slow man version... I am runnin processing on a MacBook Pro with the latest Java version.</p>

<pre><code>import processing.serial.*;
import processing.sound.*;


int S1_WAITING_FOR_PEOPLE  = 1;
int S2_PEOPLE_ENTERED      = 2;
int S3_LIGHT_FADE_OUT      = 3;
int S4_DARK                = 4;
int S5_MUSIC               = 5;
int S6_LIGHT_FADE_IN       = 6;
// make sure this is the last!!!!
int TERMINATE              = 7;

int mode = S1_WAITING_FOR_PEOPLE;




int no_one_when_distance_greater_then = 160; // cm
int time_before_dim = 5000; // ms

SoundFile file;
boolean is_playing = false;

Serial myPort;  

int dist;

boolean someone_present = false;
int someone_present_since_time;


int music_playing_since;
int music_duration;

int in_mode_since_ms;

void setup() {
  size(640, 360);

  printArray(Serial.list()); // "/dev/cu.usbmodem1411" cu.usb!!!

  myPort = new Serial(this, Serial.list()[1], 9600);
  //myPort.readStringUntil('\n');
  myPort.bufferUntil('\n');

  // Load a soundfile from the data folder of the sketch and play it back in a loop
  file = new SoundFile(this, "03.mp3");
  //file.loop();
  music_duration = (int) file.duration() * 1000;
  music_duration += 2000;

}      

void draw() {
  background(0);
  fill(255);
  text("frameCount: "+frameCount, 50, 25);
  text("dist: "+dist, 50, 50);
  text("mode: "+mode, 50, 75);


  if (frameCount == 180) {
    turn_on();
  } else if (frameCount &gt; 180) {

    if ( mode == S1_WAITING_FOR_PEOPLE) {

      if (someone_present == false) {
        if (dist &lt; no_one_when_distance_greater_then) {
          someone_present = true;
          someone_present_since_time = millis();
          change_mode(mode + 1);
        }
      }
    } else if (mode == S2_PEOPLE_ENTERED) {
      text("millis: "+millis(), 50, 100);
      text("someone_present_since_time: "+someone_present_since_time, 50, 125);
      text("time_before_dim: "+time_before_dim, 50, 150);
      if (millis() - someone_present_since_time &gt; time_before_dim) {
        change_mode(mode + 1);
      }
    } else if (mode == S3_LIGHT_FADE_OUT) {
      turn_off();
      change_mode(mode + 1);
    } else if (mode == S4_DARK) 
    {
      change_mode(mode + 1);
    } else if (mode == S5_MUSIC) 
    {
      if (is_playing == false) {
        file.play();
        is_playing = true;
        music_playing_since = millis();
      }
      if (millis() - music_playing_since &gt; music_duration) {
        is_playing = false;
        file.stop();
        change_mode(mode + 1);
      }
    } else if (mode == S6_LIGHT_FADE_IN) 
    {
      // todo
      if (millis() - in_mode_since_ms &gt; 1000) {
        change_mode(mode + 1);
      }

    } else if (mode == TERMINATE) 
    {
      change_mode(S1_WAITING_FOR_PEOPLE);
      someone_present = false; // reset
      println("turn_on();");
      turn_on();
    }
  }
}


void change_mode(int m) {
  mode = m;
  in_mode_since_ms = millis();
}



void serialEvent(Serial p) { 
  String s = p.readString();
  if (s != null) {
    s = s.replace("\r\n", "");
    if (s.contains("Distance Measured")) {
      String[] tokens = split(s, "=");
      dist = int(tokens[1]);
    }
  }
} 


void turn_on() {
  myPort.write("on");
}

void turn_off() {
  myPort.write("off");
}

void keyPressed() {
  if (key == 'a') {
    turn_on();
  }
  if (key == 's') {
    turn_off();
  }
}
</code></pre>

<p>Thanks for your help!</p>
]]></description>
   </item>
   <item>
      <title>game doesnt resume after answering quiz question</title>
      <link>https://forum.processing.org/two/discussion/25667/game-doesnt-resume-after-answering-quiz-question</link>
      <pubDate>Thu, 21 Dec 2017 13:13:07 +0000</pubDate>
      <dc:creator>panda123</dc:creator>
      <guid isPermaLink="false">25667@/two/discussions</guid>
      <description><![CDATA[<p>Hallo guys iam currently programming a game for my project and dont know hot to solve my problem. When the figur enters a sprecific space defined in the method enterRect() a new quiz screen is called. when ur answer is correct the method correctAnswer will be called and when u answer false the method falseAnswer() will be called.My problem is after i the answer  question the display doesnt change from correct/false to the game. my variable correctAnswer/falseAnswer is always on 1 after answering the question.</p>

<h1>Edit the methods correctAnswer and falseAnswer() are in the Question class.</h1>

<p>Code:</p>

<p>my question variables and methods for quiz screen:</p>

<pre><code>    public int falseAnswer=0;
    public int correctAnswer=0;

void setup() {
  frameRate(60);
  questions= new Question[7];

  ball= new Ball(50);
  s= new Shape();
  s.createRect(100, 80);
  s.createRect(100, 500);

  s.createRect(800, 80);
  s.createRect(800, 500);
}

void draw() {

  if (gameScreen==0) {
    initScreen();
  } else if (gameScreen==1) {
    gameStartScreen();
  } else if (gameScreen==2) {
    gameOverScreen();
  } else if (gameScreen==3) {
    quizScreen();
  }
  //print("K "+correctAnswer+" F "+falseAnswer);
}


public void quizScreen() {
  questions[0]=new Question("Wer", "Wer", "Wer", "Wer", "Wer");
  question=questions[0];
  if (correctAnswer==1) {
    question.correctAnswer();
  } else if (falseAnswer==1) {
    question.falseAnswer();
  }
}


void startGame() {
  gameScreen=1;
}
void gameOver() {
  gameScreen=2;
}
public void startQuiz() {
  gameScreen=3;
}


void mousePressed() {

  // if we are on the initial screen , start the game 
  if (gameScreen==0) { 
    startGame();
  }
  if (gameScreen==1) {
    startGame();
  }
  if (gameScreen==2) {
    startGame();
  }
  if (gameScreen==3) {
    startQuiz();
   if(correctAnswer==1){
    startGame();
   }else if(falseAnswer==1){
    gameStartScreen(); 
   }
}
}



public void mouseReleased() {
  if (mouseX &gt;0 &amp;&amp; mouseX &lt; (0+150) &amp;&amp; mouseY &gt;150 &amp;&amp; mouseY&lt;(150+150)) {
    falseAnswer=1;
  } else if (mouseX &gt;150 &amp;&amp; mouseX &lt;(150+150) &amp;&amp; mouseY &gt;150 &amp;&amp; mouseY&lt; (150+150)) {
    falseAnswer=1;
  } else if ( mouseX &gt; 300 &amp;&amp; mouseX &lt;(300+150) &amp;&amp; mouseY &gt;150 &amp;&amp; mouseY &lt;(150+150)) {
    falseAnswer=1;
  } else if (mouseX &gt;450 &amp;&amp; mouseX &lt;(450+150) &amp;&amp; mouseY &gt;150 &amp;&amp; mouseY &lt;(150+150)) {
    correctAnswer=1;
  }
}



public void enterRect() {

  //not finished
  if (x&gt;=85 &amp;&amp; x&lt;=245 &amp;&amp; y&gt;=60 &amp;&amp; y&lt;=135 ) {
    startQuiz();
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to repeat draw() void multiple times after pressing a button?</title>
      <link>https://forum.processing.org/two/discussion/25487/how-to-repeat-draw-void-multiple-times-after-pressing-a-button</link>
      <pubDate>Sun, 10 Dec 2017 05:47:57 +0000</pubDate>
      <dc:creator>LilyStilson</dc:creator>
      <guid isPermaLink="false">25487@/two/discussions</guid>
      <description><![CDATA[<p>I got a code for a game that has PC turn and Player turn. The question is, how can I return to PC turn, after the Player presses "Enter"?</p>

<pre><code>void setup()
{
  size (1250, 500);
  Background();
  noStroke();
  rectMode (CENTER);
  ellipseMode (CENTER);
  frameRate (60);
}

void draw()
{
  if (F == false)                              //F is a Flag for player/PC turn (false - PC, true - user)
  {
    for (++i; i&lt;p1; i += 1)
    {
      k = round (random (1, 6));
      Dice (x, y, k);                          //Making a random Dice from 1 to 6
      if (k == 1)                              //If dice getting 1 on it then stop and go to the player turn
      {
        x = 100;
        break;
      }
      x += 115;
    }
    F = true;                                    //Giving a turn to player
    x = 100;
  }
}

void keyPressed()
{
  if (F == true)                               //If it's player turn
  {  
    if (key == ' ')                             //And if spacebar is pressed
    {
      k = round (random (1, 6));       
      y = 350;
      Dice (x, y, k);                           //Make a random Dice from 1 to 6
      x += 115;
    }
    if (keyCode == ENTER)              //If Enter is pressed the turn must go to the PC and code must started again, but nothing happens
    {                                             
      F = false;
      Background();
      x = 100;
      y = 100;
      draw();
    }
    if (keyCode == ESC)                   //Closing the game, if Esc is pressed
    {
      exit();
    }
  }
}
</code></pre>

<p>Keep in mind that some void's ("void Dice (x, y, k);" and "void Background ();") are hidden. If you need, I can show the full code.
Thank you in advance</p>
]]></description>
   </item>
   <item>
      <title>creating a delay after a collision</title>
      <link>https://forum.processing.org/two/discussion/25312/creating-a-delay-after-a-collision</link>
      <pubDate>Thu, 30 Nov 2017 22:39:27 +0000</pubDate>
      <dc:creator>CSoulo</dc:creator>
      <guid isPermaLink="false">25312@/two/discussions</guid>
      <description><![CDATA[<p>Hey, I'm trying to create a delay in-between when a collision occurs and when I have my game over screen to pop up. I want the program to still be running but have a five second delay before game over shows up. I've tried a few methods such 
 as using millis() but it always starts right when I start my program. Could someone tell me how I should go about this? thanks in advance.</p>
]]></description>
   </item>
   <item>
      <title>How many comments are too much comments</title>
      <link>https://forum.processing.org/two/discussion/25013/how-many-comments-are-too-much-comments</link>
      <pubDate>Tue, 14 Nov 2017 23:40:03 +0000</pubDate>
      <dc:creator>schotsl</dc:creator>
      <guid isPermaLink="false">25013@/two/discussions</guid>
      <description><![CDATA[<p>I'm starting a bigger project and wanted to make sure it would be understandable, so I started adding comments but I feel like I'm way over doing it after looking around a bit.</p>

<p>Here's a snippet</p>

<pre><code>//This is the start scene.
void sceneZero() {
  boolean returnButtonDisappeared = true;
  boolean usernameBoxDisappeared = true;

  //If the previous scene was the menu scene.
  if (previousScene == 3) {
    //The booleans will be set to false if the objects haven't disappeared.
    returnButtonDisappeared = returnButtonDisappear();
    usernameBoxDisappeared = usernameBoxDisappear(); 

    //If either of the objects haven't disappeared keep drawing that object.
    if (!returnButtonDisappeared) returnButton();
    if (!usernameBoxDisappeared) usernameBox();
  }

  //If both the objects have disappeared draw the new objects and make them appear.
  if (usernameBoxDisappeared &amp;&amp; returnButtonDisappeared) {
    specialThanksAppear();
    pressHereAppear();

    specialThanks();
    pressHere();
  }
}
</code></pre>

<p>Or is this a normal amount of comments?</p>
]]></description>
   </item>
   <item>
      <title>making a Gameover screen when a collision occurs</title>
      <link>https://forum.processing.org/two/discussion/25014/making-a-gameover-screen-when-a-collision-occurs</link>
      <pubDate>Wed, 15 Nov 2017 00:24:32 +0000</pubDate>
      <dc:creator>CSoulo</dc:creator>
      <guid isPermaLink="false">25014@/two/discussions</guid>
      <description><![CDATA[<p>Hey I was wondering how I would be able to go about  making a gameover screen when a collision occurs. Right now i have a static wall which is called wal2 in the code below and i'm using the dist function to detect when my mouse is touching the ellipse and what I want is for it to change  to screen GAMEOVER when the collision is true.</p>

<p><code>void draw() {
  if (screen == MAIN_MENU) {
    MAIN_MENU();
  } else if (screen == INSTRUCTIONS) {
    INSTRUCTIONS();
  } else if (screen == GAMEOVER) {
    GAMEOVER();
  } else if (screen == STORY_1) {
    STORY_1();
  } else if (screen ==  LEVEL_1) {
    LEVEL_1();
  }
}</code>
`
void LEVEL_1() {</p>

<p>// wall collisions//
  boolean collision = true;</p>

<p>if (collision) {
    screen = GAMEOVER;
  } else {
    screen = LEVEL_1;
  }</p>

<p>if (dist(wal2_x, wal2_y, mouseX, mouseY)&lt;=162) {
     collision = true;
  } 
}`</p>
]]></description>
   </item>
   <item>
      <title>making a Gameover screen when a collision occurs</title>
      <link>https://forum.processing.org/two/discussion/25015/making-a-gameover-screen-when-a-collision-occurs</link>
      <pubDate>Wed, 15 Nov 2017 00:28:36 +0000</pubDate>
      <dc:creator>CSoulo</dc:creator>
      <guid isPermaLink="false">25015@/two/discussions</guid>
      <description><![CDATA[<p>Hey I was wondering how I would be able to go about making a gameover screen when a collision occurs. Right now i have a static wall which is called wal2 in the code below and i'm using the dist function to detect when my mouse is touching the ellipse and what I want is for it to change to screen GAMEOVER when the collision is true.</p>

<p><code>void draw() {
 if (screen == MAIN_MENU) {
 MAIN_MENU(); 
} else if 
(screen == INSTRUCTIONS) { 
INSTRUCTIONS(); 
} else if (screen == GAMEOVER) {
 GAMEOVER(); } 
else if (screen == STORY_1) { 
STORY_1(); 
} else if (screen == LEVEL_1) {
 LEVEL_1(); 
}
 }</code>
` // wall collisions//
  boolean collision = true;</p>

<p>if (collision) {
    screen = GAMEOVER;
  } else {
    screen = LEVEL_1;
  }</p>

<p>if (dist(wal1_x, wal1_y, mouseX, mouseY)&lt;=162) {
     collision = true;
  } else { 
    collision = false;
  }`</p>
]]></description>
   </item>
   <item>
      <title>There is a way to make a Sprite desappear when i'm on a Menu interface, and after, it appear again?</title>
      <link>https://forum.processing.org/two/discussion/24981/there-is-a-way-to-make-a-sprite-desappear-when-i-m-on-a-menu-interface-and-after-it-appear-again</link>
      <pubDate>Mon, 13 Nov 2017 00:27:23 +0000</pubDate>
      <dc:creator>Blind17</dc:creator>
      <guid isPermaLink="false">24981@/two/discussions</guid>
      <description><![CDATA[<p>I'm making a game with my friend witch has a interface menu, although when i run the menu code with the game code, we can see all the sprites moving around on the menu. So there is any way to make theses Sprites desappear?
Ah, just a little reminder, the menu code is going inside the draw function with the game, like:</p>

<pre><code>function draw() {
  if (menuOn === false &amp;&amp; instructions === false) {
    background(155);
    menu();
  } else if (menuOn === true &amp;&amp; instructions === true) {
    menu2(); // menu2 is the instructions //
  } else {
    // the game is going to be here//
    background(255);
  }
  drawSprites();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>mouse click save help</title>
      <link>https://forum.processing.org/two/discussion/24756/mouse-click-save-help</link>
      <pubDate>Thu, 26 Oct 2017 21:53:49 +0000</pubDate>
      <dc:creator>myusername005001</dc:creator>
      <guid isPermaLink="false">24756@/two/discussions</guid>
      <description><![CDATA[<p>Hello, 
currently my code is set up that if you click on the right side there is a counter that will go up for every click. there is a counter on the left as well. however i want a way to save the data. for example i want to be able to ask the user if they are male or female. then from there i want to see how many males clicked on left side of frame, and how many females clicked on right side of the frame.</p>

<pre><code>            PImage pink;
            PImage blue;
            PImage shoe;
            int mouseClicksR=0;
            int mouseClicksL=0;
            int midscreen;

            void setup () {
             size (800,800);
            midscreen=400;
            pink= loadImage("shoep.png");
            blue= loadImage("shoeb.png");
            shoe= loadImage("shoe.png");
             textAlign(-20, 500);
              textSize(50);

            }




            void draw () {
              background(0);
               image(pink, 550,275);
               image(blue, -20,255);
               image(shoe, 150,150);
                   textSize(32);
            text("Vote for which shoe you see", 150, 75); 
                 text(mouseClicksL+"", 75,500,width,height);
                  text(mouseClicksR+"", 650,500,width,height);


            }
            void mousePressed() {
             // if (mouseButton == LEFT) { mouseClicksL++; } else { mouseClicksL = 0; }
             // if (mouseButton == RIGHT) { mouseClicksR++; } else { mouseClicksR = 0; }

              if (mouseX &lt; midscreen)  //clicked on left side of screen
                mouseClicksL++;
              else if (mouseX &gt; midscreen)  //clicked on right side of screen
                mouseClicksR++;
            }
</code></pre>
]]></description>
   </item>
   <item>
      <title>Selective draw iterations</title>
      <link>https://forum.processing.org/two/discussion/24735/selective-draw-iterations</link>
      <pubDate>Wed, 25 Oct 2017 14:33:37 +0000</pubDate>
      <dc:creator>Néon</dc:creator>
      <guid isPermaLink="false">24735@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
I would like to be able to select what part of my code gets iterated over by draw(). I need one part to be drawn only once and another to be drawn continuously. Is there a way to selectively apply noLoop() and loop() to parts of our code?</p>

<p>To be specific, I'm making a 2d game with fractal background and I want that background to be drawn once without my other objects leaving a trail behind. I can't have the background change every now and then. Also, some of my objects are player controlled so continuous draw is required.</p>

<p>Any tips/solutions are welcome, ty.</p>
]]></description>
   </item>
   <item>
      <title>How to make a timer while keyPressed</title>
      <link>https://forum.processing.org/two/discussion/24731/how-to-make-a-timer-while-keypressed</link>
      <pubDate>Wed, 25 Oct 2017 04:56:50 +0000</pubDate>
      <dc:creator>PomSmit</dc:creator>
      <guid isPermaLink="false">24731@/two/discussions</guid>
      <description><![CDATA[<p>hello,</p>

<p>Im new to processing and I cant figure out how to begin my program with a startpage, then when a key is pressed show a different page with a countdown of 10 seconds and a red blinking circle. After 10 seconds you release the key and it shows a message and closes the program.</p>

<p>I got a few things done like it begins at the startpage but the timer already starts running when i run the program, not when the key is pressed. It should begin counting when the key is pressed
When i hold a key it does jump to the "holding a key" page. i tried a lot of other methods with a timer but they all failed because the timer doenst start when the key is pressed.</p>

<p>If someone could give me some tips it would be great!</p>

<p>code:</p>

<pre><code>int fadeAmount = 5;
int opacity = 255;
int circleSize = 75;
int circleYpos = 700;
int circleXpos = 700;
int timer;
int count = 10;
int trigger = 0;


void setup() {
  size(800, 800); 
  smooth();
  background(250);
} 

void draw() {

  if (keyPressed == true) {
    circle_on();
  } else if (keyPressed == true || timer &gt; 10000) {
    processing();
  } else {
    startPage();
  }
}

void startPage() {
  fill(0);
  background(250);
  textSize(50);
  text("Start", width/2 - 50, height/2);
}

void circle_on() {

  background(250);
  fill(255, 2, 2, opacity);
  noStroke();
  ellipse(circleXpos, circleYpos, circleSize, circleSize);
  if ((opacity ==0) || (opacity ==255))  
    fadeAmount = -fadeAmount;

  opacity += fadeAmount;

  fill(0);
  textSize(50);
  text("Are you sure?", 200, 720);
}



void processing() {
  background(250);
  fill(0);
  textSize(50);
  text("Agreement success.", 150, 720);
  fill(250);
  noStroke();
  ellipse(circleXpos, circleYpos, circleSize, circleSize);
}

void keyPressed() {
  timer = millis();

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to make text appear for x millis() after key input?</title>
      <link>https://forum.processing.org/two/discussion/24617/how-to-make-text-appear-for-x-millis-after-key-input</link>
      <pubDate>Wed, 18 Oct 2017 09:06:12 +0000</pubDate>
      <dc:creator>Shreerang_Vaidya</dc:creator>
      <guid isPermaLink="false">24617@/two/discussions</guid>
      <description><![CDATA[<p>I made a class in which a player draws some text from x millis() to y millis() when function say("hi",x,y) is used. It uses millis();
Example:
</p>

<pre><code>Player p;

void setup(){
  //initializes the sketch
}
void draw(){
  p.say("Hi!",1000,2500)//Hi!
  p.say("i come after mousePressed",x,y)//Here comes the problem!
}
//end</code></pre>

<p></p>

<p>I tried playing with millis-int thingie but the problem is that the variable changes per frame. Please help me.</p>
]]></description>
   </item>
   <item>
      <title>Any precedence of built-in functions? (text(), delay()...etc...)</title>
      <link>https://forum.processing.org/two/discussion/24498/any-precedence-of-built-in-functions-text-delay-etc</link>
      <pubDate>Wed, 11 Oct 2017 20:50:53 +0000</pubDate>
      <dc:creator>lowbpro</dc:creator>
      <guid isPermaLink="false">24498@/two/discussions</guid>
      <description><![CDATA[<p>Hi friends,</p>

<p>I am just wondering below code, a simple one:</p>

<pre><code>void setup() {
  size(200,200);
  background(0);
}

void draw() {
  fill(255);
  text("hi",80,80);
  delay(1000);
  text("hi2",80,80);
  background(0);
  text("hi3",80,80);
}
</code></pre>

<p>My thought is that the window will show "hi", then wait for 1 second, show "hi2", clean up, then "hi3".
However, what i see is: keep showing "hi3".
What's more strange is that, when i go into debugger mode step by step, I find "hi" is not showing up at all! So i get confused if, within the draw() loop, there is precedence of these regular functions?
Thanks to all!</p>
]]></description>
   </item>
   <item>
      <title>putting a Loading Screen.</title>
      <link>https://forum.processing.org/two/discussion/24202/putting-a-loading-screen</link>
      <pubDate>Thu, 21 Sep 2017 13:32:26 +0000</pubDate>
      <dc:creator>Dronerone24</dc:creator>
      <guid isPermaLink="false">24202@/two/discussions</guid>
      <description><![CDATA[<p>Hi guys. Can someone tell me how to put a loading screen? An example would do. Thank you!</p>
]]></description>
   </item>
   <item>
      <title>Problem with code...images, random function etc</title>
      <link>https://forum.processing.org/two/discussion/23857/problem-with-code-images-random-function-etc</link>
      <pubDate>Fri, 18 Aug 2017 22:22:36 +0000</pubDate>
      <dc:creator>netrate</dc:creator>
      <guid isPermaLink="false">23857@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to get a bomb to drop and when it hits the ground, it brings up an image of an explosion - the bomb resets and drops again.</p>

<p>NEXT I want a new random location for the bomb.  I don't know where I am going wrong.  I am trying to make this more efficient by using function for each thing that I am doing.  I am sure there is something major wrong here, but I just can't make heads of tails of it right now . I don't know how to attach the two images.</p>

<p>I also had to make up my own TIME DELAY because I can't figure out how to do it.</p>

<pre><code>start_drop=0

def setup():
    global img, img2, random_start_x
    size(400, 400)
    background(255) # white
    img=loadImage("bombsmall.jpg")
    img2=loadImage("explosion.jpg")
    random_start_x=int(random(1,400))    

def draw():
    global img, img2
    random_start()

def random_start():
    random_start_x=int(random(1,400))    
    print("This is the new start on x ", random_start_x)     
    bomb()

def bomb():
    global start_drop, img, img2, random_start_x
    background(255)
    image(img, random_start_x, start_drop)
    start_drop=start_drop+5
    if start_drop&gt;360:
        c=0
        while c&lt;1000:
           explosion()
           print(c)
           c=c+1
        start_drop=0
        random_start()

def explosion():
       global img2
       print("test")
       img2=loadImage("explosion.jpg")
       image(img2, random_start_x, 100)
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to game game over screens depending on different situations.</title>
      <link>https://forum.processing.org/two/discussion/23774/how-to-game-game-over-screens-depending-on-different-situations</link>
      <pubDate>Fri, 11 Aug 2017 17:28:16 +0000</pubDate>
      <dc:creator>Marveling</dc:creator>
      <guid isPermaLink="false">23774@/two/discussions</guid>
      <description><![CDATA[<p>Trying to make it so that if you hit the moving balls its a "gameover", screen crashes/shut down, and make it so that if you reach the finish line the game also shuts down, any advice?</p>

<p>-Code</p>

<pre><code>     int x = 100;
int y = 0;
int b = 500;
int c = 500;
int dx = 5;
int v = 500;
int vx = 5;

int s = 500;
int sx = 5;
int marve = 500;
int sherl = 5;
int h = 500;
int hx = 5;
int j = 500;
int jx = 5;



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

void draw(){
  background(0);
  textSize(32);
text("FINISH", 450, 950); 
fill(0, 102, 153);
  textSize(20);
  text("X: " + x, 5,25);
  text("Y: " + y, 100,25);
  textSize(20);
  text("Made by Sherlyn and Marvellous", 650,25);
  fill(#FF1242);
  ellipse ( c,300, 50,50);
  c += vx;
     if(c+75 &gt; width||c-25 &lt; 75) {
       vx *= -1;
     }

  fill(#FF1212);
  ellipse (x, y, 40,40);
  fill(#E5BD2A);
  ellipse(b,100, 50,50);
        b -= dx;
     if(b+150 &gt; width||b-50 &lt; 0) {
       dx *= -1;
     }
  fill(#12C490);
  ellipse(s, 500, 50,50); 
    s -= sx;
     if(s+25 &gt; width||s-25 &lt; 0) {
       sx *= -1;
     }
  fill(#C600E5);
  ellipse(marve, 700,50,50);
    marve += sherl;
      if(marve + 200 &gt; width|| marve - 100 &lt; 0) {
        sherl *= -1;

      }
  fill(#E52A65);
  ellipse(h, 600,25,25);
    h -= hx;
      if(h + 200 &gt; width|| h - 200 &lt; 0) {
        hx *= -1;
      }
  fill(#FCFBFA);
  ellipse(j, 200, 25,25);
  j += jx;
  if(j + 250 &gt; width|| j - 150 &lt; 0) {
    jx *= -1;
  }      
}


void keyPressed() {

  if (key == CODED) {
    if (keyCode == UP) {
      y -= 8;
    } else if (keyCode == DOWN) {
      y += 8;
    } else if (keyCode == LEFT) {
      x -= 8;
    } else if (keyCode == RIGHT) {
      x += 8;
}  
</code></pre>

<p>} 
}</p>
]]></description>
   </item>
   <item>
      <title>How to switch to multiple states within a current state using individual keys?</title>
      <link>https://forum.processing.org/two/discussion/23100/how-to-switch-to-multiple-states-within-a-current-state-using-individual-keys</link>
      <pubDate>Sat, 17 Jun 2017 14:53:41 +0000</pubDate>
      <dc:creator>clarketravis</dc:creator>
      <guid isPermaLink="false">23100@/two/discussions</guid>
      <description><![CDATA[<p>I am currently trying to code some form of interactive fiction using Processing. I am relatively new to coding so please go easy on me. I attempted to use switch case and set up each possibility from each page within a case and then switch between them using void keyPressed(){ but I do not think I understand the code enough to be able to pull it off. It is going to be a tree of cases effectively as each case will need to have the option to switch to three other cases using 'a' 'b' and 'c' within itself and then all three options need to be able to do the same. I'm expecting it'll be a case of get the code correct for the first branch of the tree then be able to just keep duplicating it but I cannot get it right.</p>

<p>Is there a better way to achieve what I'm trying, or does anybody have any example code I can look at?</p>
]]></description>
   </item>
   <item>
      <title>Error in changing screen</title>
      <link>https://forum.processing.org/two/discussion/22742/error-in-changing-screen</link>
      <pubDate>Wed, 24 May 2017 16:20:04 +0000</pubDate>
      <dc:creator>Epicness35</dc:creator>
      <guid isPermaLink="false">22742@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I am designing a Processing type game. I made it so I can click "buttons' (rectangle) and it draws something else; the part of the other screen. When I click the "Play" button, it goes immediately somewhere else, to the "Science" screen, which is not how it is supposed to work. When I check the variable of screen, which I am using to change drawings, it said it is 3, which means the I clicked twice, but I didn't. I would appreciate any help. Thanks!</p>

<p>``</p>

<pre><code>int screen = 0;
void setup()  {
  size(1000,700);
}




void draw()  {
  background(1,0,175);
  if(screen == 0)  { //home screen
    //Title
    fill(255,255,255); //fill of rectangle of text box to white
    rectMode(CENTER); //center
    rect(width/2, height/10, 350,75); // centered and a little bit down from top
    textSize(30); //text size
    fill(0,0,0); //black color of text
    text("Jeopardy in Processing!",width/2-165, height/10+10); //centered in rectangle

    //Play button
    fill(255,255,255);
    rect(width/2,height/3+50,250,75); //below title button and smaller
    textSize(30); //text size
    fill(0,0,0); //black text
    text("Play!",width/2-30,height/3+60); //makes the text inside the box
    //Instructions Button
    fill(255,255,255); //fill of rectangle of text box to white
    rect(width/2,height/2+50,250,75); //below play button 
    textSize(30); //text size
    fill(0,0,0); //black text
    text("Instructions",width/2-83,height/2+60);
    //Credits button
    fill(255,255,255); //white color
    rect(width/2,height/2+163,250,75); //below instructions button
    textSize(30); //text size
    fill(0,0,0); //black text
    text("Credits",width/2-50,height/2+173); //add the text
  }


  if (screen == 1)  { //play screen
    //Title "Choose Subject!"
    fill(255,255,255); //fill of rectangle of text box to white
    rectMode(CENTER); //center
    rect(width/2, height/10, 350,75); // centered and a little bit down from top
    textSize(30); //text size
    fill(0,0,0); //black color of text
    text("Choose Subject!",width/2-120, height/10+10); //centered in rectangle
    fill(255,255,255); //white rectangle
    rect(width/2,height/3+50,250,75); //below title button, Science
    textSize(30); //text size
    fill(0,0,0); //black text
    text("Science!",width/2-55,height/3+60); //makes the "Science" text inside the box
    //Math
    fill(255,255,255); //fill of rectangle of text box to white
    rect(width/2,height/2+50,250,75); //below science button 
    textSize(30); //text size
    fill(0,0,0); //black text
    text("Math",width/2-37,height/2+60);
    //Comp Sci button
    fill(255,255,255); //white color
    rect(width/2,height/2+163,250,75); //below instructions button
    textSize(30); //text size
    fill(0,0,0); //black text
    text("Comp Sci",width/2-65,height/2+173); //add the text

  }
  if (screen == 2)  {//instructions screen
   fill(255,255,255);
   rectMode(CENTER);
   rect(width/2,height/10,350,75); //rectangle
   //Text
   textSize(30); //text size
   fill(0,0,0); //black color of text
   text("Instructions",width/2-80,height/10+10); //centered in rectangle
   //Instruction box
   fill(255,255,255); //white rectangle
   rect(width/2,height/2-40,850,300);
   //Text in instruction box
   textSize(25); //text size
   fill(0,0,0);
   text("This is a Jeopardy game. You can work on teams or you can play by yourself. You can click the 'Play' button to get 3 subjects to study, Math, Science, Computer Science. You click the button for which subject you want to study. Then there will be topics for each subject, and you choose the cash amount, which is correlated to difficulty. You then answer the multiple choice questions, and get points based on that. Good Luck!" ,
   500,400,800,height/2+100);
   //Back button
   fill(255,255,255); //white rectangle
   rect(width/2,height/2+200,250,75); //rectangle below instructions
   fill(0,0,0); //black text
   text("Back",width/2-25,height/2+210); //text 
  }
  if (screen==3)  {//science screen
    text("science",width/2,height/2);


  }
}





void mousePressed()  {
  //Change the screen based on which button clicked
  //play button
  if (mouseX &gt;= 375 &amp;&amp; mouseX &lt;= 625 &amp;&amp; mouseY &lt;= 320 &amp;&amp; mouseY &gt;= 244 &amp;&amp; screen == 0)  { //if clicked play button
    println("Clicked play button"); //tell user
    screen = 1; //change screen variable 
    println("screen is",screen);
  }
  //instruction button
  if (mouseX &gt;= 375 &amp;&amp; mouseX &lt;= 625 &amp;&amp; mouseY &lt;= 437 &amp;&amp; mouseY &gt;= 363 &amp;&amp; screen == 0)  { //if clicked instructions button
    println("Clicked instructions button"); //tell user
    screen = 2; //change screen variable

  }
  //back button from instructions screen
  if (mouseX &gt;= 375 &amp;&amp; mouseX &lt;= 624 &amp;&amp; mouseY &lt;=587 &amp;&amp; mouseY &gt;= 512 &amp;&amp; screen == 2)  {
    screen = 0;


  }
  //Science button on play screen
  if (screen == 1)  { //if on the play screen to choose subjects
    if (mouseX &gt;= 375 &amp;&amp; mouseX &lt;= 625 &amp;&amp; mouseY &lt;=325 &amp;&amp; mouseY &gt;= 243)  { //if click science button
      screen = 3; //go to science screen



    }
  }

  println(mouseX,mouseY);

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Can I make a condition for the setup() and draw() to execute?</title>
      <link>https://forum.processing.org/two/discussion/22490/can-i-make-a-condition-for-the-setup-and-draw-to-execute</link>
      <pubDate>Tue, 09 May 2017 19:06:06 +0000</pubDate>
      <dc:creator>rebelL1ON</dc:creator>
      <guid isPermaLink="false">22490@/two/discussions</guid>
      <description><![CDATA[<p>Hello,
Maybe it's a dumb question, but is there a way to make a condition  before setup() and draw()? (I want to make "Press space to start the game" -game that is in my sketch- ) 
Maybe I could do it in the draw() too but I don't know how to do it.</p>

<p>Thank you in advance. :)</p>
]]></description>
   </item>
   <item>
      <title>Processing not reacting properly to arduino via firmata</title>
      <link>https://forum.processing.org/two/discussion/22376/processing-not-reacting-properly-to-arduino-via-firmata</link>
      <pubDate>Thu, 04 May 2017 00:01:46 +0000</pubDate>
      <dc:creator>ailisg</dc:creator>
      <guid isPermaLink="false">22376@/two/discussions</guid>
      <description><![CDATA[<p>Hi,
I'm using an arduino uploaded with firmata. I have a potentiometer hooked up and as the user turns the potentiometer, depending on the value they land on, a certain video will play. So if they turn it up more a different video will play etc.
What's happening is I have to turn the potentiometer to a value, and then turn it all the way back to zero and then the corresponding video from the first value will play. In between it's showing the "image" I'm calling as a part of the video, but usually only one of them, not all of them. I'm new to the video library and processing &amp; arduino in general.
Thanks for your help!</p>

<pre><code>import processing.serial.*;

import cc.arduino.*;
import org.firmata.*;


import processing.video.*;

Arduino arduino;

Movie oneDegree, twoDegrees, threeDegrees;


int sensorPin = 0;    // select the input pin for the potentiometer
int val;



void setup() {
  size(960, 540);
  arduino = new Arduino(this, Arduino.list()[3], 57600); //sets up arduino
   val = arduino.analogRead(sensorPin); 
   println(Arduino.list());
   oneDegree = new Movie(this, "comp1.mp4");
   twoDegrees = new Movie(this, "comp2.mp4");
   threeDegrees = new Movie(this, "comp3.mp4");


}

void draw() {
 val = arduino.analogRead(sensorPin); 
 println(val);
 image(oneDegree, 0, 0);
 image(twoDegrees, 0, 0);
 image(threeDegrees, 0, 0);

  if(val &gt; 10 &amp;&amp; val &lt; 348) { 
    oneDegree = new Movie(this, "comp1.mp4");
    oneDegree.play();
  }

  else if(val &gt; 348 &amp;&amp; val &lt; 686) {
  twoDegrees = new Movie(this, "comp2.mp4");
    twoDegrees.play();
  }

  else if(val &gt; 686 &amp;&amp; val &lt; 1024) {
   threeDegrees = new Movie(this, "comp3.mp4");
  threeDegrees.play();
  }

  if (oneDegree.time() == oneDegree.duration()) { //movie must be finished
twoDegrees.play();
  }
if (twoDegrees.time() == twoDegrees.duration()) { //movie must be finished
threeDegrees.play();
}
}

void movieEvent(Movie m) {
  m.read();
  /* if (m == oneDegree) {
    oneDegree.read();
  } 
  else if (m == twoDegrees) {
    twoDegrees.read();
  }
  else if (m == threeDegrees) {
    threeDegrees.read();
  }*/
}



/* void movieEvent(Movie ) {
  if (val &lt;= 348) {
    oneDegree.read();
  } 
  else if (val &gt; 348 &amp;&amp; val &lt;= 686) {
    twoDegrees.read();
  }

  else if (val &gt; 686 &amp;&amp; val &lt;= 1024) {
    threeDegrees.read();
  }
} */
</code></pre>
]]></description>
   </item>
   <item>
      <title>How to change between stages Processing</title>
      <link>https://forum.processing.org/two/discussion/22179/how-to-change-between-stages-processing</link>
      <pubDate>Mon, 24 Apr 2017 21:30:36 +0000</pubDate>
      <dc:creator>Henji</dc:creator>
      <guid isPermaLink="false">22179@/two/discussions</guid>
      <description><![CDATA[<p>Hello!</p>

<p>I am making a "game box". I have a simple main menu where i want to access my 2 processing games from. I am using keys for this, so if(keyPressed) { if (key =='1') { stage = 1; if '2' is pressed then stage = 2, same with stage 3. Problem is that when i press '2', i move to stage 2, but when i press 1 or 3, nothing happens. 
I've tried printing the stage to the console and it writes 1 when i start it up, but when i go to either stage 2 or 3 prints once and then it stops.</p>

<p>Here's a bit (starts in stage 1 defined in setup): 
  if(keyPressed) {
      if (key == '1') {
        stage = 1;
  }
      if (key == '2') {
        stage = 2;
    }
          if (key == '3') {
        stage = 3;
    }
  }</p>

<p>if (stage == 2){
    background(255,0,0); //red                 Game1 code is supposed to go here
    println(stage);</p>

<p>if(keyPressed) {
      if (key == '1') {
        stage = 1;
  }
      if (key == '2') {
        stage = 2;
    }
          if (key == '3') {
        stage = 3;
    }
  }
  }
  if (stage == 3){
    background(0,255,0); //green             Game2 code is supposed to go here
    println(stage);</p>

<p>if(keyPressed) {
      if (key == '1') {
        stage = 1;
  }
      if (key == '2') {
        stage = 2;
    }
          if (key == '3') {
        stage = 3;
    }
    }
  }</p>
]]></description>
   </item>
   <item>
      <title>How to imput a main menu screen?</title>
      <link>https://forum.processing.org/two/discussion/22159/how-to-imput-a-main-menu-screen</link>
      <pubDate>Mon, 24 Apr 2017 02:28:11 +0000</pubDate>
      <dc:creator>ejlee</dc:creator>
      <guid isPermaLink="false">22159@/two/discussions</guid>
      <description><![CDATA[<p>For my computing class, I have to make a game that starts with a main menu screen, and when a key is pressed, moves into the game. While searching for how to do this, I found information about states, but I am not quite sure how to make this work for my code. This is what I have so far.</p>

<pre><code>int u=325; //y-value for soccer ball
int v=250; //x-value for soccer ball
int w=0;//x-value for goal
int x=150; //y-value for easy
int y=90; //y-value for medium
int z=35; //y-value for difficult
int savedTime; //save the time
int totalTime=35000;
PImage goal; //goal image
PImage background; //background image
PImage ball; //soccer ball image
int score = 0;
int state=0;
final int mainMenu=0;
final int game=1;


void settings(){
    size(500, 375);
}

void setup() {
  //Makes images appear
  goal=loadImage("Soccer Goal.png");
  background=loadImage("Field picture.jpg");
  ball=loadImage("Soccer ball.png");
  savedTime=millis();
}

void draw() {
  switch(state) {
  case mainMenu:
  background(255);
  if(key=='z'){
    break;
  }
  case game:
    break;
  }

  //background must be in start of draw, otherwise unwanted trail occurs behind pictures
  background(background);
  textSize(30);
  text("Score: " + score, 30, 30);

  image(ball, v, u, 40, 40);

  int passedTime=millis()-savedTime;

  if (passedTime&gt;totalTime) {
    fill(255);
    stroke(255, 10, 10);
    rect(-20, 80, 520, 295); //background box
    fill(255, 10, 10); //text color
    text("GAME OVER", 165, 200);
    text("PRESS X TO PLAY AGAIN",75,235);
    if(key=='x'){
      setup();
      draw();
      score=0;
    }
  }

  if (score &lt;= 8) {
    game1();
  }
  if (score &gt; 8 &amp;&amp; score &lt;= 16) {
    game2();
  }
  if (score &gt; 16) {
    game3();
  }
  if (passedTime&gt;totalTime) {
    fill(255);
    stroke(255, 10, 10);
    rect(0, 80, 500, 295); //background box
    fill(255, 10, 10); //text color
    text("GAME OVER", 165, 200);
    text("PRESS X TO PLAY AGAIN",75,235);
    if(key=='x'){
      setup();
      draw();
      score=0;
    }
  }
}

void keyPressed() {
  if (key == CODED) {
    if (keyCode == RIGHT) {
      v=v+3;
    }
    if (keyCode == LEFT) {
      v=v-3;
    }

    if (keyCode == UP) {
      u=height-285; //difficult goal ball shoot
      if (score &lt;= 8) {
      if(v &gt; w &amp;&amp; v &lt; w +250) {
        score++;
      }
    }
    if (score &gt; 8 &amp;&amp; score &lt;= 16) {
      if(v &gt; w &amp;&amp; v &lt; w +200) {
        score ++;
      }
    }
    if (score &gt; 16) {
      if(v &gt; w &amp;&amp; v &lt; w +150) {
        score ++;
      }
    }

    }
    if (keyCode == DOWN) {
      u=325;
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Why aren't my Game States working?</title>
      <link>https://forum.processing.org/two/discussion/22053/why-aren-t-my-game-states-working</link>
      <pubDate>Tue, 18 Apr 2017 04:05:11 +0000</pubDate>
      <dc:creator>ellelanger</dc:creator>
      <guid isPermaLink="false">22053@/two/discussions</guid>
      <description><![CDATA[<p>Hi All,</p>

<p>I'm working on an Assignment and for some reason when the program runs, it skips over my rules() Game State. Please help.</p>

<p>PImage nurse;
PImage stretcher; 
PImage bg;</p>

<p>PImage[] playerFrames = new PImage[14];</p>

<p>int INTRO = 0;
int RULES = 1;
int RUN_GAME = 2;
int GAME_OVER = 3;</p>

<p>int gameState = INTRO;</p>

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

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

<p>Player player;</p>

<p>void setup() {
  size(1081, 841);
  imageMode(CENTER);</p>

<p>//Player(int a, int b){
  //this.a = a;
  //this.b = b;
 //}</p>

<p>// load player animation
  for (int i=0; i &lt; playerFrames.length; i++) {
    String filename = "Player" + i + ".png";
    playerFrames[i] = loadImage(filename);
    println("Loading" + filename);
  }</p>

<p>player = new Player();
  bg = loadImage("bg2.jpg");
}</p>

<p>void draw() {
  // background (obg);
/*
 switch(gameState) {
  case INTRO:
    println("intro");
    break;</p>

<p>case RULES:
    println("rules");
    break;</p>

<p>case RUN_GAME:
   println("rungame");
   break;</p>

<p>case GAME_OVER:
    println("gaveover");
   break;
  }
*/</p>

<p>if (gameState == INTRO) intro();
  else if (gameState == RULES) rules();
  else if (gameState == RUN_GAME) runGame();
  else if (gameState == GAME_OVER) gameOver();</p>

<p>}</p>

<p>//////////////////////////////////////////////////////////////////////
// INTRO STATE
void intro() {
  background(bg); 
  textSize(50);
  textAlign(CENTER, BOTTOM);
  text("Welcome to!", width/2, height/2);
  text("Williams Nursing Home!", width/2, 450);
  text("Press Spacebar for Instructions!", width/2, 500);
}</p>

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

<p>void rules() {
  background(bg);
  text("Step 1: PRESS THE 'R' KEY TO ROLL THE DICE", width/2, 450);
  text("Step 2: USE THE RIGHT ARROW TO MOVE YOUR PLAYER HOWEVER MANY SPACES YOU ROLLED.", width/2, 500);
}</p>

<p>//////////////////////////////////////////////////////////////////////
// RUN GAME -- this is where the actual game happens
void runGame() {
  background(245, 241, 222); 
  for (int i=0; i &lt; 20; i+=2) {
    line(i<em>60, 0, i</em>60, height);  //lines for the board
    line(width, i<em>60, 0, i</em>60);</p>

<p>}</p>

<pre><code>player.move();
player.display();
</code></pre>

<p>if (keyPressed) {</p>

<pre><code>if (key == 'r') {
  for (int k = 0; k &lt; 1; k++) {
    r = int(random(0, 12));
    println(r);
  }
}
</code></pre>

<p>}</p>

<p>textSize(24);
  fill(255, 0, 0);
  text(r, 15, 30);</p>

<p>if (keyPressed &amp;&amp; (key == CODED)) {
    if (keyCode == RIGHT){
      q += 4;}
      else if (keyCode == LEFT){
        q += -4;<br />
    }
  player.display( , );
}
}</p>

<p>//////////////////////////////////////////////////////////////////////
// GAME OVER -- this is what happens we we are game over 
void gameOver() {
  background(bg);
  text("GAME OVER.", width/2, height/2);
}</p>

<p>void keyPressed() {
  if (gameState == INTRO || gameState == GAME_OVER) {
    gameState = RUN_GAME;
    //dice = 0; // remember to reset the score
  }
}</p>
]]></description>
   </item>
   <item>
      <title>Making a back button</title>
      <link>https://forum.processing.org/two/discussion/21800/making-a-back-button</link>
      <pubDate>Tue, 04 Apr 2017 13:37:19 +0000</pubDate>
      <dc:creator>taarons</dc:creator>
      <guid isPermaLink="false">21800@/two/discussions</guid>
      <description><![CDATA[<p>My code is a little long so I'm sorry about that but I've tried to condense it here and just explain the bare minimum of my problem. I have a state machine that incorporates both mousePressed and button functions. I want to create a back button starting in state 2, so I called it in one of my state 2 options,  void showQuestion2Palestinian(). The problem is, it only shows up if I click the Palestinian button first. Additionally, I had to put a set of conditions on the button more specific than state--; because I don't always just want it to go back to the last state. I've given it direct assignments, but a couple of them glitch and don't go back to the right state. I don't know if this is a flaw in my processing application or in the code... Please help!</p>

<pre><code>import controlP5.*;
ControlP5 cp5session1;
ControlP5 cp5session2;
ControlP5 cp5session3;
ControlP5 cp5;

int state;

void setup() { 
  size(800, 600);
  background(255);  
}

void mousePressed() {

  if(state == 3) {
    if (200&lt;mouseX &amp;&amp; mouseX&lt;400 &amp;&amp; 100&lt;mouseY &amp;&amp; mouseY&lt;400){
    state = 4;  
    }
  }

/*  if(state == 4) {
    if (200&lt;mouseX &amp;&amp; mouseX&lt;400 &amp;&amp; 100&lt;mouseY &amp;&amp; mouseY&lt;400){
    state = 5;  
    }
  } */

  if(state == 6) {
    if (200&lt;mouseX &amp;&amp; mouseX&lt;400 &amp;&amp; 100&lt;mouseY &amp;&amp; mouseY&lt;400){
    state = 7;  
    }
  }
   if(state == 8) {
    if (0&lt;mouseX &amp;&amp; mouseX&lt;800 &amp;&amp; 0&lt;mouseY &amp;&amp; mouseY&lt;600){
    state = 9;  
    }
  }
  if(state == 10) {
    //should be before
    if (200&lt;mouseX &amp;&amp; mouseX&lt;400 &amp;&amp; 100&lt;mouseY &amp;&amp; mouseY&lt;400){
    state = 12;  
    }
  }

  /*if(state == 11) {
    if (200&lt;mouseX &amp;&amp; mouseX&lt;400 &amp;&amp; 100&lt;mouseY &amp;&amp; mouseY&lt;400){
    state = 12;  
    }
  } */

  if(state == 13) {
    if (200&lt;mouseX &amp;&amp; mouseX&lt;400 &amp;&amp; 100&lt;mouseY &amp;&amp; mouseY&lt;400){
    state = 14;  
    }
  }
   if(state == 15) {
    if (0&lt;mouseX &amp;&amp; mouseX&lt;800 &amp;&amp; 0&lt;mouseY &amp;&amp; mouseY&lt;600){
    state = 16;  
    }
  } 
}


public void Next (int theValue) {
  println("a button event from Next: "+theValue);
  showQuestion1();
  state++;
}

void showQuestion1() {
  background(255);
  video.stop();
  cp5.hide();

  cp5session1 = new ControlP5(this); 

  cp5session1.addButton("Palestinian")
    .setPosition(width/2 - 200, 285)
    .updateSize()
    .setSize(100, 50)
    ;

  cp5session1.addButton("Israeli")
    .setPosition(width/2 + 100, 285)
    .updateSize()
    .setSize(100, 50)
    ;

}

public void controlEvent(ControlEvent theEvent) {
  println(theEvent.getController().getName());
}

public void Palestinian (int theValue) {
  println("a button event from Palestinian: "+theValue);
  showQuestion2Palestinian();
  state = 2;
}

public void Israeli (int theValue) {
  println("a button event from Israeli: "+theValue);
  showQuestion2Israeli();
  state = 2;

}


void showQuestion2Palestinian() {
  background(0);
  cp5session1.hide();

  //Date buttons created 
  cp5session2 = new ControlP5(this);
  cp5session2.addButton("Palestine1945")
    .setPosition(width/3 - 100, 285)
    .updateSize()
    .setSize(100, 50)
    ;

  cp5session2.addButton("Palestine1967")
    .setPosition(width/3 + 100, 285)
    .updateSize()
    .setSize(100, 50)
    ;

  cp5session2.addButton("Palestine2017")
    .setPosition(width/3 + 300, 285)
    .updateSize()
    .setSize(100, 50)
    ;

cp5session3 = new ControlP5(this); 

  cp5session3.addButton("back")
    .setPosition(600, 500)
    .updateSize()
    .setSize(100, 50)
    ;
}


public void back (int theValue) {
  println("a button event from Palestine 1945: "+theValue);

  if (state == 2) {
    state--;
    cp5session1.show();
    cp5session2.hide();
  }
   if (state == 3) {
    state = 2;
  }
   if (state == 4) {
    state = 3;
  }
   if (state == 5) {
    state = 4;
  }
   if (state == 6) {
    state = 2;
  }
   if (state == 7) {
    state = 6;
  }
   if (state == 8) {
    state = 2;
  }

   if (state == 9) {
    state = 8;
  }
   if (state == 10) {
    state = 2;
  }

   if (state == 11) {
    state = 10;
  }

   if (state == 12) {
    state = 11;
  }

   if (state == 13) {
    state = 2;
  }
   if (state == 14) {
    state = 13;
  }

   if (state == 15) {
    state = 2;
  }

   if (state == 16) {
    state = 15;
  }
}

public void Palestine1945 (int theValue) {
  println("a button event from Palestine 1945: "+theValue);
  state = 3;
  cp5session2.hide();
  cp5session1.hide();

}

public void Palestine1967 (int theValue) {
  println("a button event from Palestine1967: "+theValue);
  state = 6;
  cp5session2.hide();
  cp5session1.hide();

}


public void Palestine2017 (int theValue) {
  println("a button event from Palestine2017: "+theValue);
  state = 8; 
  cp5session2.hide();
  cp5session1.hide();

}

void showQuestion2Israeli() {
  background(255);
  cp5session1.hide();
  //cp5session3.show(); &lt;== when I run this, the buttons don't show up at all 

  cp5session2 = new ControlP5(this);

  cp5session2.addButton("Israel1945")
    .setPosition(width/3 - 100, 285)
    .updateSize()
    .setSize(100, 50)
    ;

  cp5session2.addButton("Israel1967")
    .setPosition(width/3 + 100, 285)
    .updateSize()
    .setSize(100, 50)
    ;

  cp5session2.addButton("Israel2017")
    .setPosition(width/3 + 300, 285)
    .updateSize()
    .setSize(100, 50)
    ;
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How would I be able to make text show up when the player goes on the ellipse in state 0?</title>
      <link>https://forum.processing.org/two/discussion/21441/how-would-i-be-able-to-make-text-show-up-when-the-player-goes-on-the-ellipse-in-state-0</link>
      <pubDate>Thu, 16 Mar 2017 21:54:39 +0000</pubDate>
      <dc:creator>Nathan101</dc:creator>
      <guid isPermaLink="false">21441@/two/discussions</guid>
      <description><![CDATA[<pre><code>float linkX;
float linkY;
int state = 0;
PImage linkUp;
PImage linkDown;
PImage linkLeft;
PImage linkRight;
PImage linkImg;
PImage map;
PImage tile;

void setup () {
  size(1024, 704);
  linkUp = loadImage("link_Up.png");
  linkDown = loadImage("link_Down_Shield.png");
  linkImg = loadImage("link_Down_Shield.png");
  linkLeft = loadImage("link_Left_Shield.png");
  linkRight = loadImage("link_Right_Shield.png");
  linkX = width/2;
  linkY = height/2;

  map = loadImage("map.png");
  tile = map.get(1792, 1232, 256, 176);
  tile.resize(1024, 704);
}


void draw () {
  background(tile);

  drawLink();
  checkHotSpots();

  fill(255);
  text("mouseX = " + mouseX, 15, 15); //output mouse values
  text("mouseY = " + mouseY, 15, 30);
}

void checkHotSpots() {

  if (state == 0) {       //Home Tile
    fill(184, 134, 11);
    ellipse(285, 95, 50, 65);
  }
  if (dist(linkX, linkY, 10, 350) &lt; 90) {        // Left tile
    state = 1;
    linkX = width - 80;
    tile = map.get(1536, 1232, 256, 176);
    tile.resize(1024, 704);
  } else if (dist(linkX, linkY, 510, 0) &lt; 90) {     //Top tile
    state = 2;
    linkY = height - 80;
    linkX = 500;
    tile = map.get(1792, 1056, 256, 176);
    tile.resize(1024, 704);
  } else if (dist(linkX, linkY, 975, 350) &lt; 90) {    //Right tile
    state = 3;
    linkX = 80;
    tile = map.get(2048, 1232, 256, 176);
    tile.resize(1024, 704);
  }
} else if (state == 1) {         
  fill(184, 134, 11);
  rect(40, 130, 20, 445);
  if (dist(linkX, linkY, 825, 40) &lt; 90) {
    state = 4;
    linkY = 624;
    tile = map.get(1536, 1056, 256, 176);
    tile.resize(1024, 704);
  }
} else if (state == 3) {
  fill(184, 134, 11);
  rect(930, 6, 20, 570);
  if (linkY &lt; 2) {
    state = 5;
    linkY = 685;
    tile = map.get(2048, 1056, 256, 176);
    tile.resize(1024, 704);
  }
} else if (state == 5) {
  fill(184, 134, 11);
  rect(930, 6, 20, 570);
  if (linkX &lt; 2) {
    linkX = 955;
    state = 6;
    tile = map.get(1792, 1056, 256, 176);
    tile.resize(1024, 704);
  }
}
}

void keyPressed() {

  if ( key == CODED) {
    if ( keyCode == UP) {
      linkImg = linkUp;
      linkY -= 15;
    }
    if ( keyCode == DOWN) {
      linkImg = linkDown;
      linkY += 15;
    }
    if ( keyCode == LEFT) {
      linkImg = linkLeft;
      linkX -= 15;
    }
    if ( keyCode == RIGHT) {
      linkImg = linkRight;
      linkX += 15;
    }
  }
}

void drawLink() {

  pushMatrix();
  translate(linkX, linkY);
  scale(2.7);
  image(linkImg, 0, 0);
  popMatrix();
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>using open()</title>
      <link>https://forum.processing.org/two/discussion/16142/using-open</link>
      <pubDate>Wed, 20 Apr 2016 20:51:01 +0000</pubDate>
      <dc:creator>jeffmarc</dc:creator>
      <guid isPermaLink="false">16142@/two/discussions</guid>
      <description><![CDATA[<p>I start an external .exe with open()
but starts an external flat bed scanner scan that takes about 20 seconds</p>

<p>The program continues and before the scan finishes and puts a file in the directory
I use to put up image, it gets to the load file statement and can't find it , it's not there yet.</p>

<p>I am trying to use this code to test the file exists before letting the program continue
but it complains "unexpected token boolean"</p>

<p>boolean fileExists(String "test.png")</p>

<p>File file = new File("test.png");</p>

<p>while(!file.exists());</p>

<p>Am I on the right tract?</p>
]]></description>
   </item>
   <item>
      <title>Changing screen with mouse click</title>
      <link>https://forum.processing.org/two/discussion/20777/changing-screen-with-mouse-click</link>
      <pubDate>Mon, 13 Feb 2017 17:54:43 +0000</pubDate>
      <dc:creator>IdemoniVezulu</dc:creator>
      <guid isPermaLink="false">20777@/two/discussions</guid>
      <description><![CDATA[<p>So, I'm pretty new to processing and I'm trying to make a simple game.
The program opens with the title and "Start", "Help", and "Exit" buttons.
How do I clear the screen, change it's contents when I use the mouse to click on each button.
I know the coordinates of each button and I tried using that, but I don't understand how to use mousePressed(), and mouseClicked().
I just need to know how to use those two functions, making up the other two screens is something I have figured out. It's only going to that screen that I'm having problems with.</p>
]]></description>
   </item>
   <item>
      <title>Explosion doesn't happen after targethit but after shoot button is pressed after targethit</title>
      <link>https://forum.processing.org/two/discussion/20553/explosion-doesn-t-happen-after-targethit-but-after-shoot-button-is-pressed-after-targethit</link>
      <pubDate>Mon, 30 Jan 2017 15:23:48 +0000</pubDate>
      <dc:creator>MDMA</dc:creator>
      <guid isPermaLink="false">20553@/two/discussions</guid>
      <description><![CDATA[<p>The problem here is that no explosion is happening when target is hit.</p>

<p>Here's what happens, I "shoot" with LMB, bullet shoots, hits target and there should be an explosion, but no explosion happens. The explosion only happens if I press the "shoot" (LMB) button again.</p>

<p>What can I do to make the explosion explode as it should?</p>

<p>Second half of the code</p>

<p>edit: my code gets extremely bugged if i post it as a code(wtf) so ill try as a quote</p>
]]></description>
   </item>
   </channel>
</rss>