Here is the mobile processing version:
Quote:
import processing.phone.*;
Phone p;
int x, y, blockWidth, blockHeight, gridWidth, gridHeight;
int[] colorRange=new int[6];
int modWidth, modHeight;
int power;
int gridStartWidth, gridStartHeight;
int i=0;
boolean paused, randomSize;
void calcBlockWidth() {
blockWidth=(width-modWidth)/gridWidth;
blockHeight=(height-modHeight)/gridHeight;
}
void setup() {
p=new Phone(this);
p.fullscreen();
background(0);
int[] theColorRange={255,0,255,0,255,0};
colorRange=theColorRange;
modWidth=width%64; //make sure width of draw area divisible by 64
modHeight=height%80; //make sure height of draw area divisible by 80
gridWidth=gridStartWidth=4;
gridHeight=gridStartHeight=5;
calcBlockWidth();
randomSize=true;
}
void draw() {
if(paused==false) {
if (randomSize) {
if (random(100)==7) {
power=pow(2,random(3)+1);
gridWidth=gridStartWidth*power;
gridHeight=gridStartHeight*power;
calcBlockWidth();
}
}
fill(random(colorRange[0])+colorRange[1],random(colorRange[2])+colorRange[3],random(colorRange[4])+colorRange[5]);
x=random(gridWidth-1);
y=random(gridHeight-1);
rect (x*blockWidth+(modWidth/2),y*blockHeight+(modHeight/2),blockWidth,blockHeight);
}
}
void keyPressed() {
switch (keyCode) {
case LEFT:
paused=false;
gridWidth=max(gridStartWidth,gridWidth/2);
gridHeight=max(gridStartHeight,gridHeight/2);
calcBlockWidth();
break;
case RIGHT:
paused=false;
gridWidth=min(gridWidth*2,gridStartWidth*16);
gridHeight=min(gridHeight*2,gridStartHeight*16);
calcBlockWidth();
break;
case UP:
paused=false;
background(0);
break;
case DOWN:
paused=!paused;
break;
case FIRE:
randomSize=!randomSize;
break;
}
switch (key) {
case '1':
int[] the1ColorRange={60,180,60,20,60,20};
colorRange=the1ColorRange;
background(0);
break;
case '2':
int[] the2ColorRange={60,180,60,180,80,20};
colorRange=the2ColorRange;
background(0);
break;
case '3':
int[] the3ColorRange={80,20,80,20,60,180};
colorRange=the3ColorRange;
background(0);
break;
case '4':
int[] the4ColorRange={255,0,255,0,255,0};
colorRange=the4ColorRange;
background(0);
break;
}
}