@Override public int compare(GameObject o1, GameObject o2) { if (o1.getY() < o2.getY()) { return -1; } else if (o1.getY() > o2.getY()) { return 1; } else { return 0; } }
public void drawPickables() { Collections.sort(objects, new ItemSorter()); for (GameObject o : objects) { if (o instanceof Pickable) { o.delete(); o.draw(); } } }
public void drawObjects() { for (GameObject o : objects) { o.draw(); } }
public void addObject(GameObject object) { object.createObject(pos); objects.add(object); drawPickables(); }