Hey all,
I want to remove a ball that i shoot out of a cannon once it reaches the outer limits of the world,
having troubles getting the right coding for all sides of the world. thanks
boolean topEdge = getY() == 0; boolean leftEdge = getX() == 0; boolean rightEdge = getX() >= getWorld().getWidth() - 1; boolean bottomEdge = getY() >= getWorld().getHeight() - 1; if (topEdge || leftEdge || rightEdge || bottomEdge) getWorld().removeObject(this);
public boolean atLeftEdge() {
boolean leftEdge = getX() == 0;
if(leftEdge) {
getWorld().removeObject(this);
}
public boolean atLeftEdge() {
boolean leftEdge = getX() == 0;
if(leftEdge) {
getWorld().removeObject(this);
}
public boolean objectAtLeftEdge() {
boolean leftEdge = getX() == 0;
if(leftEdge){
return true
}
else {
return false
}
}
public void act {
if(objectAtLeftEdge()==true) {
getWorld().removeObject(this);
return;
}
else {
//whatever you want to do instead
}
}
public boolean objectAtLeftEdge() {
boolean leftEdge = getX() == 0;
if(leftEdge){
return true
}
else {
return false
}
}
public void act {
if(objectAtLeftEdge()==true) {
getWorld().removeObject(this);
return;
}
else {
//whatever you want to do instead
}
}public boolean objectAtLeftEdge() {
return getX() == 0;
}
// and
public void act()
{
if (objectAtLeftEdge()) {
getWorld().removeObject(this);
return;
}
// whatever you want to do instead
}
// if checking all edges, then
public void act()
{
if (objectAtLeftEdge() || objectAtRightEdge() || objectAtTopEdge() || objectAtBottomEdge()) {
getWorld().removeObject(this);
return;
}
// whatever you want to do instead
}