Skip to content

Commit

Permalink
Simulation keys (spacebar and dot/period key) now in accordance with …
Browse files Browse the repository at this point in the history
…requirements
  • Loading branch information
muraliavarma committed Feb 6, 2013
1 parent 587e653 commit 6a7e8e4
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 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.
17 changes: 11 additions & 6 deletions murali_varma_hw2/build-tmp/source/murali_varma_hw2.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ public class murali_varma_hw2 extends PApplet {
final float VELOCITY_MATCHING_WEIGHT = 0.1f;
final float WANDERING_WEIGHT = 0.0002f;

boolean isLoop = true;

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

Expand Down Expand Up @@ -95,15 +97,18 @@ public void clearBackground() {

public void keyPressed() {
//simulation
if (key == 'q') {
noLoop();
if (key == ' ') {
isLoop = !isLoop;
}
else if(key == 'w') {

if (isLoop) {
loop();
}

if(key == '.' || !isLoop) {
noLoop();
redraw();
}
else {
loop();
isLoop = false;
}

//commands
Expand Down
17 changes: 11 additions & 6 deletions murali_varma_hw2/murali_varma_hw2.pde
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ final float COLLISION_AVOIDANCE_WEIGHT = 0.001;
final float VELOCITY_MATCHING_WEIGHT = 0.1;
final float WANDERING_WEIGHT = 0.0002;

boolean isLoop = true;

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

Expand Down Expand Up @@ -80,15 +82,18 @@ void clearBackground() {

void keyPressed() {
//simulation
if (key == 'q') {
noLoop();
if (key == ' ') {
isLoop = !isLoop;
}
else if(key == 'w') {

if (isLoop) {
loop();
}

if(key == '.' || !isLoop) {
noLoop();
redraw();
}
else {
loop();
isLoop = false;
}

//commands
Expand Down

0 comments on commit 6a7e8e4

Please sign in to comment.