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;
|
return a;
|
||||||
}
|
}
|
||||||
PVector p1, p2, p3, p4;
|
PVector p1, p2, p3, p4;
|
||||||
void click() {
|
void leftclick() {
|
||||||
if (state < 3) state++;
|
if (state < 3) state++;
|
||||||
else state = 1;
|
else state = 1;
|
||||||
if (state == 1) {
|
if (state == 1) {
|
||||||
@@ -21,9 +21,17 @@ class Bounder {
|
|||||||
}
|
}
|
||||||
if (state == 3) {
|
if (state == 3) {
|
||||||
h = -p2.dist(new PVector(mouseX, mouseY));
|
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() {
|
void update() {
|
||||||
if (state == 2) {
|
if (state == 2) {
|
||||||
h = -p2.dist(new PVector(mouseX, mouseY));
|
h = -p2.dist(new PVector(mouseX, mouseY));
|
||||||
|
|||||||
@@ -55,8 +55,7 @@ void keyPressed() {
|
|||||||
}
|
}
|
||||||
if (key == ' ') {
|
if (key == ' ') {
|
||||||
if (bounder.state == 3) bounder.compile(false);
|
if (bounder.state == 3) bounder.compile(false);
|
||||||
bounder.state = 0;
|
bounder.reset();
|
||||||
println("Bounder reset");
|
|
||||||
}
|
}
|
||||||
if (key == CODED) {
|
if (key == CODED) {
|
||||||
if (keyCode == RIGHT) {
|
if (keyCode == RIGHT) {
|
||||||
@@ -76,7 +75,12 @@ void keyPressed() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void mousePressed() {
|
void mousePressed() {
|
||||||
bounder.click();
|
if(mouseButton == LEFT){
|
||||||
|
bounder.leftclick();
|
||||||
|
}
|
||||||
|
if(mouseButton == RIGHT){
|
||||||
|
bounder.rightclick();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setImage(int i) {
|
void setImage(int i) {
|
||||||
|
|||||||
Reference in New Issue
Block a user