Hi, two empty methods have been supplied and its my job to implement both of them. Please tell me if the first method is correct? Also the program itself consists of a 'playerObject' (a circle) which can be moved around with the cursor keys. Another 4 random sized stationary circles and their positions are also displayed which are held in the GameObject barriers[]. What I'm having trouble with is the 'collision' method. I would like to implement the radius of the 'object' and compare that with the radius of the 4 other circles in the 'barriers[]'. So if the separation between them is less than the radius of all the objects a collision is detected. I have no idea how to do this. I can get the Width of the 'GameObject object' but what about the 'GameObject barriers[]' ??? Can i do this without using any standard libraries? Thanks and sorry if I asked too many questions.
public static double distance(GameObject object1, GameObject object2) // TODO stub { float x1 = object1.getX(); float y1 = object1.getY(); float x2 = object2.getX(); float y2 = object2.getY(); System.out.println(x1 + " " + x2 + " " + y1 + " " + y2); return Math.sqrt(Math.pow((x1 - y1), 2) + Math.pow((x2 - y2), 2)); } /** * Determine if the object collides with a barrier * @param object the player object * @param barriers array of barriers * @return true if the player collides with a barrier */ public static boolean collision(GameObject object, GameObject[] barriers) // TODO stub { float radius = object.getWidth()/2; return false; }