<?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 checkaddrpattern() - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=checkaddrpattern%28%29</link>
      <pubDate>Sun, 08 Aug 2021 20:32:33 +0000</pubDate>
         <description>Tagged with checkaddrpattern() - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/taggedcheckaddrpattern%28%29/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>Pitch, Roll, Yaw using rotateX/Y/Z query</title>
      <link>https://forum.processing.org/two/discussion/27557/pitch-roll-yaw-using-rotatex-y-z-query</link>
      <pubDate>Fri, 30 Mar 2018 21:33:08 +0000</pubDate>
      <dc:creator>Neowso</dc:creator>
      <guid isPermaLink="false">27557@/two/discussions</guid>
      <description><![CDATA[<p>I am trying to represent the orientation of my phone being held upright. I'm using a simple rectangle for starters. I am sending messages over OSC. Each of my 3 values; pitch, roll and yaw (Azimuth) goes from -180degrees to +180degrees.</p>

<p>I am going by the example in the picture below my code, where X is pitch and Y is roll:</p>

<p>When I use just two values, (eg just pitch and roll) the orientation seems to be represented normally. But when I throw the third into the mix, it gets a little wild.</p>

<p>I don't have another device right now to check if it's the phone sensors that are faulty. Looking at the rotateX(and Y and Z) examples, this should work as is. I guess there's something a bit deeper I'm missing?</p>

<p>Thanks</p>

<pre><code>import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
float ZyawValue, XpitchValue, YrollValue;


void setup() {
  size(360, 360, P3D);
  lights();
  noStroke();
  colorMode(RGB, 256); 

  oscP5 = new OscP5(this,34567);
  myRemoteLocation = new NetAddress("192.168.1.7",34567);
}


void draw() {
  background(100);
  rectMode(CENTER);
  fill(51);
  stroke(255);

  pushMatrix();
  translate(width/2, height/2, 0);

    rotateX(radians(XpitchValue));
    rotateY(radians(-YrollValue));
    rotateZ(radians(ZyawValue));     // **Issues**

  rect(0, 0, 50, 100);
  popMatrix();

  textSize(24);
  String gyrStr1 = "X=Roll: " + (int) YrollValue; 
  String gyrStr2 = "Y=Pitch: " + (int) XpitchValue; 
  String gyrStr3 = "Z=Yaw: " + (int) ZyawValue; 
  fill(249, 250, 50);
  text(gyrStr1, (int) (width/6.0) - 40, 50); 
  text(gyrStr2, (int) (width/6.0) - 40, 100); 
  text(gyrStr3, (int) (width/6.0) - 40, 150);   
}



void oscEvent(OscMessage theOscMessage) {

  if(theOscMessage.checkAddrPattern("/orientation/azimuth")==true) { 
    if(theOscMessage.checkTypetag("f")) {
      ZyawValue = theOscMessage.get(0).floatValue();  
      return;
    }  
  }

  if(theOscMessage.checkAddrPattern("/orientation/pitch")==true) { 
    if(theOscMessage.checkTypetag("f")) 
    {
      XpitchValue = theOscMessage.get(0).floatValue();  
      return;
    }  
  } 

  if(theOscMessage.checkAddrPattern("/orientation/roll")==true) { 
    if(theOscMessage.checkTypetag("f")) {
      YrollValue = theOscMessage.get(0).floatValue();
      return;
    }  
  }   
  println("Azimuth: "+ZyawValue+", Pitch: "+XpitchValue+", Roll: "+YrollValue);
}
</code></pre>

<p><img src="https://forum.processing.org/two/uploads/imageupload/717/JGTPTPO6MT7I.png" alt="Screen Shot 2018-03-30 at 21.45.50" title="Screen Shot 2018-03-30 at 21.45.50" /></p>
]]></description>
   </item>
   <item>
      <title>Problems with Buffer (EyeTracker)</title>
      <link>https://forum.processing.org/two/discussion/26453/problems-with-buffer-eyetracker</link>
      <pubDate>Tue, 20 Feb 2018 14:54:56 +0000</pubDate>
      <dc:creator>eyetrackeruntref</dc:creator>
      <guid isPermaLink="false">26453@/two/discussions</guid>
      <description><![CDATA[<p>I'm receiving data from Matlab (1000fps) of a subject looking a picture using EyeTracker Hardware. [both in different computers].</p>

<p>Connection is OK, UDP is fine, OSC is working thanks to oscP5.</p>

<p>With the data, I draw circles ( that are designed by X and Y axis from EyeTracker device ) in a canvas.</p>

<p>Now the problem is that I don't know how to build a proper buffer to receive all this massive information, and then, after few milliseconds erase it. Because I want to see in my canvas, the eyes moving on real time drawing circles, but i just want to see 1 circle, not all of them, eventhough i don't need to save all this information.</p>

<p>If you don't understand something, please ask me, and I'll try to explain you better:</p>

<p>I have this code, feel free to ask and say whatever you want :</p>

<pre><code>/**
 * oscP5parsing by andreas schlegel
 * example shows how to parse incoming osc messages "by hand".
 * it is recommended to take a look at oscP5plug for an
 * alternative and more convenient way to parse messages.
 * oscP5 website at <a href="http://www.sojamo.de/oscP5" target="_blank" rel="nofollow">http://www.sojamo.de/oscP5</a>
 */
import java.util.*;

import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocation;

ArrayList &lt;Posiciones&gt; buffer  = new ArrayList&lt;Posiciones&gt;();

//Iterator &lt;Posiciones&gt; itr = new ArrayList&lt;Posiciones&gt;();


long tiempoX = 1000;
long tiempoActual = millis(); 

float x1, y1, x2, y2;
float diamt = 20;

float ancho = 400;
float alto = 400;

void setup() {
  size(400, 400); 
  smooth();
  noStroke();
  /* start oscP5, listening for incoming messages at port 8002 */
  oscP5 = new OscP5(this, 8002); //Pasar este puerto al experimento de MatLab

  /* myRemoteLocation is a NetAddress. a NetAddress takes 2 parameters,
   * an ip address and a port number. myRemoteLocation is used as parameter in
   * oscP5.send() when sending osc packets to another computer, device, 
   * application. usage see below. for testing purposes the listening port
   * and the port of the remote location address are the same, hence you will
   * send messages back to this sketch.
   */
  //myRemoteLocation = new NetAddress("127.0.0.1", 4002);
}

void draw() {

  escupirData();
  dibujarCirculos();
}

void oscEvent(OscMessage theOscMessage) {
  /* check if theOscMessage has the address pattern we are looking for. */

  if (theOscMessage.checkAddrPattern("/test")==true) {
    /* check if the typetag is the right one. */
    //println(theOscMessage);
    if (theOscMessage.checkTypetag("s")) {
      /* parse theOscMessage and extract the values from the osc message arguments. */
      String stringValue = theOscMessage.get(0).stringValue();
      println(" values: " + stringValue);

      int[] datos = int(split(stringValue, "-")); //divide los datos y los guarda temporalmente //  divide data and save temporarily
      Posiciones crearPosiciones = new Posiciones(); //creo un objeto para guardar la data // creating an object to save the data
      crearPosiciones.x1 = datos[0]; //guardo la data // saving data
      crearPosiciones.y1 = datos[1];
      crearPosiciones.x2 = datos[2];
      crearPosiciones.y2 = datos[3];
      buffer.add(crearPosiciones); //agrego un elemento al arrayList/buffer // adding an element to arrayList/buffer

      return;
    }
  }
}

void escupirData() {

  long currentMillis = millis();

  if (millis() - tiempoActual &gt;= tiempoX ) {
    //Pixel newPixel = pixeles.get(i); 

    if (buffer.size() &gt; 0) { //fijarse si el buffer tiene elementos // look if the buffer has elements
      Posiciones posicionActual = buffer.get(0); //creo un objeto para guardar el primer objeto del buffer // creating an object to save the first object of the buffer

      x1 = posicionActual.x1; //guardo la data para usar // saving the data to use
      y1 = posicionActual.y1;
      x2 = posicionActual.x2;
      y2 = posicionActual.y2;


      posicionActual.borrar = true;//si ya lo dibujé levanto el flag para borrarlo // if it is drawn, clear

      println(" borrado: " + posicionActual.borrar);

      tiempoActual = millis();
    }
  }

  //crear un iterator, que si ya dibujó la posición lo borre por el flag // creating an iterator

  //creo un iterator para podes remover lugares del ArrayList // creating an iterator to remove spots of ArrayList
  Iterator itr = buffer.iterator();
  // itr = buffer.iterator();
  while (itr.hasNext ()) {
    Posiciones posicionActual = (Posiciones)itr.next();
    if (posicionActual.borrar) {
      itr.remove(); //remuevo la frase que ya no se ve // removing the phrase that is not visible
      println("borré 1, quedan " + buffer.size() + " posiciones");
    }
  }
}

void dibujarCirculos() {

  x1 = map(x1, 0, ancho, 0, width); 
  y1 = map(y1, 0, ancho, 0, height);
  x2 = map(x2, 0, ancho, 0, width); 
  y2 = map(y2, 0, ancho, 0, height); 

  fill(255, 0, 0);
  ellipse(x1, y1, diamt, diamt);
  fill(0, 0, 255);
  ellipse(x2, y2, diamt, diamt);
}


AND THIS CLASS :

class Posiciones {
  int x1, y1, x2, y2;
  boolean borrar = false;


  Posiciones() {
  }

  void vacio() {
  }

}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How could I use a function from different class?</title>
      <link>https://forum.processing.org/two/discussion/25814/how-could-i-use-a-function-from-different-class</link>
      <pubDate>Thu, 04 Jan 2018 13:53:11 +0000</pubDate>
      <dc:creator>hsawa</dc:creator>
      <guid isPermaLink="false">25814@/two/discussions</guid>
      <description><![CDATA[<p>Hello, I am quite new to Prcoessing and I am stuck on using functions from a class to another function. I basically want to use 'void update' in 'void oscEvent(OscMessage theOscMessage' to send update function to OSC. 
Hope my problem makes sense :(</p>

<p>here is the code:</p>

<pre><code>void draw() {
  background(0);
  for (Particle p : particles) {
    p.update();
  }
}

class Particle {

  PVector position, velocity;

  void update() {
    PVector mouse = new PVector(map(mouseX, 0, width, -width / 2, width / 2), map(mouseY, 0, height, -height / 2, height / 2), 0);
    PVector acc = PVector.sub(mouse, position);


    acc.limit(FULL_ACC);
    velocity.add(acc);
    velocity.limit(FULL_VEL);
    position.add(velocity);
  }

  void oscEvent(OscMessage theOscMessage) {
    if (theOscMessage.checkAddrPattern("/output_1")==true) {
      update(); //problem is here, what is the proper way in order for the OSC to pick up this info? 
      println("mouseMoved");
    } else if (theOscMessage.checkAddrPattern("/output_2")==true) {
      update();
      println("mouseMoved");
    } else if (theOscMessage.checkAddrPattern("/output_3") == true) {
      update();
      println("mouseMoved");
    } else {
      println("Unknown OSC message received");
    }
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>How can I put microphone value into an array and also filter microphone value</title>
      <link>https://forum.processing.org/two/discussion/25222/how-can-i-put-microphone-value-into-an-array-and-also-filter-microphone-value</link>
      <pubDate>Mon, 27 Nov 2017 04:51:08 +0000</pubDate>
      <dc:creator>nancyjou</dc:creator>
      <guid isPermaLink="false">25222@/two/discussions</guid>
      <description><![CDATA[<p>I want to do a project which is about  when saying something through microphone, and then can draw something (on Processing).</p>

<p>l watch Daniel Shiffman's video "17.9: Sound Visualization: Graphing Amplitude - p5.js",
<a rel="nofollow" href="https://www.youtube.com/watch?v=jEwAMgcCgOA&amp;t=370s">https://youtube.com/watch?v=jEwAMgcCgOA&amp;t=370s</a>,
but what I use is processing and pure data,
I have a question about  how to put those microphone value into an array in Processing, like the tutorial  in the video,
(the way of receive sound from microphone I use is Pure data, and I'm successfully connect pd and Processing), 
but I just don't know how to put those value into an array in processing,
and I guess the value also need to greater than a certain value 
because microphone will also receive value when is not saying.Thank you for your help!﻿</p>

<p>My Pure data and Processing sketch is here
<a rel="nofollow" href="https://github.com/nancyjou/Sound-Visualization">https://github.com/nancyjou/Sound-Visualization</a></p>

<p>and here is only my Processing sketch.</p>

<pre><code>float global1;
float global2;
float adc;
float fiddle;
float colorY;
float alphaX;

import netP5.*;
import oscP5.*;


OscP5 oscP5;
NetAddress myRemoteLocation;

void setup() {
  size(800, 800);
  background(255);
  frameRate(25);
  colorMode(HSB, 360, 100, 100);
  noStroke();
  /* start oscP5, listening for incoming messages at port 12000 */
  oscP5 = new OscP5(this, 12001);

  myRemoteLocation = new NetAddress("127.0.0.1", 12000);
}

void draw() {

  fiddle = global2;
  colorY= map(global2, 25, 150, 0, 360);
  alphaX= map(global1, 40, 250, 20, 255);
  fill(colorY, 100, 100);
  fill(colorY, 100, fiddle+50, alphaX);
  for (int y=200; y&lt;(height/4)+1; y+=10) {
    ellipse(width/2, random(0, 400), global1, global1);
    println(y);
  }
  adc = global1 + 10;
}


void mousePressed() {
  OscMessage myMessage = new OscMessage("/first");


  myMessage.add(123);
  myMessage.add(12.34);
  myMessage.add("some text");

  oscP5.send(myMessage, myRemoteLocation);
}  

void oscEvent(OscMessage theOscMessage) {

  if (theOscMessage.checkAddrPattern("/first")==true) {



    float firstValue = theOscMessage.get(0).floatValue();
    global1 = firstValue;
  }

  if (theOscMessage.checkAddrPattern("/second")==true) {



    float secondValue = theOscMessage.get(0).floatValue();
    global2 = secondValue;
  }
  println("### received an osc message. with address pattern "+theOscMessage.addrPattern());
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>My Little LAN Game</title>
      <link>https://forum.processing.org/two/discussion/25144/my-little-lan-game</link>
      <pubDate>Wed, 22 Nov 2017 13:44:00 +0000</pubDate>
      <dc:creator>NewStudent</dc:creator>
      <guid isPermaLink="false">25144@/two/discussions</guid>
      <description><![CDATA[<p>Hey guys recently i created this little game but i am not able to test it completely because i do not have a second computer on the same network i was hoping you guys could test it here is the code:</p>

<p>RPG_Game.pde:</p>

<pre><code>import oscP5.*;
import netP5.*;
import processing.net.*;
OscP5 oscP5;
NetAddress myRemoteLocation;
Player player;
Bullet bullet;
Bullet playerBullet;
Player player2;
String playerIP = "";
String myIP;
boolean setup = true;
boolean load = false;
float loadV;
boolean connected = false;
float previous;
float stepPrevious;
boolean error = false;
int x;
int y;
boolean changeStep = false;
int step = 1;
int stepValue = 5;
float previousWay = UP;
boolean walking = false;
int range = 800;
boolean fireable = false;

void setup()
{
  bullet = new Bullet(color(255, 0, 0));
  playerBullet = new Bullet(color(0, 255, 0));
  background(255, 102, 0);
  myIP = Server.ip();
  fullScreen();
  oscP5 = new OscP5(this, 23492);
  textSize(48);
  textAlign(CENTER);
  player = new Player();
  player2 = new Player();
  x = width / 2;
  y = height / 2;
}

void draw()
{
  checkTime();
  background(255, 102, 0);
  set_up();
  load();
  player.show();
  player2.show();
  bullet.show();
  playerBullet.show();
  checkBulletPlayer();
  checkBulletOtherPlayer();
  showScore();
  if (walking) moveCharacter();
  if (bullet.show) bullet.move();
  if (playerBullet.show) playerBullet.move();
  if (!bullet.show) bullet.setDir(previousWay);
  if (!playerBullet.show) playerBullet.setDir(previousWay);
}

void keyPressed()
{
  keySetup();
  if (keyCode == UP || keyCode == DOWN || keyCode == LEFT || keyCode == RIGHT) walking = true;
  if (key == 'f' &amp;&amp; bullet.show == false &amp;&amp; !setup &amp;&amp; !load)
  {
    bullet.fire();
    OscMessage myMessage = new OscMessage("playerBullet");
    myMessage.add(bullet.bx);
    myMessage.add(bullet.by);
    myMessage.add(bullet.bdir);
    oscP5.send(myMessage, myRemoteLocation);
  }
  if (key == 'q' &amp;&amp; !setup &amp;&amp; !load) range = 300;
  if (key == 'w' &amp;&amp; !setup &amp;&amp; !load) range = 500;
  if (key == 'e' &amp;&amp; !setup &amp;&amp; !load) range = 800;
}

void keyReleased()
{
  if (keyCode == UP || keyCode == DOWN || keyCode == LEFT || keyCode == RIGHT) walking = false;
}

public void oscEvent(OscMessage theOscMessage)
{
  if (theOscMessage.checkAddrPattern("playerBullet"))
  {
    playerBullet.bx = theOscMessage.get(0).floatValue();
    playerBullet.by = theOscMessage.get(1).floatValue();
    playerBullet.setDir(theOscMessage.get(2).floatValue());
    playerBullet.fire();
  }
  if (theOscMessage.checkAddrPattern("PlayerCoor"))
  {
    player2.move(theOscMessage.get(0).intValue(), theOscMessage.get(1).intValue(), theOscMessage.get(2).intValue(), theOscMessage.get(3).intValue());
  }
  if (theOscMessage.checkAddrPattern("ConnectReq"))
  {
    myRemoteLocation = new NetAddress(theOscMessage.get(0).stringValue(), 23492);
    OscMessage myMessage = new OscMessage("Connect");
    myMessage.add("yes");
    oscP5.send(myMessage, myRemoteLocation);
  }
  if (theOscMessage.checkAddrPattern("Connect")) connected = true;
}
</code></pre>

<p>Bullet.pde:</p>

<pre><code>class Bullet
{
  float bx;
  float by;
  float bdir;
  boolean show = false;
  float previousX;
  float previousY;
  color clr;

  Bullet(color a)
  {
    bdir = UP;
    clr = a;
  }

  void move()
  {
    if (bdir == UP) by -= 55;
    if (bdir == LEFT) bx -= 55;
    if (bdir == DOWN) by += 55;
    if (bdir == RIGHT) bx += 55;
    if(dist(previousX, previousY, bx, by) &gt; range) show = false;
  }

  void show()
  {
    if (show)
    {
      noStroke();
      fill(clr);
      ellipse(bx + 24, by + 24, 10, 10);
      stroke(0);
      fill(255);
    }
    if(!show) bx = by = -1000;
  }

  void fire()
  {
    bx = player.x;
    by = player.y;
    previousX = bx;
    previousY = by;
    show = true;
  }

  void setDir(float _dir)
  {
    bdir = _dir;
  }
}
</code></pre>

<p>Draw.pde:</p>

<pre><code>void set_up()
{
  if (setup)
  {
    text("Enter Other Players IP:", width / 2, height / 3);
    text("Your IP: " + myIP, width / 2, height / 7);
    fill(0, 188, 255);
    text(playerIP, width / 2, height / 2 + 15);
    fill(255);
    if (error) text("Failed to Connect or Other Machine did not Respond", width / 2, height / 2 + 200);
  }
}

void load()
{
  if (load)
  {
    if (connected) loadV += 5;
    fill(255);
    text("Connecting to: " + playerIP, width / 2, height /  7);
    rectMode(CENTER);
    rect(width / 2, height / 2, 500, 100);
    fill(255, 0, 0);
    rectMode(CORNER);
    rect(width / 2 - 250, height / 2 - 50, loadV, 100);
    if (millis() - previous &gt; 5000 &amp;&amp; loadV &lt; 500)
    {
      loadV = 0;
      setup = true;
      load = false;
      connected = false;
      error = true;
    }
    if (loadV == 500) load = false;
  }
}

void keySetup()
{
  if (setup &amp;&amp; keyCode != CONTROL &amp;&amp; keyCode != SHIFT &amp;&amp; keyCode != 524)
  {
    if (keyCode == BACKSPACE)
    {
      if (playerIP.length() &gt; 0) playerIP = playerIP.substring(0, playerIP.length() - 1);
    } else
    {
      if (keyCode == ENTER)
      {
        error = false;
        if (!playerIP.equals(""))
        {
          myRemoteLocation = new NetAddress(playerIP, 23492);
          setup = false;
          load = true;
          OscMessage myMessage = new OscMessage("ConnectReq");
          myMessage.add(myIP);
          oscP5.send(myMessage, myRemoteLocation);
          previous = millis();
        }
      } else
      {
        playerIP += key;
      }
    }
  }
  if (keyCode == TAB)
  {
    loadV = 0;
    setup = true;
    load = false;
    connected = false;
  }
}

void moveCharacter()
{
  if (!setup &amp;&amp; !load)
  {
    if (keyCode == UP)
    {
      previousWay = UP;
      if (y &gt; 0) y -= stepValue;
      if (changeStep)
      {
        if (step == 1) step = 2;
        else if (step == 2) step = 1;
        changeStep = false;
      }
      player.move(x, y, UP, step);
      OscMessage myMessage = new OscMessage("PlayerCoor");
      myMessage.add(x);
      myMessage.add(y);
      myMessage.add(UP);
      myMessage.add(step);
      oscP5.send(myMessage, myRemoteLocation);
    }
    if (keyCode == DOWN)
    {
      previousWay = DOWN;
      if (y + 65 &lt; height) y += stepValue;
      if (changeStep)
      {
        if (step == 1) step = 2;
        else if (step == 2) step = 1;
        changeStep = false;
      }
      player.move(x, y, DOWN, step);
      OscMessage myMessage = new OscMessage("PlayerCoor");
      myMessage.add(x);
      myMessage.add(y);
      myMessage.add(DOWN);
      myMessage.add(step);
      oscP5.send(myMessage, myRemoteLocation);
    }
    if (keyCode == LEFT)
    {
      previousWay = LEFT;
      if (x &gt; 0) x -= stepValue;
      if (changeStep)
      {
        if (step == 1) step = 2;
        else if (step == 2) step = 1;
        changeStep = false;
      }
      player.move(x, y, LEFT, step);
      OscMessage myMessage = new OscMessage("PlayerCoor");
      myMessage.add(x);
      myMessage.add(y);
      myMessage.add(LEFT);
      myMessage.add(step);
      oscP5.send(myMessage, myRemoteLocation);
    }
    if (keyCode == RIGHT)
    {
      previousWay = RIGHT;
      if (x + 65 &lt; width) x += stepValue;
      if (changeStep)
      {
        if (step == 1) step = 2;
        else if (step == 2) step = 1;
        changeStep = false;
      }
      player.move(x, y, RIGHT, step);
      OscMessage myMessage = new OscMessage("PlayerCoor");
      myMessage.add(x);
      myMessage.add(y);
      myMessage.add(RIGHT);
      myMessage.add(step);
      oscP5.send(myMessage, myRemoteLocation);
    }
  }
}

void checkTime()
{
  if (millis() - stepPrevious &gt;= 200)
  {
    stepPrevious = millis();
    changeStep = true;
  }
}

void checkBulletPlayer()
{
  if (playerBullet.bx &gt; x - 15 &amp;&amp; playerBullet.bx &lt; x + 32 &amp;&amp; playerBullet.by &gt; y - 15 &amp;&amp; playerBullet.by &lt; y + 32)
  {
    player.health -= 20;
    if (player.health &lt;= 0)
    {
      player2.score++;
      player.health = 100;
      player.x = width / 2;
      player.y = height / 2;
      x = width / 2;
      y = height / 2;
    }
  }
}

void checkBulletOtherPlayer()
{
  if (bullet.bx &gt; player2.x - 15 &amp;&amp; bullet.bx &lt; player2.x + 32 &amp;&amp; bullet.by &gt; player2.y - 15 &amp;&amp; bullet.by &lt; player2.y + 32)
  {
    player2.health -= 20;
    if (player2.health &lt;= 0)
    {
      player.score++;
      player2.health = 100;
      player2.x = width / 2;
      player2.y = height / 2;
    }
  }
}

void showScore()
{
  if (!setup &amp;&amp; !load)
  {
    fill(255);
    text((int) player.score, width / 10, height / 10);
    text((int) player2.score, width - 150, height / 10);
  }
}
</code></pre>

<p>Player.pde:</p>

<pre><code>class Player
{
  PImage player = loadImage("character.png");
  PImage sprite = player.get(0, 97, 32, 32);;
  float x;
  float y;
  float dir;
  int foot = 1;
  float health = 100;
  float score = 0;

  Player()
  {
    x = width / 2;
    y = height / 2;
    dir = UP;
  }

  void move(float _x, float _y, float _dir, int _foot)
  {
    x = _x;
    y = _y;
    dir = _dir;
    foot = _foot;
    if(dir == UP &amp;&amp; foot == 1) sprite = player.get(0, 97, 32, 32);
    if(dir == UP  &amp;&amp; foot == 2) sprite = player.get(66, 97, 32, 32);
    if(dir == LEFT &amp;&amp; foot == 1) sprite = player.get(0, 32, 32, 32);
    if(dir == LEFT &amp;&amp; foot == 2) sprite = player.get(66, 32, 32, 32);
    if(dir == DOWN &amp;&amp; foot == 1) sprite = player.get(0, 128, 32, 32);
    if(dir == DOWN &amp;&amp; foot == 2) sprite = player.get(66, 128, 32, 32);
    if(dir == RIGHT &amp;&amp; foot == 1) sprite = player.get(0, 191, 32, 32);
    if(dir == RIGHT &amp;&amp; foot == 2) sprite = player.get(66, 191, 32, 32);
  }

  void show()
  {
    if (!setup &amp;&amp; !load)
    {
      sprite.resize(48, 48);
      image(sprite, x, y);
      fill(map(health, 20, 100, 255, 0), 0, 0);
      ellipse(x, y, 10, 10);
      fill(255);
    }
  }
}
</code></pre>

<p>I am open to any suggestions and opinions.
Thanks</p>

<p>and here is the character.png file:</p>

<p><img src="https://forum.processing.org/two/uploads/imageupload/508/QEL8KBAM7B1C.png" alt="character" title="character" /></p>
]]></description>
   </item>
   <item>
      <title>Init new objec from Class via OSCp5</title>
      <link>https://forum.processing.org/two/discussion/18776/init-new-objec-from-class-via-oscp5</link>
      <pubDate>Sat, 29 Oct 2016 04:39:17 +0000</pubDate>
      <dc:creator>miquel_parera</dc:creator>
      <guid isPermaLink="false">18776@/two/discussions</guid>
      <description><![CDATA[<p>Hello.</p>

<p>Some time ago I am trying to create and destroy objects of classes and modify some of its parameters via OSC messages. I tried it with ArrayLists with controlEvents GUI and it works, but there is no way with OSC.</p>

<p>I made this supermegasimple code if someone wants to implement a solution inside:</p>

<pre><code>import oscP5.*;
import netP5.*;

OscP5 oscP5;
NetAddress myRemoteLocation;

circle obj1;

void setup()
{
  size(800,600);
  oscP5 = new OscP5(this,12000);
}

void draw()
{
  background(0);
}

void oscEvent(final OscMessage theOscMessage) {
    if(theOscMessage.checkAddrPattern("/circle")==true) {
     if(theOscMessage.checkTypetag("i")) { 
       // /circle name create a circle with this name
       // /circle name erase destroy this circle
     }
    }
}

class circle {
  circle(){}
  void display(){
    ellipse(10,10,50,50);
  }
}
</code></pre>

<p>Thanks!</p>
]]></description>
   </item>
   <item>
      <title>How to respond with each point seperate in the spiral</title>
      <link>https://forum.processing.org/two/discussion/17123/how-to-respond-with-each-point-seperate-in-the-spiral</link>
      <pubDate>Mon, 13 Jun 2016 12:37:09 +0000</pubDate>
      <dc:creator>Dom1</dc:creator>
      <guid isPermaLink="false">17123@/two/discussions</guid>
      <description><![CDATA[<p>Hello together,
i am a student from Germany and my english isn´t the best. Sorry for that. I need your help for a project named visual music. I havent so much experience in processing, so i hope you can help me.</p>

<p>My code interprets data from cSound with Processing. The code works, but now i want to change the colour and size values of each generated point in my spiral. It should change them in addiction to the imported data ( int circle_color_r, circle_color_g, circle_color_b and float value). Here is my (Processing)code. Do you have a solution for me?</p>

<pre><code>import netP5.*;
import oscP5.*;
OscP5 oscP5;
NetAddress myRemoteLocation;

int circle_color_r ;
int circle_color_g ;
int circle_color_b ;
float ang=0;
int mx,my;
float value;
float size;

void setup(){
  size(500,500);
  background(0);
  frameRate(100);
  mx=width/2;
  my=height/2;
  oscP5 = new OscP5(this,12000); //Portangabe  
}

void draw(){
  strokeWeight(size); //stärke der Punkte
  rect(0,0,width,height);
  float ray=0.2;
  ang-=1.1; //Winkelgeschwindigkeit

  for(int i=0;i&lt;650;i++){
    ray*=1.0022;
    ray+=0.2;
    float maxray = ray*1.1;//streuung
    float a = radians(ang+i);

    stroke(circle_color_r, circle_color_g, circle_color_b); 
    point(mx+ cos(a)*random(ray,maxray),my+sin(a)*random(ray,maxray)); 
  }
   this.size = value*10;
   saveFrame();
 }
void oscEvent(OscMessage theOscMessage) {
   if(theOscMessage.checkAddrPattern("/freq")==true)
  {
   value = theOscMessage.get(0).floatValue();
  print(value);
  }
  if(theOscMessage.checkAddrPattern("/color")==true)
  {
   circle_color_r = theOscMessage.get(0).intValue();
   circle_color_g = theOscMessage.get(1).intValue();
   circle_color_b = theOscMessage.get(2).intValue();
print(circle_color_r);
  } 
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Combine use of oscP5 and Fisica</title>
      <link>https://forum.processing.org/two/discussion/15969/combine-use-of-oscp5-and-fisica</link>
      <pubDate>Mon, 11 Apr 2016 17:12:19 +0000</pubDate>
      <dc:creator>caggen96</dc:creator>
      <guid isPermaLink="false">15969@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>to make this fast: i'm a noob at processing and programming in general (started a couple of weeks ago), but I LOVE IT! Very fun so far.</p>

<p>My problem with this game I'm trying to create is, well I want to be able to control the "FBox player" (a rectangle that serves as the player) using oscP5. When I move the "//Player" part into draw I'm able to do it but it generates LOTS of boxes and trying to use background() to clean doesn't work. Can anyone help me out with this issue?</p>

<p>To sum up: let me control the box without the program generating hundreds of boxes:)</p>

<p>Many thanks in advance!</p>

<pre><code>OscP5 oscP5;

FWorld world;

float x, y, inputX, inputY;

void setup() {

size(500, 500);

Fisica.init(this);  
world = new FWorld();
world.setEdges();
world.setEdgesRestitution(0.5);

oscP5 = new OscP5(this, 12000);

 // Player
FBox player = new FBox(80, 20);
player.setPosition(x, 450);
world.add(player);

 // Ball
FCircle ball = new FCircle(25);
ball.setPosition(250, 250);
world.add(ball);
}

void draw() {
background(0, 150, 150);

world.step();
world.draw();

x = lerp(x, inputX, 0.08f);
 // y = lerp(y, inputY, 0.08f);

}

void oscEvent(OscMessage msg) {
if (msg.checkAddrPattern("/multi/1")) {
inputX = msg.get(0).floatValue() * width;
 // inputY = msg.get(1).floatValue() * height;

println(x + " " + y);
</code></pre>

<p>}
  }</p>
]]></description>
   </item>
   <item>
      <title>When I turn the 3D space, I want an object remains in place: how to do ?</title>
      <link>https://forum.processing.org/two/discussion/15469/when-i-turn-the-3d-space-i-want-an-object-remains-in-place-how-to-do</link>
      <pubDate>Sun, 13 Mar 2016 09:55:30 +0000</pubDate>
      <dc:creator>all</dc:creator>
      <guid isPermaLink="false">15469@/two/discussions</guid>
      <description><![CDATA[<p>Hello,</p>

<p>I wrote a small P5 code to explain my problem.
In P3D, there are 2 cubes : white cube and red cube.
I want to rotate the white cube in the 3 dimensions without rotate the red cube.
I use a very simple Max standalone control (rotateX, rotateY, rotateZ) to rotate the white cube (OSC). You can download this standalone here : <a href="https://dl.dropboxusercontent.com/u/83095197/Rotation.zip" target="_blank" rel="nofollow">https://dl.dropboxusercontent.com/u/83095197/Rotation.zip</a></p>

<p>This work fine if I rotate only one variable (rotateX with rotateY = 0 et rotateZ = 0; rotateY with rotateX = 0 et rotateZ = 0; rotateZ with rotateX = 0 et rotateY = 0). On the other side, it doesn't work if I rotate 2, 3 variables in the same time : the red cube move. How to maintain the red cube in place by modifying several parameters at once ?</p>

<p>Here, my P5 code :</p>

<pre><code>                        // OSC
                        import oscP5.*;
                        import netP5.*;
                        OscP5 oscP5;
                        NetAddress myRemoteLocation;

                        // VARIABLES
                        int DIMX, DIMY, DIMZ;
                        float translateX, translateY, translateZ;
                        float rotateX, rotateY, rotateZ;


                        void setup() {
                          size(600, 600, P3D); 
                          DIMX = width/2; 
                          DIMY = height/2;
                          DIMZ = 300;

                          // OSC
                          oscP5 = new OscP5(this, 12000);
                          myRemoteLocation = new NetAddress("127.0.0.1", 12000);

                          // VARIABLES
                          translateX = width/2;
                          translateY = height/2;
                          translateZ = -height*2;
                          rotateX = 0;
                          rotateY = 0;
                          rotateZ = 0;
                        }


                        void draw() {
                          background(0);

                          // WHITE CUBE
                          translate(translateX, translateY, translateZ);
                          rotateX(radians(rotateX));
                          rotateY(radians(rotateY));
                          rotateZ(radians(rotateZ));
                          noFill();
                          stroke(255);
                          box(DIMX*2, DIMY*2, DIMZ*2);

                          // RED CUBE
                          pushMatrix();
                          rotateX(radians(rotateX * -1));
                          rotateY(radians(rotateY * -1));
                          rotateZ(radians(rotateZ * -1));
                          noFill();
                          stroke(255, 0, 0);
                          box(DIMX, DIMY, DIMZ);
                          popMatrix();
                        }


                        void oscEvent(OscMessage theOscMessage) {

                          // ROTATE X
                          if (theOscMessage.checkAddrPattern("/max2P5/rotateX")==true) {
                            rotateX=theOscMessage.get(0).floatValue();
                          }

                          // ROTATE Y
                          if (theOscMessage.checkAddrPattern("/max2P5/rotateY")==true) {
                            rotateY=theOscMessage.get(0).floatValue();
                          }

                          // ROTATE Z
                          if (theOscMessage.checkAddrPattern("/max2P5/rotateZ")==true) {
                            rotateZ=theOscMessage.get(0).floatValue();
                          }
                        }
</code></pre>

<p>Thank you :)
Best,
Alex</p>
]]></description>
   </item>
   </channel>
</rss>