public void update(float delta) { if (MathUtils.random() < delta * Constants.ICICLE_SPAWNS_PER_SECOND) { Vector2 newIciclePosition = new Vector2(MathUtils.random() * viewport.getWorldWidth(), viewport.getWorldHeight()); Icicle newIcicle = new Icicle(newIciclePosition); icicleList.add(newIcicle); } for (Icicle icicle : icicleList) { icicle.update(delta); } // TODO: begin a removal session icicleList.begin(); // TODO: Remove any icicle completely off the bottom of the screen for (int i = 0; i < icicleList.size; i++) { if (icicleList.get(i).position.y < -Constants.ICICLES_HEIGHT) { icicleList.removeIndex(i); } } // TODO: End removal session icicleList.end(); }
public void update(float delta) { if (MathUtils.random() < delta * Constants.ICICLE_SPAWNS_PER_SECOND) { Vector2 newIciclePosition = new Vector2(MathUtils.random() * viewport.getWorldWidth(), viewport.getWorldHeight()); Icicle newIcicle = new Icicle(newIciclePosition); icicleList.add(newIcicle); } for (Icicle icicle : icicleList) { icicle.update(delta); } icicleList.begin(); for (int i = 0; i < icicleList.size; i++) { if (icicleList.get(i).position.y < -Constants.ICICLES_HEIGHT) { // TODO: Increment count of icicles dodged iciclesDodged++; icicleList.removeIndex(i); } } icicleList.end(); }
public void render(ShapeRenderer renderer) { renderer.setColor(Constants.ICICLE_COLOR); for (Icicle icicle : icicleList) { icicle.render(renderer); } }