DoubleA
2011-06-02 18:14:25 UTC
if(_coin.update() == 1) {
this is where it says the operator == is undefined
and this is my interface:
public interface Coin {
int nu = 1;
public void update ();
public void set();
}
class coins implements Coin{
public interface Coin {
public void update();
public void set();
}
}
which is linked to four different coin classes that more or less go like this:
class winter implements Coin {
int coinX, coinY, coinWidth, coinHeight;
winter ( int bX, int bY, int bW, int bH ) // The class constructor
{
coinX = bX;
coinY = bY;
coinWidth = bW;
coinHeight = bH;
}
int update()
{
int movementAmount; // Create and set a variable to hold the amount of white pixels detected in the area where the coin is
movementAmount = 0;
for( int y = coinY; y < (coinY + (coinHeight+1)); y++ ) { // For loop that cycles through all of the pixels in the area the coin occupies
for( int x = coinX; x < (coinX + (coinWidth-1)); x++ ) {
if ( x < width && x > 0 && y < height && y > 0 ) { // If the current pixel is within the screen bondaries
if (brightness(movementImg.pixels[x + (y * width)]) > 127) // and if the brightness is above 127 (in this case, if it is white)
{
movementAmount++; // Add 1 to the movementAmount variable.
}
}
}
}
if (movementAmount > 5) // If more than 5 pixels of movement are detected in the coin area
{
hitCoin++; // Add 1 point
return 1; // Return 1 so that the coin object is destroyed
}
else {
image(wCoin, coinX, coinY); // Draws the coin to the screen
return 0; // Returns '0' so that the coin isn't destroyed
}
}
}
-----
I'm fairly certain it's something to do with the new interface. Anyone got any ideas?