Permalink
Browse files

Triangular boids, print statement when force toggled

  • Loading branch information...
1 parent b1322e6 commit e11dd194f6a316bc8303efd9871abeab841482c2 @muraliavarma committed Feb 8, 2013
@@ -35,7 +35,14 @@ class Creature {
void draw() {
fill (255);
- arc(SCREEN_WIDTH * posX, SCREEN_HEIGHT * posY, radius, radius, 0, 2 * PI);
+ // arc(SCREEN_WIDTH * posX, SCREEN_HEIGHT * posY, radius, radius, 0, 2 * PI);
+ float s = 10; //radius of the circuscribing circle of this isosceles triangle
+ pushMatrix();
+ translate(SCREEN_WIDTH * posX, SCREEN_HEIGHT * posY);
+ rotate(PI/2 + atan2(velY, velX));
+ triangle(0, -s, -s * 0.707, s * 0.707, s * 0.707, s * 0.707);
+ translate(-SCREEN_WIDTH * posX, -SCREEN_HEIGHT * posY);
+ popMatrix();
}
void update() {
@@ -66,4 +66,11 @@ void keyPressed() {
if (key == '4') {
wanderingForce = !wanderingForce;
}
+
+ if (key >= '1' && key <= '4') {
+ println("Centering: " + (flockCenteringForce?"on":"off") +
+ ", Collisions: " + (velocityMatchingForce?"on":"off") +
+ ", Velocity matching: " + (collisionAvoidanceForce?"on":"off") +
+ ", Wandering: " + (wanderingForce?"on":"off"));
+ }
}
Binary file not shown.
Binary file not shown.
@@ -142,7 +142,17 @@ public void init() {
public void draw() {
fill (255);
- arc(SCREEN_WIDTH * posX, SCREEN_HEIGHT * posY, radius, radius, 0, 2 * PI);
+ // arc(SCREEN_WIDTH * posX, SCREEN_HEIGHT * posY, radius, radius, 0, 2 * PI);
+ float s = 10; //radius of the circuscribing circle of this isosceles triangle
+ pushMatrix();
+ translate(SCREEN_WIDTH * posX, SCREEN_HEIGHT * posY);
+ rotate(PI/2 + atan2(velY, velX));
+ // triangle(SCREEN_WIDTH * posX, SCREEN_HEIGHT * posY - s,
+ // SCREEN_WIDTH * posX - s * 0.707, SCREEN_HEIGHT * posY + s * 0.707,
+ // SCREEN_WIDTH * posX + s * 0.707, SCREEN_HEIGHT * posY + s * 0.707);
+ triangle(0, -s, -s * 0.707f, s * 0.707f, s * 0.707f, s * 0.707f);
+ translate(-SCREEN_WIDTH * posX, -SCREEN_HEIGHT * posY);
+ popMatrix();
}
public void update() {
@@ -355,6 +365,13 @@ public void keyPressed() {
if (key == '4') {
wanderingForce = !wanderingForce;
}
+
+ if (key >= '1' && key <= '4') {
+ println("Centering: " + (flockCenteringForce?"on":"off") +
+ ", Collisions: " + (velocityMatchingForce?"on":"off") +
+ ", Velocity matching: " + (collisionAvoidanceForce?"on":"off") +
+ ", Wandering: " + (wanderingForce?"on":"off"));
+ }
}
HashMap flockCenterGrid;
HashMap collisionAvoidanceGrid;

0 comments on commit e11dd19

Please sign in to comment.