Hi folks,
I'm getting some mysterious crashes with the following sketch. It runs fine, but about one time out of ten when I close the sketch it blue-screens my computer (Macbook Pro OSX 10.6.8, Processing v2.0b7)
Help would be much appreciated. Here's the sketch:
float jit1;
float jit2;
int time;
int mrph;
int v1, v2, v3 ,v4 ,v5 ,v6, v7, v8, v9 , v10, v11, v12, v13;
float easing = 0.05;
int chR;
int chG;
int chB;
int bR;
int bG;
int bB;
float x = 100;
float y = 100;
float vx1;
float vx2;
float vx3;
float vx4;
float vx5;
float vx6;
float vx7;
float vx8;
float vx9;
float vx10;
float vx11;
float vx12;
float vx13;
float vdx1;
float vdx2;
float vdx3;
float vdx4;
float vdx5;
float vdx6;
float vdx7;
float vdx8;
float vdx9;
float vdx10;
float vdx11;
float vdx12;
float vdx13;
int hSzX =10;
int hSzY=10;
int spd = 10;
final static int NORTH = 1;
final static int EAST = 2;
final static int SOUTH = 4;
final static int WEST = 8;
int result;
float targetX = 100;
float targetY = 100;
float targetvX;
//create a moment of chance potential
Dueller d1 = new Dueller(random(1000), random(400));
Dueller d2 = new Dueller(random(1000), random(400));
void setup(){
time = 0;
size(1000, 400, P2D);
result = 0;
v1 = int((random(70)+5));
v2 = int((random(70)+5));
v3 = int((random(70)+5));
v4 = int((random(70)+5));
v5 = int((random(70)+5));
v6 = int((random(70)+5));
v7 = int((random(70)+5));
v8 = int((random(70)+5));
v9 = int((random(70)+5));
v10 = int((random(70)+5));
v11 = int((random(70)+5));
v12 = int((random(70)+5));
v13 = int((random(70)+5));
mrph = int(random(2));
//frameRate(60);
bR = int(random(100));
bG = int(random(100));
bB = int(random(100));
chR = bR+(int(random(100)))+175;
chG = bG+(int(random(100)))+175;
chB = bB+(int(random(100)))+175;
}
void draw(){
background(bR, bG, bB);
switch(result) {
case NORTH: targetY-=spd; break;
case EAST: targetX+=spd; break;
case SOUTH: targetY+=spd; break;
case WEST: targetX-=spd; break;
case NORTH|EAST: targetY-=spd; targetX+=spd; break;
case NORTH|WEST: targetY-=spd; targetX-=spd; break;
case SOUTH|EAST: targetY+=spd; targetX+=spd; break;
case SOUTH|WEST: targetY+=spd; targetX-=spd; break;
}
float dx = targetX - x;
if(abs(dx) > 1) {
x += dx * easing;
}
float dy = targetY - y;
if(abs(dy) > 1) {
y += dy * easing;
}
noStroke();
fill(chR, chG, chB, 90);
// rect(x, y, hSzX, hSzY);
if(mrph == 1){
if( millis() > time ){
time = millis() + int(random(2000)); //random delay
v1 = int(random(60)+5);
v2 = int(random(60)+5);
v3 = int(random(60)+5);
v4 = int(random(60)+5);
v5 = int(random(60)+5);
v6 = int(random(60)+5);
v7 = int(random(60)+5);
v8 = int(random(60)+5);
v9 = int(random(60)+5);
v10 = int(random(60)+5);
v11 = int(random(60)+5);
v12 = int(random(60)+5);
v13 = int(random(60)+5);
}
float vdx1 = v1 - vx1;
if(abs(vdx1) > 0.1) {
vx1 += vdx1 * easing;
}
float vdx2 = v2 - vx2;
if(abs(vdx2) > 0.1) {
vx2 += vdx2 * easing;
}
float vdx3 = v3 - vx3;
if(abs(vdx3) > 0.1) {
vx3 += vdx3 * easing;
}
float vdx4 = v4 - vx4;
if(abs(vdx4) > 0.1) {
vx4 += vdx4 * easing;
}
float vdx5 = v5 - vx5;
if(abs(vdx5) > 0.1) {
vx5 += vdx5 * easing;
}
float vdx6 = v6 - vx6;
if(abs(vdx6) > 0.1) {
vx6 += vdx6 * easing;
}
float vdx7 = v7 - vx7;
if(abs(vdx7) > 0.1) {
vx7 += vdx7 * easing;
}
float vdx8 = v8 - vx8;
if(abs(vdx8) > 0.1) {
vx8 += vdx8 * easing;
}
float vdx9 = v9 - vx9;
if(abs(vdx9) > 0.1) {
vx9 += vdx9 * easing;
}
float vdx10 = v10 - vx10;
if(abs(vdx10) > 0.1) {
vx10 += vdx10 * easing;
}
float vdx11 = v11 - vx11;
if(abs(vdx11) > 0.1) {
vx11 += vdx11 * easing;
}
float vdx12 = v12 - vx12;
if(abs(vdx12) > 0.1) {
vx12 += vdx12 * easing;
}
float vdx13 = v13 - vx13;
if(abs(vdx13) > 0.1) {
vx13 += vdx13 * easing;
}
beginShape();
vertex(x+vx1, y+vx2);
vertex(x+vx3, y+vx4);
vertex(x+vx6, y+vx7);
vertex(x+vx8, y+vx9);
vertex(x+vx10, y+vx11);
vertex(x+vx12, y+vx13);
endShape(CLOSE);
}
if(mrph == 0){
beginShape();
vertex(x+v1, y+v2);
vertex(x+v3, y+v4);
vertex(x+v6, y+v7);
vertex(x+v8, y+v9);
vertex(x+v10, y+v11);
vertex(x+v12, y+v13);
endShape(CLOSE);
}
//keyPressed();
jit1 = random(1000)-random(1000);
jit2 = random(1000)-random(1000);
d1.update(x, y, random(0.02), jit1);
d2.update(x, y, random(0.02), jit2);
}
void keyPressed(){
if(key ==CODED){
switch(keyCode) {
case (UP):result |=NORTH;break;
case (RIGHT):result |=EAST;break;
case (DOWN):result |=SOUTH;break;
case (LEFT):result |=WEST;break;
}
}
}
void keyReleased(){
if(key ==CODED){
switch(keyCode) {
case(UP):result ^=NORTH;break;
case(RIGHT):result ^=EAST;break;
case(DOWN):result ^=SOUTH;break;
case(LEFT):result ^=WEST;break;
}
}
}
class Dueller{
//float cx, cy;
//float easingD = 0.01;
//float targetcX, targetcY;
float cx, cy;
Dueller(float initX, float initY){
cx = initX;
cy = initY;
}
void update(float targetcX, float targetcY, float easingD, float jit){
float dcx = targetcX - cx;
if(abs(dcx) > 1) {
cx += (dcx+jit) * easingD;
}
float dcy = targetcY - cy;
if(abs(dcy) > 1) {
cy += (dcy+jit) * easingD;
}
noStroke();
fill(255, 255, 255, 90);
rectMode(CENTER);
rect(cx, cy, random(30), random(30));
}
}
I'm getting some mysterious crashes with the following sketch. It runs fine, but about one time out of ten when I close the sketch it blue-screens my computer (Macbook Pro OSX 10.6.8, Processing v2.0b7)
Help would be much appreciated. Here's the sketch:
float jit1;
float jit2;
int time;
int mrph;
int v1, v2, v3 ,v4 ,v5 ,v6, v7, v8, v9 , v10, v11, v12, v13;
float easing = 0.05;
int chR;
int chG;
int chB;
int bR;
int bG;
int bB;
float x = 100;
float y = 100;
float vx1;
float vx2;
float vx3;
float vx4;
float vx5;
float vx6;
float vx7;
float vx8;
float vx9;
float vx10;
float vx11;
float vx12;
float vx13;
float vdx1;
float vdx2;
float vdx3;
float vdx4;
float vdx5;
float vdx6;
float vdx7;
float vdx8;
float vdx9;
float vdx10;
float vdx11;
float vdx12;
float vdx13;
int hSzX =10;
int hSzY=10;
int spd = 10;
final static int NORTH = 1;
final static int EAST = 2;
final static int SOUTH = 4;
final static int WEST = 8;
int result;
float targetX = 100;
float targetY = 100;
float targetvX;
//create a moment of chance potential
Dueller d1 = new Dueller(random(1000), random(400));
Dueller d2 = new Dueller(random(1000), random(400));
void setup(){
time = 0;
size(1000, 400, P2D);
result = 0;
v1 = int((random(70)+5));
v2 = int((random(70)+5));
v3 = int((random(70)+5));
v4 = int((random(70)+5));
v5 = int((random(70)+5));
v6 = int((random(70)+5));
v7 = int((random(70)+5));
v8 = int((random(70)+5));
v9 = int((random(70)+5));
v10 = int((random(70)+5));
v11 = int((random(70)+5));
v12 = int((random(70)+5));
v13 = int((random(70)+5));
mrph = int(random(2));
//frameRate(60);
bR = int(random(100));
bG = int(random(100));
bB = int(random(100));
chR = bR+(int(random(100)))+175;
chG = bG+(int(random(100)))+175;
chB = bB+(int(random(100)))+175;
}
void draw(){
background(bR, bG, bB);
switch(result) {
case NORTH: targetY-=spd; break;
case EAST: targetX+=spd; break;
case SOUTH: targetY+=spd; break;
case WEST: targetX-=spd; break;
case NORTH|EAST: targetY-=spd; targetX+=spd; break;
case NORTH|WEST: targetY-=spd; targetX-=spd; break;
case SOUTH|EAST: targetY+=spd; targetX+=spd; break;
case SOUTH|WEST: targetY+=spd; targetX-=spd; break;
}
float dx = targetX - x;
if(abs(dx) > 1) {
x += dx * easing;
}
float dy = targetY - y;
if(abs(dy) > 1) {
y += dy * easing;
}
noStroke();
fill(chR, chG, chB, 90);
// rect(x, y, hSzX, hSzY);
if(mrph == 1){
if( millis() > time ){
time = millis() + int(random(2000)); //random delay
v1 = int(random(60)+5);
v2 = int(random(60)+5);
v3 = int(random(60)+5);
v4 = int(random(60)+5);
v5 = int(random(60)+5);
v6 = int(random(60)+5);
v7 = int(random(60)+5);
v8 = int(random(60)+5);
v9 = int(random(60)+5);
v10 = int(random(60)+5);
v11 = int(random(60)+5);
v12 = int(random(60)+5);
v13 = int(random(60)+5);
}
float vdx1 = v1 - vx1;
if(abs(vdx1) > 0.1) {
vx1 += vdx1 * easing;
}
float vdx2 = v2 - vx2;
if(abs(vdx2) > 0.1) {
vx2 += vdx2 * easing;
}
float vdx3 = v3 - vx3;
if(abs(vdx3) > 0.1) {
vx3 += vdx3 * easing;
}
float vdx4 = v4 - vx4;
if(abs(vdx4) > 0.1) {
vx4 += vdx4 * easing;
}
float vdx5 = v5 - vx5;
if(abs(vdx5) > 0.1) {
vx5 += vdx5 * easing;
}
float vdx6 = v6 - vx6;
if(abs(vdx6) > 0.1) {
vx6 += vdx6 * easing;
}
float vdx7 = v7 - vx7;
if(abs(vdx7) > 0.1) {
vx7 += vdx7 * easing;
}
float vdx8 = v8 - vx8;
if(abs(vdx8) > 0.1) {
vx8 += vdx8 * easing;
}
float vdx9 = v9 - vx9;
if(abs(vdx9) > 0.1) {
vx9 += vdx9 * easing;
}
float vdx10 = v10 - vx10;
if(abs(vdx10) > 0.1) {
vx10 += vdx10 * easing;
}
float vdx11 = v11 - vx11;
if(abs(vdx11) > 0.1) {
vx11 += vdx11 * easing;
}
float vdx12 = v12 - vx12;
if(abs(vdx12) > 0.1) {
vx12 += vdx12 * easing;
}
float vdx13 = v13 - vx13;
if(abs(vdx13) > 0.1) {
vx13 += vdx13 * easing;
}
beginShape();
vertex(x+vx1, y+vx2);
vertex(x+vx3, y+vx4);
vertex(x+vx6, y+vx7);
vertex(x+vx8, y+vx9);
vertex(x+vx10, y+vx11);
vertex(x+vx12, y+vx13);
endShape(CLOSE);
}
if(mrph == 0){
beginShape();
vertex(x+v1, y+v2);
vertex(x+v3, y+v4);
vertex(x+v6, y+v7);
vertex(x+v8, y+v9);
vertex(x+v10, y+v11);
vertex(x+v12, y+v13);
endShape(CLOSE);
}
//keyPressed();
jit1 = random(1000)-random(1000);
jit2 = random(1000)-random(1000);
d1.update(x, y, random(0.02), jit1);
d2.update(x, y, random(0.02), jit2);
}
void keyPressed(){
if(key ==CODED){
switch(keyCode) {
case (UP):result |=NORTH;break;
case (RIGHT):result |=EAST;break;
case (DOWN):result |=SOUTH;break;
case (LEFT):result |=WEST;break;
}
}
}
void keyReleased(){
if(key ==CODED){
switch(keyCode) {
case(UP):result ^=NORTH;break;
case(RIGHT):result ^=EAST;break;
case(DOWN):result ^=SOUTH;break;
case(LEFT):result ^=WEST;break;
}
}
}
class Dueller{
//float cx, cy;
//float easingD = 0.01;
//float targetcX, targetcY;
float cx, cy;
Dueller(float initX, float initY){
cx = initX;
cy = initY;
}
void update(float targetcX, float targetcY, float easingD, float jit){
float dcx = targetcX - cx;
if(abs(dcx) > 1) {
cx += (dcx+jit) * easingD;
}
float dcy = targetcY - cy;
if(abs(dcy) > 1) {
cy += (dcy+jit) * easingD;
}
noStroke();
fill(255, 255, 255, 90);
rectMode(CENTER);
rect(cx, cy, random(30), random(30));
}
}
1