<?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 #generation - Processing 2.x and 3.x Forum</title>
      <link>https://forum.processing.org/two/discussions/tagged/feed.rss?Tag=%23generation</link>
      <pubDate>Sun, 08 Aug 2021 20:34:22 +0000</pubDate>
         <description>Tagged with #generation - Processing 2.x and 3.x Forum</description>
   <language>en-CA</language>
   <atom:link href="/two/discussions/tagged%23generation/feed.rss" rel="self" type="application/rss+xml" />
   <item>
      <title>How to Link generated objects with a moving character?</title>
      <link>https://forum.processing.org/two/discussion/22847/how-to-link-generated-objects-with-a-moving-character</link>
      <pubDate>Wed, 31 May 2017 19:54:36 +0000</pubDate>
      <dc:creator>dcolwell18</dc:creator>
      <guid isPermaLink="false">22847@/two/discussions</guid>
      <description><![CDATA[<p>I am creating a code in which we are trying to link a character, in this case Mario, with a sequence of randomly generated blocks. We have created a system of generation for the blocks, but are having trouble having Mario interact with them and stop on the blocks. Any suggestions? Currently the blocks are generated on a series of timers, and his interactions with them are controlled by a series of if statements determining Mario's position. Any suggestions?</p>
]]></description>
   </item>
   <item>
      <title>Chaos game</title>
      <link>https://forum.processing.org/two/discussion/22434/chaos-game</link>
      <pubDate>Sun, 07 May 2017 10:17:26 +0000</pubDate>
      <dc:creator>noahbuddy</dc:creator>
      <guid isPermaLink="false">22434@/two/discussions</guid>
      <description><![CDATA[<p>After I saw the chaos game video from Numberphile, I recreated it that evening but spent much longer playing around with it. I am placing a basic version here thinking someone else may enjoy.
* Edited with suggestions from <a href="/two/profile/jeremydouglass">@jeremydouglass</a></p>

<pre><code>int N = 3; // Number of control points
int MAX_DIST = 60;
int MANY_TIMES = 2000;
float DIV = 2.0; // You can change the rules for drawing the pattern

// Control points
float[] px = new float[N];
float[] py = new float[N];

// The moving point, draws the pattern
float selx = 0;
float sely = 0;

boolean held = false;
int nearest = -1;

void setup()
{
  size(800,600,P2D);

  // Initial points, anywhere you like
  px[0] = width/4;
  py[0] = height/4;
  px[1] = width - (width/4);
  py[1] = height/4;
  px[2] = width - (width/4);
  py[2] = height - (height/4);

  noFill();
  frameRate(60);
  background(0);
}

void mouseMoved()
{
  float neardist = width + height;
  for (int i=0; i&lt;N; i++)
  {
    float nd = dist(px[i],py[i], mouseX,mouseY);
    if (nd &lt; neardist)
    {
      nearest = i;
      neardist = nd;
    }
  }
  if (MAX_DIST &lt; neardist)
  {
    nearest = -1;
  }
}

void mousePressed()
{
  if (-1 != nearest)
  {
    held = true;
  }
}
void mouseReleased()
{
  held = false;
}

void draw()
{
  // This section allows you to move the control points
  if (held)
  {
    px[nearest] = constrain(mouseX,0,width);
    py[nearest] = constrain(mouseY,0,height);
    background(0);
  }
  // Still not to the pattern code

  // Show control points
  for (int i=0; i&lt;N; i++)
  {
    if (i == nearest)
    {
      stroke(0,255,0);
    }
    else
    {
      stroke(0,0,255);
    }
    ellipse( px[i],py[i], MAX_DIST,MAX_DIST );
  }

  stroke(255);
  for (int i=0; i&lt;MANY_TIMES; i++) // Draw many points
  {
    // These are the lines that actually generate the pattern.
    int thistime = (int)random(N);
    float nx = ((px[thistime] - selx) / DIV) + selx;
    float ny = ((py[thistime] - sely) / DIV) + sely;
    selx = nx;
    sely = ny;
    // Yep, that is it.

    point( nx, ny );
  }
}
</code></pre>
]]></description>
   </item>
   <item>
      <title>Infinite Arrays?</title>
      <link>https://forum.processing.org/two/discussion/4480/infinite-arrays</link>
      <pubDate>Thu, 17 Apr 2014 08:17:22 +0000</pubDate>
      <dc:creator>Matyze</dc:creator>
      <guid isPermaLink="false">4480@/two/discussions</guid>
      <description><![CDATA[<p>I want to create infinitely generating terrain for a program I'm making. I tested by adding and subtracting from the coordinates I gave the noise function, which worked out okay for making an infinite map you could travel on.</p>

<p>But what if I want to store the map inside of an array? You can't head west or north very long, because you'll walk right off the map and crash the program (since I was trying to access -1).</p>

<p>I've heard of something called ArrayList, but I'm not sure if that will solve my problem...</p>

<p>Thanks ahead of time for any answers! I appreciate how fast my last question was answered :)</p>
]]></description>
   </item>
   </channel>
</rss>