public void init() { space = new Space(1024, 800, this); for (int i = 0; i < 100; i++) { int x = BOUND + STATIC_SIZE / 2 + (int) (Math.random() * (1024 - 2 * (BOUND + STATIC_SIZE / 2))); int y = BOUND + STATIC_SIZE / 2 + (int) (Math.random() * (800 - 2 * (BOUND + STATIC_SIZE / 2))); StaticBar bar = new StaticBar(x, y, STATIC_SIZE * Math.random(), STATIC_SIZE * Math.random()); space.add(bar); } space.rebuildStaticIndexes(); int i = 0; while (i < 1000) { int x = BOUND + SIZE + (int) (Math.random() * (1024 - 2 * (BOUND + SIZE))); int y = BOUND + SIZE + (int) (Math.random() * (800 - 2 * (BOUND + SIZE))); double vx = 5 - Math.random() * 10; double vy = 2 - Math.random() * 4; DynamicBar bar = new DynamicBar(x, y, SIZE, SIZE); bar.setSpeed(vx, vy); if (!space.cross(bar)) { space.add(bar); i++; } } }
public void changeVelocityOf(DynamicBar bar) { bar.vy += 0.1f; }