reset function for bounder, reset on right click
This commit is contained in:
12
bounder.pde
12
bounder.pde
@@ -9,7 +9,7 @@ class Bounder {
|
||||
return a;
|
||||
}
|
||||
PVector p1, p2, p3, p4;
|
||||
void click() {
|
||||
void leftclick() {
|
||||
if (state < 3) state++;
|
||||
else state = 1;
|
||||
if (state == 1) {
|
||||
@@ -21,9 +21,17 @@ class Bounder {
|
||||
}
|
||||
if (state == 3) {
|
||||
h = -p2.dist(new PVector(mouseX, mouseY));
|
||||
noLoop();
|
||||
}
|
||||
}
|
||||
|
||||
void rightclick(){
|
||||
reset();
|
||||
}
|
||||
void reset(){
|
||||
boolean redrawthis = (state == 3) ? true : false;
|
||||
state = 0;
|
||||
if(redrawthis) redraw();
|
||||
}
|
||||
void update() {
|
||||
if (state == 2) {
|
||||
h = -p2.dist(new PVector(mouseX, mouseY));
|
||||
|
||||
@@ -55,8 +55,7 @@ void keyPressed() {
|
||||
}
|
||||
if (key == ' ') {
|
||||
if (bounder.state == 3) bounder.compile(false);
|
||||
bounder.state = 0;
|
||||
println("Bounder reset");
|
||||
bounder.reset();
|
||||
}
|
||||
if (key == CODED) {
|
||||
if (keyCode == RIGHT) {
|
||||
@@ -76,7 +75,12 @@ void keyPressed() {
|
||||
}
|
||||
|
||||
void mousePressed() {
|
||||
bounder.click();
|
||||
if(mouseButton == LEFT){
|
||||
bounder.leftclick();
|
||||
}
|
||||
if(mouseButton == RIGHT){
|
||||
bounder.rightclick();
|
||||
}
|
||||
}
|
||||
|
||||
void setImage(int i) {
|
||||
|
||||
Reference in New Issue
Block a user