Skip to content

Commit

Permalink
Keys for adding/deleting creatures
Browse files Browse the repository at this point in the history
  • Loading branch information
muraliavarma committed Feb 6, 2013
1 parent 6a7e8e4 commit 8e7a96d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
Binary file modified murali_varma_hw2/build-tmp/murali_varma_hw2$Creature.class
Binary file not shown.
Binary file modified murali_varma_hw2/build-tmp/murali_varma_hw2.class
Binary file not shown.
20 changes: 16 additions & 4 deletions murali_varma_hw2/build-tmp/source/murali_varma_hw2.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class murali_varma_hw2 extends PApplet {
final int REFLECT_MODE = 0;
final int TOROIDAL_MODE = 1;

final int NUM_CREATURES = 100;
final int MIN_CREATURES = 1;
final int MAX_CREATURES = 100;

final float EPSILON = 0.01f;

Expand All @@ -34,8 +35,9 @@ public class murali_varma_hw2 extends PApplet {
final float VELOCITY_MATCHING_WEIGHT = 0.1f;
final float WANDERING_WEIGHT = 0.0002f;

boolean isLoop = true;
int NUM_CREATURES = 10;

boolean isLoop = true;
int edgeBehavior = TOROIDAL_MODE;
int backgroundAlpha = 10; //0 for full trail, 255 for no trail

Expand All @@ -62,8 +64,8 @@ public void drawBackground() {
}

public void initCreatures() {
creatures = new Creature[NUM_CREATURES];
for (int i = 0; i < NUM_CREATURES; i++) {
creatures = new Creature[MAX_CREATURES];
for (int i = 0; i < MAX_CREATURES; i++) {
creatures[i] = new Creature(i);
}
}
Expand Down Expand Up @@ -134,6 +136,16 @@ public void keyPressed() {
clearBackground();
}

if (key == '=' || key == '+') {
NUM_CREATURES = min(NUM_CREATURES+1, MAX_CREATURES);
//reinit this newly added creature
creatures[NUM_CREATURES-1].init();
}

if (key == '-' || key == '-') {
NUM_CREATURES = max(NUM_CREATURES-1, MIN_CREATURES);
}

//forces
if (key == '1') {
flockCenteringForce = !flockCenteringForce;
Expand Down
20 changes: 16 additions & 4 deletions murali_varma_hw2/murali_varma_hw2.pde
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ final int CONTROLS_WIDTH = 100;
final int REFLECT_MODE = 0;
final int TOROIDAL_MODE = 1;

final int NUM_CREATURES = 100;
final int MIN_CREATURES = 1;
final int MAX_CREATURES = 100;

final float EPSILON = 0.01;

Expand All @@ -19,8 +20,9 @@ final float COLLISION_AVOIDANCE_WEIGHT = 0.001;
final float VELOCITY_MATCHING_WEIGHT = 0.1;
final float WANDERING_WEIGHT = 0.0002;

boolean isLoop = true;
int NUM_CREATURES = 10;

boolean isLoop = true;
int edgeBehavior = TOROIDAL_MODE;
int backgroundAlpha = 10; //0 for full trail, 255 for no trail

Expand All @@ -47,8 +49,8 @@ void drawBackground() {
}

void initCreatures() {
creatures = new Creature[NUM_CREATURES];
for (int i = 0; i < NUM_CREATURES; i++) {
creatures = new Creature[MAX_CREATURES];
for (int i = 0; i < MAX_CREATURES; i++) {
creatures[i] = new Creature(i);
}
}
Expand Down Expand Up @@ -119,6 +121,16 @@ void keyPressed() {
clearBackground();
}

if (key == '=' || key == '+') {
NUM_CREATURES = min(NUM_CREATURES+1, MAX_CREATURES);
//reinit this newly added creature
creatures[NUM_CREATURES-1].init();
}

if (key == '-' || key == '-') {
NUM_CREATURES = max(NUM_CREATURES-1, MIN_CREATURES);
}

//forces
if (key == '1') {
flockCenteringForce = !flockCenteringForce;
Expand Down

0 comments on commit 8e7a96d

Please sign in to comment.