@Override public void update() { final Iterator<CircleParticle> it = particles.iterator(); while (it.hasNext()) { final CircleParticle p = it.next(); p.update(); p.setOpacity(Math.min(255, p.getLife()) / 255); if (p.isDead()) { it.remove(); } } if (lastParticleTime <= 0) { final int leftScreen = (int) level.getMapViewport().getX(); final int rightScreen = (int) (level.getMapViewport().getX() + level.getMapViewport().getRect2D().getWidth()); final int size = MathUtils.getRandomInt(10, 20); final Color color = new Color(190, MathUtils.getRandomInt(190, 220), MathUtils.getRandomInt(190, 240)); final CircleParticle p = new CircleParticle( level, MathUtils.getRandomInt(leftScreen - 100, rightScreen + 100), -10, size, size, 255, color); p.setCollision(false); p.applyForce(new Vec2D(MathUtils.getRandomFloat(-1, 1), MathUtils.getRandomFloat(1, 3))); particles.add(p); lastParticleTime = frequency; } else { lastParticleTime--; } }
public final Corners getCornersAreSolid(final double x, final double y) { final int leftTile = (int) (x / Tile.SIZE); final int rightTile = (int) ((x + moveData.collisionBox.getWidth()) / Tile.SIZE); final int topTile = (int) (y / Tile.SIZE); final int bottomTile = (int) ((y + moveData.collisionBox.getHeight()) / Tile.SIZE); final boolean topLeft = hasAttribute(parentLevel.getMap(), Attribute.SOLID, topTile, leftTile); final boolean topRight = hasAttribute(parentLevel.getMap(), Attribute.SOLID, topTile, rightTile); final boolean bottomLeft = hasAttribute(parentLevel.getMap(), Attribute.SOLID, bottomTile, leftTile); final boolean bottomRight = hasAttribute(parentLevel.getMap(), Attribute.SOLID, bottomTile, rightTile); final Corners solidCorners = new Corners(); solidCorners.topLeft = topLeft; solidCorners.topRight = topRight; solidCorners.bottomRight = bottomRight; solidCorners.bottomLeft = bottomLeft; return solidCorners; }
public boolean isOffScreen() { return !parentLevel.getMapViewport().intersects(getRect2D()); }