Skip to content

Instantly share code, notes, and snippets.

@boyanov83
Created September 17, 2014 17:57
Show Gist options
  • Save boyanov83/ad60e947594c36299f0a to your computer and use it in GitHub Desktop.
Save boyanov83/ad60e947594c36299f0a to your computer and use it in GitHub Desktop.
static void draw(Graphics g) throws InterruptedException {
if (rain.size() < 60) {
rain.add(yy);
yy -= 20;
rain.add(rnd.nextInt(490));
rain.add(Toolkit.getDefaultToolkit().getImage("rock.png"));
}
for (int i = 0; i < rain.size(); i += 3) {
g.drawImage((Image) rain.get(i + 2), (int) rain.get(i + 1), (int) rain.get(i), null);
rain.set(i, ((int) rain.get(i)) + 5);
if ((int) rain.get(i) >= 490) {
rain.set(i, 10);
rain.set(i + 1, rnd.nextInt(490));
} else {
collisionObjectSetter(i, rain);
}
}
try {
Thread.sleep(2);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment