Posted by hank,
Tue Aug 21 06:04:00 UTC 2007
This Demo is an example of a major issue in Java. They seriously need to at least give the user a warning before fullscreening. I mean, that demo could have been really bad. Hint: goatse.
On the other hand, this would be AWESOME for presentations.
Tags: java
Posted by hank,
Fri Jul 20 04:41:00 UTC 2007
I’m not one to advocate Java generally, but Processing is totally hawt. Here’s something I screwed around with today:
Ball[] myBalls;
void setup()
{
size(500,500);
frameRate(25);
myBalls = new Ball[300];
for (int i = 0; i < 300; i++) {
myBalls[i] = new Ball();
myBalls[i].x = random(0, 500);
myBalls[i].y = random(0, 500);
myBalls[i].r = random(0, 10);
myBalls[i].xv = random(-5, 5);
myBalls[i].yv = random(-5, 5);
myBalls[i].mycolor = int(random(0, 100));
myBalls[i].myseed = int(random(25,100));
}
}
void draw() {
background(0);
for (int i = 0; i < 300; i++) {
myBalls[i].run();
}
}
class Ball
{
float x; //X acis centroid
float y; //Y axis centroid\
float r; // Radius
float xv; //X axis velocity
float yv; //Y axis velocity
int mycolor;
int myseed;
int counter;
void run()
{
drawShape();
x += xv;
y += yv;
yv += 0.4;
if(x < 0 || x > width) {
xv = -xv;
}
else if(y < 0 || y > height) {
yv = -1.1 * yv;
}
if(counter % myseed == 0) {
xv = random(-5,5);
yv = random(-5,5);
}
counter++;
}
void drawShape()
{
smooth();
ellipseMode(CENTER_RADIUS);
noStroke();
fill(mycolor);
ellipse(x,y,r,r);
}
}
You can download it here: sketch_070719a
Tags: java