Hey guys below is my code that i am using to determine if when the program is running a click is within a certain area of the world. I have an object array that needs to have one of the objects .totalPebble set to zero when it is clicked in the area. I used System.out.println("Mouse clicked") to test if it is detecting the click and it doesnt seem to be outputting this could someone please help me, im not sure if it is the null thing or something else.
Thanks in advance
int x = 0; int y = 0; MouseInfo mouse = Greenfoot.getMouseInfo(); if (mouse != null) { x = mouse.getX(); y = mouse.getY(); } if (Greenfoot.mouseClicked(null)) { System.out.println("Mouse clicked"); System.out.println("X: " + x + "Y: " + y); if (((x > 10) && (x < 220)) && ((y > 0) && (y < 270)))//min and max should be the edges of the area; { System.out.println("Dip 1 clicked"); for ( int i=0; i<dipArray[0].totalPebble; i++) { if (i>dipArray.length) //the constant that is controlling the object array is set { //to zero when it is above array length, as there are no more objects i=0; } dipArray[i].totalPebble=dipArray[i].totalPebble+1; //add one pebble to following dips } dipArray[0].totalPebble=0; //set the clicked dip pebble value to 0 } dipArray[0].updatePebble(); }