Loading...
Processing Forum
Recent Topics
All Forums
Screen name:
pianokeyzzz
pianokeyzzz's Profile
2
Posts
1
Responses
0
Followers
Activity Trend
Last 30 days
Last 30 days
Date Interval
From Date :
To Date :
Go
Loading Chart...
Posts
Responses
PM
Show:
All
Discussions
Questions
Expanded view
List view
Private Message
Help with resetting the random line function
[4 Replies]
25-Apr-2013 09:46 PM
Forum:
Programming Questions
I am having trouble getting the entire program to reset and start on a new clean background any thoughts?
int num = 2000;
int range = 50;
float[] ax = new float[num];
float[] ay = new float[num];
void setup() {
size(800, 600);
background(0);
for(int i = 0; i < num; i++) {
ax[i] = width/2;
ay[i] = height/2;
}
frameRate(30);
}
void draw() {
float r = random(0, 800);
float a = random(0, 250);
float b = random(0, 250);
float c = random(0, 250);
if (keyPressed) {
if (key == 'a') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'b') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'c') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'd') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'e') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'f') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'g') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'h') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'i') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'j') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'k') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'l') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'm') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'n') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'o') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'p') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'q') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'r') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 's') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 't') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'u') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'v') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'w') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'x') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'y') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
if (key == 'z') {
fill(a, b, c);
rect(r, 300, 50, 50);
}
keyPressed=false;
}
// Shift all elements 1 place to the left
for(int i = 1; i < num; i++) {
ax[i-1] = ax[i];
ay[i-1] = ay[i];
}
// Put a new value at the end of the array
ax[num-1] += random(-range, range);
ay[num-1] += random(-range, range);
// Constrain all points to the screen
ax[num-1] = constrain(ax[num-1], 0, width);
ay[num-1] = constrain(ay[num-1], 0, height);
// Draw a line connecting the points
for(int i=1; i<num; i++) {
float val = float(i)/num * 204.0 + 51;
stroke(val);
line(ax[i-1], ay[i-1], ax[i], ay[i]);
}
if (mousePressed == true) {
background(0);
}
}
How to limit key press to one time and not repeat when help down
[1 Reply]
22-Apr-2013 01:23 PM
Forum:
Programming Questions
having trouble with making it so when i hit a button it only makes one rectangle instead of a few. anyone know how to limit it?
thanks here is the code:
void setup() {
size(2000,1000);
background(250);
}
void draw() {
float r = random(0,2000);
float a = random(0,250);
float b = random(0,250);
float c = random(0,250);
if (keyPressed) {
if (key == 'a' || key == 'A') {
fill(a , b, c);
rect(r, 700, 50, 50); }
if (keyPressed) {
if (key == 'b' || key == 'b') {
fill( a , b ,c);
rect(r, 700, 50, 50); }
}
if (keyPressed) {
if (key == 'c' || key == 'c') {
fill( a , b ,c);
rect(r, 700, 50, 50); }
}
if (keyPressed) {
if (key == 'd' || key == 'D') {
fill( a , b ,c);
rect(r, 700, 50, 50); }
}
}
}
«Prev
Next »
Moderate user : pianokeyzzz
Forum